Esempio n. 1
0
    def _init_prefixes(cls):
        from library.python.resource import resfs_read, resfs_files

        for resource in resfs_files():
            if not resource.endswith('top_level.txt'):
                continue
            data = resfs_read(resource).decode('utf-8')
            for top_level in data.split('\n'):
                if top_level:
                    cls.prefixes[top_level] = resource[:-len('top_level.txt')]
Esempio n. 2
0
    def _init_prefixes(cls):
        from library.python.resource import resfs_read, resfs_files
        cls.prefixes.clear()

        METADATA_NAME = re.compile('^Name: (.*)$', re.MULTILINE)

        for resource in resfs_files():
            if not resource.endswith('METADATA'):
                continue
            data = resfs_read(resource).decode('utf-8')
            metadata_name = METADATA_NAME.search(data)
            if metadata_name:
                metadata_name = Prepared(metadata_name.group(1))
                cls.prefixes[metadata_name.normalized] = resource[:-len('METADATA')]
Esempio n. 3
0
def test_resfs_read():
    assert 'Metadata-Version' in rs.resfs_read(
        'contrib/python/py/.dist-info/METADATA').decode('utf-8')
Esempio n. 4
0
 def read_text(self, filename):
     from library.python.resource import resfs_read
     data = resfs_read('{}{}'.format(self.prefix, filename))
     if data:
         return data.decode('utf-8')