[Reproducible-commits] [misc] 01/02: filter-packages: add from notes.git

Chris Lamb lamby at moszumanska.debian.org
Mon Feb 9 17:45:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository misc.

commit 945abb10c9ed815e489d26f9d7f4c5a3620a36f8
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Feb 9 17:42:49 2015 +0000

    filter-packages: add from notes.git
---
 filter-packages | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/filter-packages b/filter-packages
new file mode 100755
index 0000000..20beee0
--- /dev/null
+++ b/filter-packages
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# filter-packages: easily find and filter packages.yml
+#
+# Copyright © 2015 Chris Lamb <lamby at debian.org>
+# Licensed under WTFPL — http://www.wtfpl.net/txt/copying/
+
+import sys
+import yaml
+import optparse
+
+from os.path import join, dirname, abspath
+
+def main():
+    parser = optparse.OptionParser(usage='%prog [options] [packages.yml]')
+    parser.add_option('--issues', dest='issues', default=None,
+        help="only print packages with comma-separated issues ISSUES")
+    parser.add_option('--has-bugs', dest='bugs', action='store_true',
+        help="only print packages with bug(s) listed")
+    parser.add_option('--no-bugs', dest='bugs', action='store_false',
+        help="only print packages without bug(s) listed")
+    parser.add_option('--has-comments', dest='comments', action='store_true',
+        help="only print packages with comments")
+    parser.add_option('--no-comments', dest='comments', action='store_false',
+        help="only print packages without comments")
+
+    options, args = parser.parse_args()
+
+    if len(args) > 1:
+        parser.error("command can only take one argument")
+
+    if options.issues is not None:
+        options.issues = set(options.issues.split(','))
+
+    filename = args[0] if len(args) == 1 else \
+        join(dirname(dirname(abspath(__file__))), 'packages.yml')
+
+    with open(filename) as f:
+        packages = yaml.safe_load(f)
+
+    for x, y in sorted(packages.iteritems()):
+        if not options.issues <= set(y.get('issues', ())):
+            continue
+
+        if options.bugs is not None and options.bugs ^ ('bugs' in y):
+            continue
+
+        if options.comments is not None and options.comments ^ ('comments' in y):
+            continue
+
+        print x
+
+    return 0
+
+if __name__ == '__main__':
+    sys.exit(main())

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/misc.git



More information about the Reproducible-commits mailing list