Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_method(self, method):
self.nv = NameVariants('foo', '3')
self.mv = NameVariants('foo', '')
def setup_method(self, method):
self.nv = NameVariants('foo', '3')
self.mv = NameVariants('foo', '')
converted = super(DandifiedNameConvertor, self).rpm_name(
name, python_version)
python_query = self.query.filter(name__substr=[
'python', 'py', original_name, canonical_form(original_name)])
if converted in [pkg.name for pkg in python_query]:
logger.debug("Converted name exists")
return converted
logger.debug("Converted name not found, searches for correct form")
not_versioned_name = NameVariants(self.base_name(original_name), '')
versioned_name = NameVariants(self.base_name(original_name),
python_version)
if self.base_name(original_name).startswith("py"):
nonpy_name = NameVariants(self.base_name(
original_name)[2:], python_version)
for pkg in python_query:
versioned_name.find_match(pkg.name)
not_versioned_name.find_match(pkg.name)
if 'nonpy_name' in locals():
nonpy_name.find_match(pkg.name)
if 'nonpy_name' in locals():
versioned_name = versioned_name.merge(nonpy_name)
correct_form = versioned_name.merge(not_versioned_name).best_matching
logger.debug("Most likely correct form of the name {0}.".format(
correct_form))
return correct_form or converted
if pkg_name:
return super(DandifiedNameConvertor, self).rpm_name(
name, python_version)
original_name = name
converted = super(DandifiedNameConvertor, self).rpm_name(
name, python_version)
python_query = self.query.filter(name__substr=[
'python', 'py', original_name, canonical_form(original_name)])
if converted in [pkg.name for pkg in python_query]:
logger.debug("Converted name exists")
return converted
logger.debug("Converted name not found, searches for correct form")
not_versioned_name = NameVariants(self.base_name(original_name), '')
versioned_name = NameVariants(self.base_name(original_name),
python_version)
if self.base_name(original_name).startswith("py"):
nonpy_name = NameVariants(self.base_name(
original_name)[2:], python_version)
for pkg in python_query:
versioned_name.find_match(pkg.name)
not_versioned_name.find_match(pkg.name)
if 'nonpy_name' in locals():
nonpy_name.find_match(pkg.name)
if 'nonpy_name' in locals():
versioned_name = versioned_name.merge(nonpy_name)
correct_form = versioned_name.merge(not_versioned_name).best_matching
def merge(self, other):
"""Merges object with other NameVariants object, not set values
of self.variants are replace by values from other object.
"""
if not isinstance(other, NameVariants):
raise TypeError("NameVariants isinstance can be merge with"
"other isinstance of the same class")
for key in self.variants:
self.variants[key] = self.variants[key] or other.variants[key]
return self
"""
if pkg_name:
return super(DandifiedNameConvertor, self).rpm_name(
name, python_version)
original_name = name
converted = super(DandifiedNameConvertor, self).rpm_name(
name, python_version)
python_query = self.query.filter(name__substr=[
'python', 'py', original_name, canonical_form(original_name)])
if converted in [pkg.name for pkg in python_query]:
logger.debug("Converted name exists")
return converted
logger.debug("Converted name not found, searches for correct form")
not_versioned_name = NameVariants(self.base_name(original_name), '')
versioned_name = NameVariants(self.base_name(original_name),
python_version)
if self.base_name(original_name).startswith("py"):
nonpy_name = NameVariants(self.base_name(
original_name)[2:], python_version)
for pkg in python_query:
versioned_name.find_match(pkg.name)
not_versioned_name.find_match(pkg.name)
if 'nonpy_name' in locals():
nonpy_name.find_match(pkg.name)
if 'nonpy_name' in locals():
versioned_name = versioned_name.merge(nonpy_name)