root/releases/pkgcore-checks/0.3.5/pkgcore_checks/imlate.py @ ferringb%2540gmail.com-20070207174621-yb3eqrqc6jtmdgse

Revision ferringb%2540gmail.com-20070207174621-yb3eqrqc6jtmdgse, 2.5 KB (checked in by Brian Harring <ferringb@…>, 2 years ago)

kill off to_str, no longer used; use short_desc and long_desc properties instead

Line 
1# Copyright: 2006 Brian Harring <ferringb@gmail.com>
2# License: GPL2
3
4from pkgcore.restrictions import packages, values
5from pkgcore_checks import base, addons
6
7
8class LaggingStableInfo(base.Result):
9
10    """Arch that is behind another from a stabling standpoint"""
11   
12    __slots__ = ("category", "package", "version", "keywords",
13        "stable")
14    threshold = base.versioned_feed
15   
16    def __init__(self, pkg, keywords):
17        base.Result.__init__(self)
18        self._store_cpv(pkg)
19        self.keywords = keywords
20        self.stable = tuple(str(x) for x in pkg.keywords
21            if not x[0] in ("~", "-"))
22   
23    @property
24    def short_desc(self):
25        return "stabled arches [ %s ], potentials [ %s ]" % \
26            (', '.join(self.stable), ', '.join(self.keywords))
27
28
29class ImlateReport(base.Template):
30
31    """
32    scan for ebuilds that can be stabled based upon stabling status for
33    other arches
34    """
35
36    feed_type = base.package_feed
37    required_addons = (addons.ArchesAddon,)
38    known_results = (LaggingStableInfo,)
39
40    @staticmethod
41    def mangle_option_parser(parser):
42        parser.add_option(
43            "--source-arches", action='callback', dest='reference_arches',
44            default=addons.ArchesAddon.default_arches,
45            type='string', callback=addons.ArchesAddon._record_arches,
46            help="comma seperated list of what arches to compare against for "
47            "imlate, defaults to %s" % (
48                ",".join(addons.ArchesAddon.default_arches),))
49
50    def __init__(self, options, arches):
51        base.Template.__init__(self, options)
52        arches = frozenset(x.strip().lstrip("~") for x in options.arches)
53        self.target_arches = frozenset("~%s" % x.strip().lstrip("~")
54            for x in arches)
55        self.source_arches = frozenset(x.lstrip("~")
56            for x in options.reference_arches)
57        self.source_filter = packages.PackageRestriction("keywords",
58            values.ContainmentMatch(*self.source_arches))
59
60    def feed(self, pkgset, reporter):
61        fmatch = self.source_filter.match
62        remaining = set(self.target_arches)
63        for pkg in reversed(pkgset):
64            if not fmatch(pkg):
65                continue
66            unstable_keys = remaining.intersection(pkg.keywords)
67            if unstable_keys:
68                reporter.add_report(LaggingStableInfo(pkg,
69                    sorted(unstable_keys)))
70                remaining.difference_update(unstable_keys)
71                if not remaining:
72                    break
Note: See TracBrowser for help on using the browser.