示例#1
0
    def evaluate_pep386(self):
        if not hasattr(self, "_evaluate_pep386"):
            normalized = verlib.suggest_normalized_version(self.version)

            evaluator = {
                "title": _("PEP386 Compatibility"),
                "message": jinja2.Markup(_("PEP386 defines a specific allowed syntax for Python package versions."
                                           "<br /><br />"
                                           "Previously it was impossible to accurately determine across any Python package what "
                                           "order the versions should go in, but with PEP386 we can now intelligently sort by version..."
                                           "<br /><br />"
                                           "But only if the version numbers are compatible!"))
            }

            if self.version == normalized:
                self._evaluate_pep386 = {
                    "level": "success",
                    "message": jinja2.Markup(_('Compatible with <a href="http://www.python.org/dev/peps/pep-0386/">PEP386</a>.')),
                    "evaluator": evaluator,
                }
            elif normalized is not None:
                self._evaluate_pep386 = {
                    "level": None,
                    "message": jinja2.Markup(_('Almost Compatible with <a href="http://www.python.org/dev/peps/pep-0386/">PEP386</a>.')),
                    "evaluator": evaluator,
                }
            else:
                self._evaluate_pep386 = {
                    "level": "error",
                    "message": jinja2.Markup(_('Incompatible with <a href="http://www.python.org/dev/peps/pep-0386/">PEP386</a>.')),
                    "evaluator": evaluator,
                }
        return self._evaluate_pep386
示例#2
0
def version_ordering(sender, **kwargs):
    instance = kwargs.get("instance")
    if instance is not None:
        releases = Release.objects.filter(package__pk=instance.package.pk)

        versions = []
        dated = []

        for release in releases:
            normalized = verlib.suggest_normalized_version(release.version)
            if normalized is not None:
                versions.append(release)
            else:
                dated.append(release)

        versions.sort(key=lambda x: verlib.NormalizedVersion(verlib.suggest_normalized_version(x.version)))
        dated.sort(key=lambda x: x.created)

        for i, release in enumerate(dated + versions):
            if release.order != i:
                Release.objects.filter(pk=release.pk).update(order=i)
示例#3
0
def version_ordering(sender, **kwargs):
    instance = kwargs.get("instance")
    if instance is not None:
        releases = Release.objects.filter(package__pk=instance.package.pk)

        versions = []
        dated = []

        for release in releases:
            normalized = verlib.suggest_normalized_version(release.version)
            if normalized is not None:
                versions.append(release)
            else:
                dated.append(release)

        versions.sort(key=lambda x: verlib.NormalizedVersion(verlib.suggest_normalized_version(x.version)))
        dated.sort(key=lambda x: x.created)

        for i, release in enumerate(dated + versions):
            if release.order != i:
                Release.objects.filter(pk=release.pk).update(order=i)