Пример #1
0
 def __init__(self, name, version, metadata):
     self.__name__ = name
     self.release_files = OOBTree()
     self.version = version
     self.original_metadata = metadata
     schema = Metadata()
     self.metadata = schema.serialize(metadata)
     self.metadata = schema.deserialize(self.metadata)
Пример #2
0
 def __init__(self, name, version, metadata, deserialize_metadata=True):
     self.__name__ = name
     self.release_files = OOBTree()
     self.version = version
     self.original_metadata = metadata
     if deserialize_metadata:
         schema = Metadata()
         self.metadata = schema.serialize(metadata)
         self.metadata = schema.deserialize(self.metadata)
Пример #3
0
def evolve(context):
    root = context['repository']
    schema = Metadata(typ=NullableMapping(), default=None)

    for package in root:
        print(package.name)
        for release in package:
            original_metadata = release.original_metadata
            serialized_metadata = schema.serialize(original_metadata)
            release.metadata = schema.deserialize(serialized_metadata)
    context.evolved = 3
Пример #4
0
def evolve(context):
    root = context['repository']
    schema = Metadata()

    for package_name in root:
        package = root[package_name]
        for release_name in package.releases:
            release = package[release_name]
            original_metadata = release.original_metadata
            serialized_metadata = schema.serialize(original_metadata)
            release.metadata = schema.deserialize(serialized_metadata)
    context.evolved = 2
Пример #5
0
    def test_deserialize_from_setuptools(self):
        # Test response
        with open(get_resource('papaye_setuptools.json'), 'r') as json_file:
            cstruct = json.loads(json_file.read())
        from papaye.schemas import Metadata
        schema = Metadata()
        expected_keys = sorted([
            'version',
            'author',
            'author_email',
            'home_page',
            'keywords',
            'license',
            'summary',
            'maintainer',
            'maintainer_email',
            'description',
            'platform',
            'classifiers',
            'name',
        ])
        expected_classifiers = [
            "Programming Language :: Python",
            "Framework :: Pyramid",
            "Topic :: Internet :: WWW/HTTP",
            "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
        ]

        result = schema.deserialize(cstruct)

        self.assertIsNotNone(result)
        self.assertIsInstance(result, dict)
        self.assertEqual(expected_keys, sorted([key for key in result.keys()]))
        self.assertEqual(result['version'], '0.1.3-dev')
        self.assertEqual(result['author'], 'Romain Commandé')
        self.assertEqual(result['author_email'], '*****@*****.**')
        self.assertEqual(result['home_page'], 'https://github.com/rcommande/papaye')
        self.assertEqual(result['keywords'], ['web',  'wsgi', 'bfg', 'pylons', 'pyramid'])
        self.assertEqual(result['license'], 'UNKNOWN')
        self.assertEqual(result['summary'], cstruct['summary'])
        self.assertEqual(result['maintainer'], None)
        self.assertEqual(result['maintainer_email'], None)
        self.assertEqual(
            result['description'],
            {
                'html': True,
                'content': publish_parts(cstruct['description'], writer_name='html')['fragment'],
            }
        )
        self.assertEqual(result['platform'], 'UNKNOWN')
        self.assertEqual(result['classifiers'], expected_classifiers)
        self.assertEqual(result['name'], 'papaye')
Пример #6
0
 def __init__(self, version, metadata={},
              deserialize_metadata=True, package=None, **kwargs):
     self.release_files = MyOOBTree()
     self.version = version
     self.package = package
     self.original_metadata = metadata or {}
     if deserialize_metadata:
         schema = Metadata()
         self.metadata = schema.serialize(self.original_metadata)
         self.metadata = schema.deserialize(self.metadata)
     super().__init__(
         name=version, metadata=metadata,
         deserialize_metadata=True,
         package=package,
         **kwargs,
     )
