Convert fileattr metadata in json metadata
    :param dict md: metadata dictionary
    :rtype: PosixFileAttr or WindowsFileAttr or None
    :return: fileattr metadata
972374
def fileattr_from_metadata(md):
    # type: (dict) -> collections.namedtuple
    
    try:
        mdattr = json.loads(
            md[JSON_KEY_BLOBXFER_METADATA])[_JSON_KEY_FILE_ATTRIBUTES]
    except (KeyError, TypeError):
        return None
    else:
        if blobxfer.util.on_windows():
            global _FILEATTR_WARNED_ON_WINDOWS
            if not _FILEATTR_WARNED_ON_WINDOWS:
                _FILEATTR_WARNED_ON_WINDOWS = True
                logger.warning(
                    'file attributes store/restore on Windows is not '
                    'supported yet')
            fileattr = None
        else:
            try:
                fileattr = PosixFileAttr(
                    mode=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_MODE],
                    uid=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_UID],
                    gid=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_GID],
                )
            except KeyError:
                fileattr = None
        return fileattr
162702
def _from_metadata(self, urlpath):
        """"""
        md = self.get_metadata(urlpath)
        if md is not None:
            return [self._path(urlpath)]
188034
def encryption_metadata_exists(md):
        # type: (dict) -> bool
        
        try:
            if blobxfer.util.is_not_empty(
                    md[EncryptionMetadata._METADATA_KEY_NAME]):
                return True
        except (KeyError, TypeError):
            pass
        return False
941433
def vectored_io_from_metadata(md):
    # type: (dict) -> collections.namedtuple
    
    try:
        mdattr = json.loads(
            md[JSON_KEY_BLOBXFER_METADATA])[_JSON_KEY_VECTORED_IO]
    except (KeyError, TypeError):
        pass
    else:
        if mdattr[_JSON_KEY_VECTORED_IO_MODE] == _JSON_KEY_VECTORED_IO_STRIPE:
            mdstripe = mdattr[_JSON_KEY_VECTORED_IO_STRIPE]
            try:
                nextptr = explode_vectored_io_next_entry(
                    mdstripe[_JSON_KEY_VECTORED_IO_STRIPE_NEXT])
            except (KeyError, AttributeError):
                nextptr = None
            vio = VectoredStripe(
                total_size=mdstripe[_JSON_KEY_VECTORED_IO_STRIPE_TOTAL_SIZE],
                offset_start=mdstripe[
                    _JSON_KEY_VECTORED_IO_STRIPE_OFFSET_START],
                total_slices=mdstripe[
                    _JSON_KEY_VECTORED_IO_STRIPE_TOTAL_SLICES],
                slice_id=mdstripe[_JSON_KEY_VECTORED_IO_STRIPE_SLICE_ID],
                next=nextptr,
            )
            return vio
        else:
            raise RuntimeError('Cannot handle Vectored IO mode: {}'.format(
                mdattr[_JSON_KEY_VECTORED_IO_MODE]))
    return None
903832
def _load_from_file(metadata, load_func):
    
    config_filename = get_config_filename(metadata)
    if config_filename is None:
        return dict()

    with open(config_filename, "r") as file_:
        data = load_func(file_.read())
        return dict(data)
1161454
def _convert_md_type(self, type_to_convert: str):
        
        if type_to_convert in FILTER_TYPES:
            return FILTER_TYPES.get(type_to_convert)
        elif type_to_convert in FILTER_TYPES.values():
            return [k for k, v in FILTER_TYPES.items() if v == type_to_convert][0]
        else:
            raise ValueError(
                "Incorrect metadata type to convert: {}".format(type_to_convert)
            )
231751
def _parse(self):
        
        return MetadataFile(
            self.filename,
            self.raw_data,
            decoders.parse_meta(self.filename, self.raw_data)
        )
1272570
def save_metadata_json(self, filename: str, structure: JsonExportable) -> None:
        """"""
        if self.compress_json:
            filename += '.json.xz'
        else:
            filename += '.json'
        save_structure_to_file(structure, filename)
        if isinstance(structure, (Post, StoryItem)):
            # log 'json ' message when saving Post or StoryItem
            self.context.log('json', end=' ', flush=True)
