Merge from genscripts r457: douglasjanderson
authorfuzzyray <fuzzyray@gentoo.org>
Wed, 22 Sep 2010 21:59:35 +0000 (21:59 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Wed, 22 Sep 2010 21:59:35 +0000 (21:59 -0000)
Add h(a)s to gentoolkit.test.equery.test_init.test_expand_module_name so that
the test passes.

Merge from genscripts r453: douglasjanderson
This bring all equery modules except the new has module on board with
bug #114086; adding non-zero exit status when a script finds no results

Merge from genscripts r441: brian.dolbec
some minor (non fatal) indent fixes.

svn path=/trunk/gentoolkit/; revision=812

pym/gentoolkit/equery/belongs.py
pym/gentoolkit/equery/changes.py
pym/gentoolkit/equery/depends.py
pym/gentoolkit/equery/hasuse.py
pym/gentoolkit/test/equery/test_init.py

index 8e8abb3ade15e6f3779ee79ad90fd23e2f46b22b..7c20658b34eb8f991cde8a92145e80d4f43f7e6c 100644 (file)
@@ -154,6 +154,7 @@ def main(input_args):
                printer_fn=printer_fn
        )
 
-       find_owner(queries)
+       if not find_owner(queries):
+               sys.exit(1)
 
 # vim: set ts=4 sw=4 tw=79:
index b290f0a592884be71d61c44483adce32b6477006..1e9be32507712c9ac59e3290df1f9f406d16988c 100644 (file)
@@ -141,11 +141,16 @@ def main(input_args):
                sys.exit(2)
 
        first_run = True
+       got_match = False
        for query in (Query(x) for x in queries):
                if not first_run:
                        print()
 
                match = query.find_best()
+               if match is None:
+                       continue
+
+               got_match = True
                changelog_path = os.path.join(match.package_path(), 'ChangeLog')
                changelog = ChangeLog(changelog_path)
 
@@ -177,5 +182,8 @@ def main(input_args):
                                print_entries(changelog.entries_matching_atom(atom)[:end])
 
                first_run = False
+       
+       if not got_match:
+               sys.exit(1)
 
 # vim: set ts=4 sw=4 tw=79:
index 2890365ed9471a8060dc01fe70d947243fae4258..cab23d1c4499a29f3d6608f88b98005475ee16f3 100644 (file)
@@ -171,7 +171,9 @@ def main(input_args):
        #
 
        dep_print = DependPrinter(verbose=CONFIG['verbose'])
+
        first_run = True
+       got_match = False
        for query in queries:
                if not first_run:
                        print()
@@ -184,13 +186,17 @@ def main(input_args):
 
                if CONFIG['verbose']:
                        print(" * These packages depend on %s:" % pp.emph(pkg.cpv))
-               pkg.graph_reverse_depends(
+               if pkg.graph_reverse_depends(
                        pkgset=sorted(pkggetter(), key=CPV),
                        max_depth=QUERY_OPTS["max_depth"],
                        only_direct=QUERY_OPTS["only_direct"],
                        printer_fn=dep_print
-               )
+               ):
+                       got_match = True
 
                first_run = False
 
+       if not got_match:
+               sys.exit(1)
+
 # vim: set ts=4 sw=4 tw=79:
index 03b989eff28685a8cec6216c40d6ef8275b585b4..80c98fe907b3ce8c31abcbae88a897d4a724cbbd 100644 (file)
@@ -60,7 +60,7 @@ def print_help(with_description=True):
                (" -o, --overlay-tree", "include overlays in search path"),
                (" -p, --portage-tree", "include entire portage tree in search path"),
                (" -F, --format=TMPL", "specify a custom output format"),
-        ("              TMPL",
+               ("              TMPL",
                        "a format template using (see man page):")
        )))
        print(" " * 24, ', '.join(pp.emph(x) for x in FORMAT_TMPL_VARS))                        
@@ -73,19 +73,19 @@ def display_useflags(query, pkg):
                useflags = [x.lstrip("+-") for x in pkg.environment("IUSE").split()]
        except errors.GentoolkitFatalError:
                # aux_get KeyError or other unexpected result
-               return
+               return False
 
        if query not in useflags:
-               return
+               return False
 
        if CONFIG['verbose']:
-                pkgstr = PackageFormatter(
+               pkgstr = PackageFormatter(
                        pkg,
                        do_format=True,
                        custom_format=QUERY_OPTS["package_format"]
                )
        else:
-                pkgstr = PackageFormatter(
+               pkgstr = PackageFormatter(
                        pkg,
                        do_format=False,
                        custom_format=QUERY_OPTS["package_format"]
@@ -95,17 +95,19 @@ def display_useflags(query, pkg):
                not QUERY_OPTS["in_porttree"] and
                not QUERY_OPTS["in_overlay"]):
                if not 'I' in  pkgstr.location:
-                       return
+                       return False
        if (QUERY_OPTS["in_porttree"] and
                not QUERY_OPTS["in_overlay"]):
                if not 'P' in  pkgstr.location:
-                       return
+                       return False
        if (QUERY_OPTS["in_overlay"] and
                not QUERY_OPTS["in_porttree"]):
                if not 'O' in  pkgstr.location:
-                       return
+                       return False
        pp.uprint(pkgstr)
 
+       return True
+
 
 
 def parse_module_options(module_opts):
@@ -158,6 +160,7 @@ def main(input_args):
        #
 
        first_run = True
+       got_match = False
        for query in queries:
                if not first_run:
                        print()
@@ -166,7 +169,12 @@ def main(input_args):
                        pp.uprint(" * Searching for USE flag %s ... " % pp.emph(query))
 
                for pkg in matches:
-                       display_useflags(query, pkg)
+                       if display_useflags(query, pkg):
+                               got_match = True
+
                first_run = False
 
+       if not got_match:
+               sys.exit(1)
+
 # vim: set ts=4 sw=4 tw=79:
index d59fdc26d2a46239f0637b12b2319cbbceb6dec0..31da63508ce5bc11b4cb012267c35e0426f573d5 100644 (file)
@@ -17,6 +17,7 @@ class TestEqueryInit(unittest.TestCase):
        def test_expand_module_name(self):
                # Test that module names are properly expanded
                name_map = {
+                       'a': 'has',
                        'b': 'belongs',
                        'c': 'changes',
                        'k': 'check',