Parse the metadata.rb into a dict.
549671
def parse(self):
        """"""
        data = utils.ruby_lines(self.readlines())
        data = [tuple(j.strip() for j in line.split(None, 1))
                for line in data]
        depends = {}
        for line in data:
            if not len(line) == 2:
                continue
            key, value = line
            if key == 'depends':
                value = value.split(',')
                lib = utils.ruby_strip(value[0])
                detail = [utils.ruby_strip(j) for j in value[1:]]
                depends[lib] = detail
        datamap = {key: utils.ruby_strip(val) for key, val in data}
        if depends:
            datamap['depends'] = depends
        self.seek(0)
        return datamap
162702
def _from_metadata(self, urlpath):
        """"""
        md = self.get_metadata(urlpath)
        if md is not None:
            return [self._path(urlpath)]
528712
def metadata_to_dict(metadata):
    

    tree = etree.parse(metadata)
    root = tree.getroot()

    meta = OrderedDict()

    keys = [
        'SPACECRAFT_NAME',
        'PRODUCT_STOP_TIME',
        'Cloud_Coverage_Assessment',
        'PROCESSING_LEVEL',
        'PRODUCT_TYPE',
        'PROCESSING_BASELINE',
        'SENSING_ORBIT_NUMBER',
        'SENSING_ORBIT_DIRECTION',
        'PRODUCT_FORMAT',
    ]

    # grab important keys from the file
    for key in keys:
        try:
            meta[key.lower()] = root.findall('.//' + key)[0].text
        except IndexError:
            meta[key.lower()] = None

    meta['product_cloud_coverage_assessment'] = float(meta.pop('cloud_coverage_assessment'))

    meta['sensing_orbit_number'] = int(meta['sensing_orbit_number'])

    # get tile list
    meta['tiles'] = get_tiles_list(root.findall('.//Product_Organisation')[0])

    # get available bands
    if root.findall('.//Band_List'):
        bands = root.findall('.//Band_List')[0]
        meta['band_list'] = []
        for b in bands:
            band = b.text.replace('B', '')
            if len(band) == 1:
                band = 'B' + pad(band, 2)
            else:
                band = b.text
            meta['band_list'].append(band)
    else:
        bands = root.findall('.//Spectral_Information_List')[0]
        meta['band_list'] = []
        for b in bands:
            band = b.attrib['physicalBand'].replace('B', '')
            if len(band) == 1:
                band = 'B' + pad(band, 2)
            else:
                band = b.attrib['physicalBand']
            meta['band_list'].append(band)

    return meta
657547
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'entity') and self.entity is not None:
            _dict['entity'] = self.entity
        if hasattr(self, 'location') and self.location is not None:
            _dict['location'] = self.location
        if hasattr(self, 'value') and self.value is not None:
            _dict['value'] = self.value
        if hasattr(self, 'confidence') and self.confidence is not None:
            _dict['confidence'] = self.confidence
        if hasattr(self, 'metadata') and self.metadata is not None:
            _dict['metadata'] = self.metadata
        if hasattr(self, 'groups') and self.groups is not None:
            _dict['groups'] = [x._to_dict() for x in self.groups]
        if hasattr(self, '_additionalProperties'):
            for _key in self._additionalProperties:
                _value = getattr(self, _key, None)
                if _value is not None:
                    _dict[_key] = _value
        return _dict
1154155
def from_metadata(metadata: Metadata) -> Any:
        
        irods_metadata = IrodsMetadata()
        for key, value in metadata.items():
            irods_metadata[key] = {value}
        return irods_metadata
459728
def parse(self):
        """"""
        if not self.parsed.get('migration'):
            raise ParseError(u"'migration' key is missing", YAML_EXAMPLE)
        self.check_dict_expected_keys(
            {'options', 'versions'}, self.parsed['migration'], 'migration',
        )
        return self._parse_migrations()
651797
def metadata():
    """"""
    with open(os.path.join(charm_dir(), 'metadata.yaml')) as md:
        return yaml.safe_load(md)
244599
def read_metadata(self):  # type: () ->Dict[str,str]
        
        config = configparser.ConfigParser()
        config.read(self.file_inventory.config_files[0])
        try:
            return {"setup.cfg": config["metadata"]["version"]}
        except KeyError:
            return {}