Пример #7
0
    def test_deserialize_from_pypi(self):
        # Test response
        with open(get_resource('pyramid.json'), 'r') as json_file:
            cstruct = json.loads(json_file.read())['info']
        from papaye.schemas import Metadata
        schema = Metadata()
        expected_keys = sorted([
            'version',
            'author',
            'author_email',
            'home_page',
            'keywords',
            'license',
            'summary',
            'maintainer',
            'maintainer_email',
            'description',
            'platform',
            'classifiers',
            'name',
        ])

        result = schema.deserialize(cstruct)

        self.assertIsNotNone(result)
        self.assertIsInstance(result, dict)
        self.assertEqual(expected_keys, sorted([key for key in result.keys()]))
        self.assertEqual(result['version'], '1.5')
        self.assertEqual(result['author'], 'Chris McDonough, Agendaless Consulting')
        self.assertEqual(result['author_email'], '*****@*****.**')
        self.assertEqual(result['home_page'], 'http://pylonsproject.org')
        self.assertEqual(result['keywords'], ['web',  'wsgi',  'pylons', 'pyramid'])
        self.assertEqual(result['license'], 'BSD-derived (http://www.repoze.org/LICENSE.txt)')
        self.assertEqual(result['summary'], cstruct['summary'])
        self.assertEqual(result['maintainer'], None)
        self.assertEqual(result['maintainer_email'], None)
        self.assertEqual(
            result['description'],
            {
                'html': True,
                'content': publish_parts(cstruct['description'], writer_name='html')['fragment'],
            }
        )
        self.assertEqual(result['platform'], 'UNKNOWN')
        self.assertEqual(result['classifiers'], cstruct['classifiers'])
        self.assertEqual(result['name'], 'pyramid')
Пример #8
0
def evolve(context):
    root = context['repository']
    schema = Metadata()

    for package_name in root:
        package = root[package_name]
        for release_name in package.releases:
            release = package[release_name]
            metadata = dict(((key, value) for key, value in release.metadata.items() if value is not None))
            release.original_metadata = dict(release.metadata)
            deserialized_metadata = schema.deserialize(metadata)
            release.metadata = deserialized_metadata

            for release_filename in release.release_files:
                release_file = release[release_filename]
                release_file.size = os.path.getsize(release_file.content.open().name)
    context.evolved = 1
Пример #9
0
def evolve(context):
    root = context['repository']
    schema = Metadata()

    for package_name in root:
        package = root[package_name]
        for release_name in package.releases:
            release = package[release_name]
            metadata = dict(((key, value)
                             for key, value in release.metadata.items()
                             if value is not None))
            release.original_metadata = dict(release.metadata)
            deserialized_metadata = schema.deserialize(metadata)
            release.metadata = deserialized_metadata

            for release_filename in release.release_files:
                release_file = release[release_filename]
                release_file.size = os.path.getsize(
                    release_file.content.open().name)
    context.evolved = 1
Пример #10
0
    def test_deserialize_with_empty_metadata(self):
        from papaye.schemas import Metadata
        schema = Metadata()
        expected_keys = sorted([
            'version',
            'author',
            'author_email',
            'home_page',
            'keywords',
            'license',
            'summary',
            'maintainer',
            'maintainer_email',
            'description',
            'platform',
            'classifiers',
            'name',
        ])

        result = schema.deserialize({})

        self.assertIsNotNone(result)
        self.assertIsInstance(result, dict)
        self.assertEqual(expected_keys, sorted([key for key in result.keys()]))
        self.assertEqual(result['version'], None)
        self.assertEqual(result['author'], None)
        self.assertEqual(result['author_email'], None)
        self.assertEqual(result['home_page'], None)
        self.assertEqual(result['keywords'], None)
        self.assertEqual(result['license'], None)
        self.assertEqual(result['summary'], None)
        self.assertEqual(result['maintainer'], None)
        self.assertEqual(result['maintainer_email'], None)
        self.assertEqual(result['description'], None)
        self.assertEqual(result['platform'], None)
        self.assertEqual(result['classifiers'], None)
        self.assertEqual(result['name'], None)