How to use the pyp2rpm.name_convertor.NameVariants function in pyp2rpm

To help you get started, we’ve selected a few pyp2rpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fedora-python / pyp2rpm / tests / test_name_convertor.py View on Github external
def setup_method(self, method):
        self.nv = NameVariants('foo', '3')
        self.mv = NameVariants('foo', '')
github fedora-python / pyp2rpm / tests / test_name_convertor.py View on Github external
def setup_method(self, method):
        self.nv = NameVariants('foo', '3')
        self.mv = NameVariants('foo', '')
github fedora-python / pyp2rpm / pyp2rpm / name_convertor.py View on Github external
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
github fedora-python / pyp2rpm / pyp2rpm / name_convertor.py View on Github external
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
github fedora-python / pyp2rpm / pyp2rpm / name_convertor.py View on Github external
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
github fedora-python / pyp2rpm / pyp2rpm / name_convertor.py View on Github external
"""
        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)