1187817
def parse_metadata(self, metadata_xml):
        
        try:
            metadata = dict()
            mdata = xmltodict.parse(metadata_xml)['metadata']
            metadata['revision'] = mdata['revision']
            metadata['manifests'] = dict()

            # check if multiple manifests are present
            if type(mdata['data']) is list:
                manifests = mdata['data']
            else:
                manifests = [mdata['data']]

            for manifest in manifests:
                manifest_dict = dict()
                manifest_dict['type'] = manifest['@type']
                manifest_dict['checksum'] = manifest['checksum']
                manifest_dict['open_checksum'] = manifest['open_checksum']
                manifest_dict['location'] = manifest['location']['@href']
                manifest_dict['timestamp'] = datetime.fromtimestamp(
                                                 int(manifest['timestamp']))
                manifest_dict['size'] = int(manifest['size'])
                manifest_dict['open_size'] = int(manifest['open_size'])
                metadata['manifests'][manifest['@type']] = manifest_dict

        except Exception as e:
            raise RepositoryError("{0}/{1}".format(self.url,self.metadata_dir,
                                                   self.metadata_file), e)

        return metadata
605493
def load_metadata(stream):
    """"""
    try:
        metadata = json.load(
            stream, encoding='utf8', object_pairs_hook=OrderedDict)
    except json.JSONDecodeError as e:
        err = RuntimeError('Error parsing {}: {}'.format(stream.name, e))
        raise_from(err, e)
    else:
        # convert changelog keys back to ints for sorting
        for group in metadata:
            if group == '$version':
                continue
            apis = metadata[group]['apis']
            for api in apis.values():
                int_changelog = OrderedDict()
                for version, log in api.get('changelog', {}).items():
                    int_changelog[int(version)] = log
                api['changelog'] = int_changelog
    finally:
        stream.close()

    return metadata
382912
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'id') and self.id is not None:
            _dict['id'] = self.id
        if hasattr(self, 'metadata') and self.metadata is not None:
            _dict['metadata'] = self.metadata
        if hasattr(self, 'collection_id') and self.collection_id is not None:
            _dict['collection_id'] = self.collection_id
        if hasattr(self,
                   'result_metadata') and self.result_metadata is not None:
            _dict['result_metadata'] = self.result_metadata._to_dict()
        if hasattr(self, 'title') and self.title is not None:
            _dict['title'] = self.title
        if hasattr(self, '_additionalProperties'):
            for _key in self._additionalProperties:
                _value = getattr(self, _key, None)
                if _value is not None:
                    _dict[_key] = _value
        return _dict
121359
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'model') and self.model is not None:
            _dict['model'] = self.model
        return _dict
36866
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'label') and self.label is not None:
            _dict['label'] = self.label
        if hasattr(self, 'provenance_ids') and self.provenance_ids is not None:
            _dict['provenance_ids'] = self.provenance_ids
        return _dict
116324
def to_dict(self):
        """"""
        error_dict = {}
        for field in ('status', 'source', 'title', 'detail', 'id', 'code', 'links', 'meta'):
            if getattr(self, field, None):
                error_dict.update({field: getattr(self, field)})

        return error_dict
862197
def _read_routine_metadata(self):
        
        metadata = {}
        if os.path.isfile(self._metadata_filename):
            with open(self._metadata_filename, 'r') as file:
                metadata = json.load(file)

        return metadata
795908
def read_metadata(text, ext):
    """"""
    ext = '.' + ext.split('.')[-1]
    lines = text.splitlines()

    if ext in ['.md', '.Rmd']:
        comment = ''
    else:
        comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#')

    metadata, _, _, _ = header_to_metadata_and_cell(lines, comment, ext)
    if ext in ['.r', '.R'] and not metadata:
        metadata, _, _, _ = header_to_metadata_and_cell(lines, "#'", ext)

    return metadata
826179
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'synonym') and self.synonym is not None:
            _dict['synonym'] = self.synonym
        if hasattr(self, 'created') and self.created is not None:
            _dict['created'] = datetime_to_string(self.created)
        if hasattr(self, 'updated') and self.updated is not None:
            _dict['updated'] = datetime_to_string(self.updated)
        return _dict