Beispiel #1
0
def _get_meta(self):
    metacache = getattr(self, '_meta_cache', (False, False))
    if metacache[0] is not getattr(self, 'filename', None) or metacache[1] \
       is not getattr(self, 'tags', None):
        self._meta_cache = (getattr(self, 'filename', None),
           getattr(self, 'tags', None))
        if getattr(self, 'tags', None) is None:
            meta = NormMetaData()
        else:
            meta = NormMetaData.converted(self)
        path = getattr(self, 'filename', None)
        if isinstance(path, basestring):
            (meta['dir'], meta['name']) = os.path.split(path)
            meta['path'] = path
            meta['basename'] = os.path.splitext(meta['name'])[0]
        relpath = getattr(self, 'relpath', None)
        if isinstance(relpath, basestring):
            meta['relpath'] = relpath.decode(Config['fs_encoding'], Config['fs_encoding_err'] or 'replace')
        reldir = getattr(self, 'reldir', None)
        if isinstance(reldir, basestring):
            meta['reldir'] = reldir.decode(Config['fs_encoding'], Config['fs_encoding_err'] or 'replace')
        ext = getattr(self, 'ext', None)
        if ext is not None:
            meta['ext'] = ext
        type_ = getattr(self, 'type_', None)
        if type_ is not None:
            meta['type'] = type_
        self._meta = meta
    return getattr(self,'_meta')
Beispiel #2
0
def _set_meta(self, value):
    NormMetaData.converted(value).apply(self, True)