How to use the pyroma.ratings.FieldTest function in pyroma

To help you get started, we’ve selected a few pyroma 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 regebro / pyroma / pyroma / ratings.py View on Github external
def message(self):
        if self._major_version_specified:
            return (
                "The classifiers should specify what minor versions of "
                "Python you support as well as what major version."
            )
        return "You should specify what Python versions you support."


class Keywords(FieldTest):
    weight = 20
    field = "keywords"


class Author(FieldTest):
    weight = 100
    field = "author"


class AuthorEmail(FieldTest):
    weight = 100
    field = "author_email"


class Url(BaseTest):
    weight = 20

    def test(self, data):
        return bool(data.get("url")) or bool(data.get("project_urls"))

    def message(self):
github regebro / pyroma / pyroma / ratings.py View on Github external
def test(self, data):
        return bool(data.get(self.field))

    def message(self):
        return ("Your package does not have %s data" % self.field) + (
            self.fatal and "!" or "."
        )


class Name(FieldTest):
    fatal = True
    field = "name"


class Version(FieldTest):
    fatal = True
    field = "version"


class VersionIsString(BaseTest):
    weight = 50

    def test(self, data):
        # Check that the version is a string
        version = data.get("version")
        return isinstance(version, stringtypes)

    def message(self):
        return "The version number should be a string."
github regebro / pyroma / pyroma / ratings.py View on Github external
fatal = False


class FieldTest(BaseTest):
    """Tests that a specific field is in the data and is not empty or False"""

    def test(self, data):
        return bool(data.get(self.field))

    def message(self):
        return ("Your package does not have %s data" % self.field) + (
            self.fatal and "!" or "."
        )


class Name(FieldTest):
    fatal = True
    field = "name"


class Version(FieldTest):
    fatal = True
    field = "version"


class VersionIsString(BaseTest):
    weight = 50

    def test(self, data):
        # Check that the version is a string
        version = data.get("version")
        return isinstance(version, stringtypes)
github regebro / pyroma / pyroma / ratings.py View on Github external
class LongDescription(BaseTest):
    weight = 50

    def test(self, data):
        long_description = data.get("long_description", "")
        if not isinstance(long_description, stringtypes):
            long_description = ""
        return len(long_description) > 100

    def message(self):
        return "The package's long_description is quite short."


class Classifiers(FieldTest):
    weight = 100
    field = "classifiers"


class ClassifierVerification(BaseTest):
    weight = 20

    def test(self, data):
        self._incorrect = []
        classifiers = data.get("classifiers", [])
        for classifier in classifiers:
            if classifier not in CLASSIFIERS:
                self._incorrect.append(classifier)
        if self._incorrect:
            return False
        return True
github regebro / pyroma / pyroma / ratings.py View on Github external
"Python you support as well as what major version."
            )
        return "You should specify what Python versions you support."


class Keywords(FieldTest):
    weight = 20
    field = "keywords"


class Author(FieldTest):
    weight = 100
    field = "author"


class AuthorEmail(FieldTest):
    weight = 100
    field = "author_email"


class Url(BaseTest):
    weight = 20

    def test(self, data):
        return bool(data.get("url")) or bool(data.get("project_urls"))

    def message(self):
        return (
            "Your package should have a 'url' field with a link to the "
            "project home page, or a 'project_urls' field, with a "
            "dictionary of links, or both."
        )
github regebro / pyroma / pyroma / ratings.py View on Github external
self.weight = 25
        else:
            # No Python version specified at all:
            self.weight = 100
        return False

    def message(self):
        if self._major_version_specified:
            return (
                "The classifiers should specify what minor versions of "
                "Python you support as well as what major version."
            )
        return "You should specify what Python versions you support."


class Keywords(FieldTest):
    weight = 20
    field = "keywords"


class Author(FieldTest):
    weight = 100
    field = "author"


class AuthorEmail(FieldTest):
    weight = 100
    field = "author_email"


class Url(BaseTest):
    weight = 20