Read metadata if required
545080
function(cb) {
        if (!readMetadata) {
          return cb();
        }

        self.ffprobe(0, function(err, data) {
          if (!err) {
            self._ffprobeData = data;
          }

          cb();
        });
      }
609202
private String loadExistingMetadata(Path metadataFilename, int branchId) {
    try {
      FileSystem fsForBranch = writerFileSystemByBranches.get(branchId);
      if (!fsForBranch.exists(metadataFilename)) {
        return null;
      }
      FSDataInputStream existingMetadata = writerFileSystemByBranches.get(branchId).open(metadataFilename);
      return IOUtils.toString(existingMetadata, StandardCharsets.UTF_8);
    } catch (IOException e) {
      LOG.warn("IOException {} while trying to read existing metadata {} - treating as null", e.getMessage(),
          metadataFilename.toString());
      return null;
    }
  }
376044
def _read_content(self):
        
        if self._path_in_arc:
            with zipfile.ZipFile(file=str(self._metadata_file)) as zf:
                self._content = json.loads(
                    zf.read(self._path_in_arc).decode('utf-8'),
                    object_pairs_hook=OrderedDict)
        else:
            with self._metadata_file.open('r') as mdf:
                self._content = json.load(mdf,
                                          object_pairs_hook=OrderedDict)
985671
def getMetadata(self, remote, address, key):
        """"""
        if self._server is not None:
            # pylint: disable=E1121
            return self._server.getAllMetadata(remote, address, key)
871913
def get_metadata(self, key) -> str:
        
        return self.metadata[key] if key in self.metadata else None
1180638
def get_dependency_metadata():
    ''''''
    link = os.path.join(_api_url(), 'meta.txt')
    return _process_req_txt(requests.get(link)).split('\n')
300470
def read_json(self):
        
        with reading_ancillary_files(self):
            metadata = super(GenericLayerMetadata, self).read_json()

        return metadata
93379
def _from_metadata(self, urlpath):
        """"""
        md = self.get_metadata(urlpath)
        if md is not None:
            return [e['cache_path'] for e in md]
1143181
def metaseries_description_metadata(description):
    """"""
    if not description.startswith('<MetaData>'):
        raise ValueError('invalid MetaSeries image description')

    from xml.etree import cElementTree as etree  # delayed import
    root = etree.fromstring(description)
    types = {'float': float, 'int': int,
             'bool': lambda x: asbool(x, 'on', 'off')}

    def parse(root, result):
        # recursive
        for child in root:
            attrib = child.attrib
            if not attrib:
                result[child.tag] = parse(child, {})
                continue
            if 'id' in attrib:
                i = attrib['id']
                t = attrib['type']
                v = attrib['value']
                if t in types:
                    result[i] = types[t](v)
                else:
                    result[i] = v
        return result

    adict = parse(root, {})
    if 'Description' in adict:
        adict['Description'] = adict['Description'].replace('&#13;&#10;', '\n')
    return adict
1348924
def metadata(self):
    
    if self._info is None:
      try:
        self._info = self._api.objects_get(self._bucket, self._key)
      except Exception as e:
        raise e
    return ObjectMetadata(self._info) if self._info else None
913439
def get_admin_metadata(self):
        """"""
        logger.debug("Getting admin metdata")
        text = self.get_text(self.get_admin_metadata_key())
        return json.loads(text)
1129694
def get_metadata(self, namespace, name):
        ""

        if namespace in NAMESPACES:
            namespace = NAMESPACES[namespace]

        return self.metadata[namespace].get(name, [])
573255
def available_metadata(self):
        
        url = self.base_url + 'metadata/types'
        headers = {'Authorization': 'Bearer {}'.format(self.auth())}
        r = requests.get(url, headers=headers)
        return pd.read_json(r.content, orient='records')['name']
1061655
def get_metadata(self, dataset_identifier, content_type="json"):
        '''
        
        '''
        resource = _format_old_api_request(dataid=dataset_identifier, content_type=content_type)
        return self._perform_request("get", resource)
455137
def _read_metadata(self):
        

        filetype = self.fp.readline().strip()
        filetitle = self.fp.readline().strip()
        # Decode to UTF string, if possible
        try:
            filetype = str(filetype, 'utf-8')
            filetitle = str(filetitle, 'utf-8')
        except:
            # TODO: Handle this edge-case of converting file metadata more elegantly.
            pass

        self.__setattr__('filetype', filetype)
        self.__setattr__('filetitle', filetitle)
1079326
def visit_Metadata(self, metadata, *args, **kwargs):
        """"""
        result = OrderedDict()
        put_scalar = lambda name, json_name=None: self.optional_attribute_scalar(result, metadata, name, json_name)
        put_list = lambda name, json_name=None: self.optional_attribute_list(result, metadata, name, json_name)

        put_scalar('name')
        put_scalar('description')
        put_scalar('author')
        put_scalar('copyright')
        put_list('links')
        put_scalar('time')
        put_scalar('keywords')
        put_scalar('bounds')
        put_list('extensions')

        return result
646204
def read_metadata(self, file_path):  # type: (str) ->str
        
        config = configparser.ConfigParser()
        config.read(file_path)
        try:
            return unicode(config["metadata"]["version"])
        except KeyError:
            return ""