aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-01-20 15:05:18 -0500
committerMike Frysinger <vapier@gentoo.org>2014-01-20 15:05:18 -0500
commita8d9d1e301afbdd794d3a95f0ef61e78ca39edcf (patch)
treecf86cc3eb126ac155884a0476e08a09ec7d59c7d
parentekeyword: fix keyword sorting between platforms (diff)
downloadgentoolkit-a8d9d1e301afbdd794d3a95f0ef61e78ca39edcf.tar.gz
gentoolkit-a8d9d1e301afbdd794d3a95f0ef61e78ca39edcf.tar.bz2
gentoolkit-a8d9d1e301afbdd794d3a95f0ef61e78ca39edcf.zip
ekeyword: make quiet/verbose flags a bit more flexible
This allows for multiple levels of verbose/quiet.
-rwxr-xr-xsrc/ekeyword/ekeyword.py16
-rwxr-xr-xsrc/ekeyword/ekeyword_unittest.py6
2 files changed, 11 insertions, 11 deletions
diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py
index 66cf48a..7a6c630 100755
--- a/src/ekeyword/ekeyword.py
+++ b/src/ekeyword/ekeyword.py
@@ -190,15 +190,15 @@ def process_keywords(keywords, ops, arch_status=None):
return new_keywords
-def process_content(ebuild, data, ops, arch_status=None, verbose=False,
- quiet=False, format='color-inline'):
+def process_content(ebuild, data, ops, arch_status=None, verbose=0,
+ quiet=0, format='color-inline'):
"""Process |ops| for |data|"""
# Set up the user display style based on verbose/quiet settings.
- if verbose:
+ if verbose > 1:
disp_name = ebuild
def logit(msg):
print('%s: %s' % (disp_name, msg))
- elif quiet:
+ elif quiet > 1:
def logit(msg):
pass
else:
@@ -225,7 +225,7 @@ def process_content(ebuild, data, ops, arch_status=None, verbose=False,
old_keywords, ops, arch_status=arch_status)
# Finally let's present the results to the user.
- if new_keywords != old_keywords:
+ if (new_keywords != old_keywords) or verbose:
# Only do the diff work if something actually changed.
updated = True
old_keywords = sort_keywords(old_keywords)
@@ -256,7 +256,7 @@ def process_content(ebuild, data, ops, arch_status=None, verbose=False,
return updated, content
-def process_ebuild(ebuild, ops, arch_status=None, verbose=False, quiet=False,
+def process_ebuild(ebuild, ops, arch_status=None, verbose=0, quiet=0,
dry_run=False, format='color-inline'):
"""Process |ops| for |ebuild|"""
with open(ebuild, 'rb') as f:
@@ -369,9 +369,9 @@ def get_parser():
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-n', '--dry-run', default=False, action='store_true',
help='Show what would be changed, but do not commit')
- parser.add_argument('-v', '--verbose', default=False, action='store_true',
+ parser.add_argument('-v', '--verbose', action='count',
help='Be verbose while processing things')
- parser.add_argument('-q', '--quiet', default=False, action='store_true',
+ parser.add_argument('-q', '--quiet', action='count',
help='Be quiet while processing things (only show errors)')
parser.add_argument('--format', default='auto',
choices=('auto', 'color-inline', 'inline', 'short-multi', 'long-multi'),
diff --git a/src/ekeyword/ekeyword_unittest.py b/src/ekeyword/ekeyword_unittest.py
index 5096c71..00c295f 100755
--- a/src/ekeyword/ekeyword_unittest.py
+++ b/src/ekeyword/ekeyword_unittest.py
@@ -245,7 +245,7 @@ class TestProcessContent(unittest.TestCase):
self.assertFalse(updated)
self.assertEqual(ret, [' KEYWORDS=\n'])
- def _testSmoke(self, format='color-inline', verbose=False, quiet=False):
+ def _testSmoke(self, format='color-inline', verbose=0, quiet=0):
ops = (
ekeyword.Op(None, 'arm', None),
ekeyword.Op('~', 'sparc', None),
@@ -256,11 +256,11 @@ class TestProcessContent(unittest.TestCase):
def testSmokeQuiet(self):
"""Smoke test for quiet mode"""
- self._testSmoke(quiet=True)
+ self._testSmoke(quiet=10)
def testSmokeVerbose(self):
"""Smoke test for verbose mode"""
- self._testSmoke(verbose=True)
+ self._testSmoke(verbose=10)
def testSmokeFormatColor(self):
"""Smoke test for color-inline format"""