Ejemplo n.º 1
0
def test_parse_name_and_version():
    path = join(dirname(__file__), "../data/example-1.0.tar.gz")
    metadata = read_metadata(path)

    eq_(metadata,
        dict(author="Location Labs",
             author_email="*****@*****.**",
             description=None,
             home_page="http://www.locationlabs.com",
             keywords=None,
             license=None,
             metadata_version="1.0",
             name="example",
             platforms=["UNKNOWN"],
             summary="Example distribution",
             supported_platforms=(),
             version="1.0"))
Ejemplo n.º 2
0
    def _get_metadata(self, path, filename):
        metadata = read_metadata(path)

        # make sure metadata validates
        if not self.validate_metadata(metadata):
            abort(codes.bad_request)

        # make sure nothing fishy is going on
        if metadata.get(Version.FILENAME) not in [None, filename]:
            abort(codes.bad_request)

        # make sure metadata is consistent with filename
        expected_name, expected_version = guess_name_and_version(filename)
        if metadata["name"] != expected_name or metadata["version"] != expected_version:
            self.logger.warn("Aborting upload of: {}; conflicting filename and metadata".format(filename))
            abort(codes.bad_request)

        # include local path in metadata
        metadata[Version.FILENAME] = filename
        # add upload timestamp
        metadata["_uploaded_timestamp"] = time()

        return metadata