Beispiel #1
0
def downgrade_iter_sort(restrict, l, pkg_grabber=pkg_grabber):
    """Sort a list of packages from highest to lowest and prefer nonlivefs.

    :param l: list of packages
    :param pkg_grabber: function to use as an attrgetter
    :return: sorted list of packages
    """
    def f(x, y):
        c = cmp(x, y)
        if x.repo.livefs:
            if y.repo.livefs:
                return c
            return -1
        elif y.repo.livefs:
            return 1
        elif restrict.match(x):
            if restrict.match(y):
                return 1
            return -1
        elif restrict.match(y):
            return 1
        return c

    sort_cmp(l, f, key=pkg_grabber, reverse=True)
    return l
Beispiel #2
0
def lowest_iter_sort(l, pkg_grabber=pkg_grabber):
    def f(x, y):
        c = cmp(x, y)
        if c:
            return c
        elif x.repo.livefs:
            if y.repo.livefs:
                return 0
            return -1
        elif y.repo.livefs:
            return 1
        return 0
    sort_cmp(l, f, key=pkg_grabber)
    return l
Beispiel #3
0
def highest_iter_sort(l, pkg_grabber=pkg_grabber):
    def f(x, y):
        c = cmp(x, y)
        if c:
            return c
        elif x.repo.livefs:
            if y.repo.livefs:
                return 0
            return 1
        elif y.repo.livefs:
            return -1
        return 0
    sort_cmp(l, f, key=pkg_grabber, reverse=True)
    return l
Beispiel #4
0
def lowest_iter_sort(l, pkg_grabber=pkg_grabber):
    """Sort a list of packages from lowest to highest.

    :param l: list of packages
    :param pkg_grabber: function to use as an attrgetter
    :return: sorted list of packages
    """
    def f(x, y):
        c = cmp(x, y)
        if c:
            return c
        elif x.repo.livefs:
            if y.repo.livefs:
                return 0
            return -1
        elif y.repo.livefs:
            return 1
        return 0
    sort_cmp(l, f, key=pkg_grabber)
    return l
Beispiel #5
0
def lowest_iter_sort(l, pkg_grabber=pkg_grabber):
    """Sort a list of packages from lowest to highest.

    :param l: list of packages
    :param pkg_grabber: function to use as an attrgetter
    :return: sorted list of packages
    """
    def f(x, y):
        c = cmp(x, y)
        if c:
            return c
        elif x.repo.livefs:
            if y.repo.livefs:
                return 0
            return -1
        elif y.repo.livefs:
            return 1
        return 0
    sort_cmp(l, f, key=pkg_grabber)
    return l