Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init_bad_data(self, name, version):
with pytest.raises(NoSuchPackageException):
PypiDownloader(self.client, name, version)
('eggs', NoSuchPackageException),
('/spam/beans/eggs/ham', NoSuchPackageException)
])
def test_getter_bad_data(self, sf, expected):
with pytest.raises(expected):
c = Convertor(package=sf)
c.getter
def convert(self):
"""Returns RPM SPECFILE.
Returns:
rendered RPM SPECFILE.
"""
# move file into position
try:
local_file = self.getter.get()
except (exceptions.NoSuchPackageException, OSError) as e:
logger.error(
"Failed and exiting:", exc_info=True)
logger.info("Pyp2rpm failed. See log for more info.")
sys.exit(e)
# save name and version from the file (rewrite if set previously)
self.name, self.version = self.getter.get_name_version()
self.local_file = local_file
data = self.metadata_extractor.extract_data(self.client)
logger.debug("Extracted metadata:")
logger.debug(pprint.pformat(data.data))
self.merge_versions(data)
jinja_env = jinja2.Environment(loader=jinja2.ChoiceLoader([
self.client = client
self.name = name
try:
self.versions = self.client.package_releases(self.name, True)
except xmlrpclib.ProtocolError as e:
sys.stderr.write("Failed to connect to server: {0} \n".format(e))
raise SystemExit(3)
# Use only stable versions, unless --pre was specified
if not prerelease:
self.versions = [candidate for candidate in self.versions
if not parse_version(candidate).is_prerelease]
# If versions is empty list then there is no such package on PyPI
if not self.versions:
raise exceptions.NoSuchPackageException(
'Package "{0}" could not be found on PyPI.'.format(name))
self.version = version or self.versions[0]
# if version is specified, will check if such version exists
if version and self.client.release_urls(name, version) == []:
raise exceptions.NoSuchPackageException(
'Package with name "{0}" and version "{1}" could not be '
'found on PyPI.'.format(name, version))
self.save_dir_init(save_dir)
# Use only stable versions, unless --pre was specified
if not prerelease:
self.versions = [candidate for candidate in self.versions
if not parse_version(candidate).is_prerelease]
# If versions is empty list then there is no such package on PyPI
if not self.versions:
raise exceptions.NoSuchPackageException(
'Package "{0}" could not be found on PyPI.'.format(name))
self.version = version or self.versions[0]
# if version is specified, will check if such version exists
if version and self.client.release_urls(name, version) == []:
raise exceptions.NoSuchPackageException(
'Package with name "{0}" and version "{1}" could not be '
'found on PyPI.'.format(name, version))
self.save_dir_init(save_dir)