def extract_data(self): """Extracts data from PyPI and archive. Returns: PackageData object containing data extracted from PyPI and archive. """ try: release_urls = self.client.release_urls(self.name, self.version) release_data = self.client.release_data(self.name, self.version) except: # some kind of error with client => return TODO: log the failure logger.debug('Client: {0} Name: {1} Version: {2}.'.format( self.client, self.name, self.version)) logger.warn('Some kind of error while communicating with client: {0}.'.format( self.client), exc_info=True) return PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version, 'FAILED TO EXTRACT FROM PYPI', 'FAILED TO EXTRACT FROM PYPI') url = '' md5_digest = None if len(release_urls): for release_url in release_urls: if release_url['url'].endswith("tar.gz"): url = release_url['url'] md5_digest = release_url['md5_digest'] if url == '': url = release_urls[0]['url'] md5_digest = release_urls[0]['md5_digest'] elif release_data: url = release_data['download_url'] data = PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version, md5_digest, url) for data_field in settings.PYPI_USABLE_DATA: setattr(data, data_field, release_data.get(data_field, '')) pypi_license = data.license with self.archive: data.set_from(self.data_from_archive) # for example nose has attribute `packages` but instead of name listing the # packages is using function to find them, that makes data.packages an empty set if data.has_packages and not data.packages: data.packages.add(data.name) # we usually get better license representation from trove classifiers data.license = utils.license_from_trove( release_data.get('classifiers', '')) or data.license or pypi_license return data
def test_merge_versions_fedora(self, self_bv, self_pv, data_pv, expected_bv, expected_pv): c = Convertor(package='pkg', base_python_version=self_bv, python_versions=self_pv, template='fedora.spec') data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1') data.python_versions = data_pv c.merge_versions(data) assert data.base_python_version == expected_bv assert data.python_versions == expected_pv
def test_versions_epel6(self, self_bv, self_pv, data_bv, data_pv, expected_bv, expected_pv): c = Convertor(package='pkg', base_python_version=self_bv, python_versions=self_pv, template='epel6.spec') data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1') data.base_python_version = data_bv data.python_versions = data_pv c.merge_versions(data) assert data.base_python_version == expected_bv assert data.python_versions == expected_pv
def extract_data(self): """Extracts data from archive. Returns: PackageData object containing the extracted data. """ data = PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) \ if self.rpm_name == None else self.rpm_name, self.version) with self.archive: data.set_from(self.data_from_archive) return data
def test_bad_versions(self, self_bv, self_pv): c = Convertor(package='pkg', base_python_version=self_bv, python_versions=self_pv, template='epel6.spec') data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1') with pytest.raises(SystemExit): c.merge_versions(data)
def extract_data(self): """Extracts data from archive. Returns: PackageData object containing the extracted data. """ data = PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version) with self.archive: data.set_from(self.data_from_archive) if virtualenv is not None: data.set_from(self.data_from_venv, update=True) if "scripts" in data.data: setattr(data, "scripts", utils.remove_major_minor_suffix(data.data['scripts'])) # for example nose has attribute `packages` but instead of name listing the pacakges # is using function to find them, that makes data.packages an empty set if data.has_packages and data.packages == "TODO:": data.packages = set([data.name]) return data
def extract_data(self): """Extracts data from archive. Returns: PackageData object containing the extracted data. """ data = PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version) with self.archive: data.set_from(self.data_from_archive) # for example nose has attribute `packages` but instead of name listing the packages # is using function to find them, that makes data.packages an empty set if(data.has_packages and not data.packages): data.packages.add(data.name) return data
def extract_data(self): """Extracts data from archive. Returns: PackageData object containing the extracted data. """ data = PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version) with self.archive: data.set_from(self.data_from_archive) if virtualenv is not None: data.set_from(self.data_from_venv, update=True) if "scripts" in data.data: setattr(data, "scripts", utils.remove_major_minor_suffix(data.data['scripts'])) # for example nose has attribute `packages` but instead of name listing the pacakges # is using function to find them, that makes data.packages an empty set if data.has_packages and data.packages in ("TODO:", set()): data.packages = set([data.name]) return data
def extract_data(self): """Extracts data from archive. Returns: PackageData object containing the extracted data. """ data = PackageData( local_file=self.local_file, name=self.name, pkg_name=self.rpm_name or self.name_convertor.rpm_name(self.name, pkg_name=True), version=self.version, srcname=self.srcname) with self.archive: data.set_from(self.data_from_archive) # for example nose has attribute `packages` but instead of name # listing the pacakges is using function to find them, that makes # data.packages an empty set if virtualenv is disabled if self.venv_extraction_disabled and getattr(data, "packages") == []: data.packages = [data.name] return data
def extract_data(self): """Extracts data from archive. Returns: PackageData object containing the extracted data. """ data = PackageData( self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version, ) with self.archive: data.set_from(self.data_from_archive) data.set_from(self.data_from_venv, update=True) data.data["build_deps"] += utils.runtime_to_build(data.data["runtime_deps"]) setattr(data, "build_deps", utils.unique_deps(data.data["build_deps"])) # for example nose has attribute `packages` but instead of name listing the pacakges # is using function to find them, that makes data.packages an empty set if data.has_packages and not data.packages: data.packages.add(data.name) return data
def extract_data(self): """Extracts data from archive. Returns: PackageData object containing the extracted data. """ data = PackageData( local_file=self.local_file, name=self.name, pkg_name=self.rpm_name or self.name_convertor.rpm_name(self.name), version=self.version, srcname=self.srcname) with self.archive: data.set_from(self.data_from_archive) if "scripts" in data.data: setattr(data, "scripts", utils.remove_major_minor_suffix(data.data['scripts'])) # for example nose has attribute `packages` but instead of name listing the pacakges # is using function to find them, that makes data.packages an empty set # if virtualenv is disabled if virtualenv is None and getattr(data, "packages") == set(): data.packages = set([data.name]) return data
def extract_data(self): """Extracts data from PyPI and archive. Returns: PackageData object containing data extracted from PyPI and archive. """ try: release_urls = self.client.release_urls(self.name, self.version) release_data = self.client.release_data(self.name, self.version) except: # some kind of error with client => return TODO: log the failure return PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) \ if self.rpm_name == None else self.rpm_name, self.version, 'FAILED TO EXTRACT FROM PYPI', 'FAILED TO EXTRACT FROM PYPI') url = '' md5_digest = None if len(release_urls) > 0: url_bak = release_urls[0]['url'] md5_bak = release_urls[0]['md5_digest'] for release_url in release_urls: if release_url['url'].endswith("tar.gz"): url = release_url['url'] md5_digest = release_url['md5_digest'] elif release_url['url'].endswith("zip"): url_bak = release_url['url'] md5_bak = release_url['md5_digest'] else: if url == '': url = url_bak md5_digest = md5_bak elif release_data: url = release_data['download_url'] data = PackageData(self.local_file, self.name, self.name_convertor.rpm_name(self.name) \ if self.rpm_name == None else self.rpm_name, self.version, md5_digest, url) for data_field in settings.PYPI_USABLE_DATA: setattr(data, data_field, release_data.get(data_field, '')) with self.archive: data.set_from(self.data_from_archive) # we usually get better license representation from trove classifiers data.license = utils.license_from_trove(release_data.get('classifiers', '')) or data.license return data
def test_summary_with_dot(self, s, expected): pd = PackageData('spam', 'spam', 'python-spam', 'spam') pd.summary = s assert pd.summary == expected
def test_set_none_value(self, name): pd = PackageData('spam', 'spam', 'python-spam', 'spam') setattr(pd, name, None) actual = getattr(pd, name) assert actual == 'TODO:'
def test_get_nonexistent_attribute(self): pd = PackageData('spam', 'spam', 'python-spam', 'spam') assert pd.eggs == 'TODO:'
def test_underscored_name(self, n, expected): pd = PackageData('spam', n, 'python-spam', 'spam') assert pd.underscored_name == expected
def test_update_attr(self, key, init, update_data, expected): pd = PackageData('spam', init, 'python-spam', 'spam') pd.set_from(update_data, update=True) assert pd.data[key] == expected
def extract_data(self): """Extracts data from PyPI and archive. Returns: PackageData object containing data extracted from PyPI and archive. """ try: release_urls = self.client.release_urls(self.name, self.version) release_data = self.client.release_data(self.name, self.version) except: # some kind of error with client => return TODO: log the failure logger.debug("Client: {0} Name: {1} Version: {2}.".format(self.client, self.name, self.version)) logger.warn("Some kind of error while communicating with client: {0}.".format(self.client), exc_info=True) return PackageData( self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version, "FAILED TO EXTRACT FROM PYPI", "FAILED TO EXTRACT FROM PYPI", ) url = "" md5_digest = None if len(release_urls): for release_url in release_urls: if release_url["url"].endswith("tar.gz"): url = release_url["url"] md5_digest = release_url["md5_digest"] if url == "": url = release_urls[0]["url"] md5_digest = release_urls[0]["md5_digest"] elif release_data: url = release_data["download_url"] data = PackageData( self.local_file, self.name, self.name_convertor.rpm_name(self.name) if self.rpm_name is None else self.rpm_name, self.version, md5_digest, url, ) for data_field in settings.PYPI_USABLE_DATA: setattr(data, data_field, release_data.get(data_field, "")) pypi_license = data.license with self.archive: data.set_from(self.data_from_archive) data.set_from(self.data_from_venv, update=True) setattr(data, "scripts", utils.remove_major_minor_suffix(data.data["scripts"])) data.data["build_deps"] += utils.runtime_to_build(data.data["runtime_deps"]) setattr(data, "build_deps", utils.unique_deps(data.data["build_deps"])) # Append all runtime deps to build deps and unique the result # for example nose has attribute `packages` but instead of name listing the # packages is using function to find them, that makes data.packages an empty set if data.has_packages and not data.packages: data.packages.add(data.name) # we usually get better license representation from trove classifiers data.license = utils.license_from_trove(release_data.get("classifiers", "")) or data.license or pypi_license return data