902838
def libvlc_media_save_meta(p_md):
    '''
    '''
    f = _Cfunctions.get('libvlc_media_save_meta', None) or \
        _Cfunction('libvlc_media_save_meta', ((1,),), None,
                    ctypes.c_int, Media)
    return f(p_md)
601400
def load_metadata_from_file(filename):
    
    try:
        extension = os.path.splitext(filename)[1]
        return _metadata_loader[extension](filename)
    except KeyError:
        raise TypeError('Cannot read metadata from file %s, extension %s not '
                        'supported at this time' % (filename, extension))
1135573
def metadata_extractor(self):
        
        if not hasattr(self, '_local_file'):
            raise AttributeError("local_file attribute must be set before "
                                 "calling metadata_extractor")
        if not hasattr(self, '_metadata_extractor'):
            if self.local_file.endswith('.whl'):
                logger.info("Getting metadata from wheel using "
                            "WheelMetadataExtractor.")
                extractor_cls = metadata_extractors.WheelMetadataExtractor
            else:
                logger.info("Getting metadata from setup.py using "
                            "SetupPyMetadataExtractor.")
                extractor_cls = metadata_extractors.SetupPyMetadataExtractor

            base_python_version = (
                self.base_python_version or self.template_base_py_ver)

            self._metadata_extractor = extractor_cls(
                self.local_file,
                self.name,
                self.name_convertor,
                self.version,
                self.rpm_name,
                self.venv,
                base_python_version)

        return self._metadata_extractor
1361358
def metadata_index_json(self):
        """"""
        try:
            return op.join(self.metadata_dir, 'INDEX.json')
        except FileNotFoundError:
            return op.join(self.metadata_dir, 'INDEX_JSON')
952922
def get_file_meta(filepath):
    
    meta = {}
    meta['filepath'] = os.path.abspath(filepath)
    meta['creation_datetime'] = get_creation_datetime(filepath)
    meta['last_access_datetime'] = get_access_datetime(filepath)
    meta['modification_datetime'] = get_modification_datetime(filepath)
    try:
        import magic
        f_mime = magic.Magic(mime=True, uncompress=True)
        f_other = magic.Magic(mime=False, uncompress=True)
        meta['mime'] = f_mime.from_file(meta['filepath'])
        meta['magic-type'] = f_other.from_file(meta['filepath'])
    except ImportError:
        pass
    return meta
720542
def _get_metadata(self, file_id, metadata_fields=''):
        
        '''  '''
        
        title = '%s._get_metadata' % self.__class__.__name__
        
    # construct fields arg
        if not metadata_fields:
            metadata_fields = ','.join(self.object_file.keys())
        else:
            field_list = metadata_fields.split(',')
            for field in field_list:
                if not field in self.object_file.keys():
                    raise ValueError('%s(metadata_fields="%s") is not a valid drive file field' % (title, field))
    
    # send request
        try:
            metadata_details = self.drive.get(fileId=file_id, fields=metadata_fields).execute()
        except:
            raise DriveConnectionError(title)
        
        return metadata_details
703812
def _save_metadata(self):
        
        with open(self.paths.metadata(), 'w') as metadata_fd:
            utils.json_dump(self.metadata, metadata_fd)
538063
def md_options_to_metadata(options):
    """"""
    metadata = parse_md_code_options(options)

    if metadata:
        language = metadata[0][0]
        for lang in _JUPYTER_LANGUAGES + ['julia', 'scheme', 'c++']:
            if language.lower() == lang.lower():
                return lang, dict(metadata[1:])

    return None, dict(metadata)
196181
def dumps(self, format="local"):
        
        if format == "local":
            res = EntitiesDescriptor()
            for _md in self.metadata.values():
                try:
                    res.entity_descriptor.extend(
                        _md.entities_descr.entity_descriptor)
                except AttributeError:
                    res.entity_descriptor.append(_md.entity_descr)

            return "%s" % res
        elif format == "md":
            return json.dumps(self.items(), indent=2)