Пример #1
0
    def parse(self, content, path=None):
        """Parse the info file described by the given content.

        @param content: Content of the info file to parse.
        @param path: Optional path of the loaded file.  Used when raising
            errors.

        @raise MetaDataError: When errors are found in the info data.
        """
        try:
            self.parse_serialization_data(
                serializer.yaml_load(content), path)
        except yaml.MarkedYAMLError, e:
            # Capture the path name on the error if present.
            if path is not None:
                e.problem_mark = serializer.yaml_mark_with_path(
                    path, e.problem_mark)
            raise
Пример #2
0
    def parse(self, data, pathname=None):
        """

        Load data into the config object.

        Data can be a properly encoded YAML string or a dict, such as
        one returned by `get_serialization_data`.

        Each call to `parse` replaces any existing data.

        :param data: Python dict or YAML encoded dict containing a valid
                     config options specification.
        :param pathname: optional pathname included in some errors.

        """
        if isinstance(data, basestring):
            try:
                raw_data = serializer.yaml_load(data)
            except yaml.MarkedYAMLError, e:
                if pathname is not None:
                    e.problem_mark = serializer.yaml_mark_with_path(
                        pathname, e.problem_mark)
                raise