[Reproducible-commits] [misc] 01/05: clean-notes: use argparse to allow some flags (currently -v/-q, -n --db)

Mattia Rizzolo mapreri-guest at moszumanska.debian.org
Wed Jan 7 00:11:55 UTC 2015


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

mapreri-guest pushed a commit to branch master
in repository misc.

commit 246e7b7d560520498414ccbc3f6b40d3022c0dd9
Author: Mattia Rizzolo <mattia at mapreri.org>
Date:   Tue Jan 6 22:35:11 2015 +0100

    clean-notes: use argparse to allow some flags (currently -v/-q, -n --db)
---
 clean-notes | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/clean-notes b/clean-notes
index de7f8d6..4cc3870 100755
--- a/clean-notes
+++ b/clean-notes
@@ -1,4 +1,5 @@
 #!/usr/bin/python3
+# -*- coding: utf-8 -*-
 
 # clean-notes: sort and clean the notes stored in notes.git
 # Copyright © 2015 Mattia Rizzolo <mattia at mapreri.org>
@@ -11,6 +12,7 @@ import sys
 import json
 import yaml
 import apt_pkg
+import argparse
 import requests
 
 reproducible_json = 'https://reproducible.debian.net/userContent/reproducible.json'
@@ -19,6 +21,14 @@ reproducible_json = 'https://reproducible.debian.net/userContent/reproducible.js
 notes_yaml = 'packages.yml'
 # {package_name: {things..} }
 
+parser = argparse.ArgumentParser(description = "housekeep the packages.yml file")
+group = parser.add_mutually_exclusive_group()
+group.add_argument("-v", "--verbose", action="store_true")
+group.add_argument("-q", "--quiet", action="store_true")
+parser.add_argument("-n", "--dry-run", action="store_true")
+parser.add_argument("-d", "--db", action="store_true", help="do the UDD query and fill the notes")
+args = parser.parse_args()
+
 def warning(*objs):
     print("WARNING: ", *objs, file=sys.stderr)
 
@@ -57,7 +67,8 @@ def find_old_notes(testedpkgs, notes):
             if item['package'] == pkg and \
                apt_pkg.version_compare(str(item['version']),
                                        str(notes[pkg]['version'])) > 0:
-                print("The package " + pkg + " has a new tested version")
+                if not args.quiet:
+                    print("The package " + pkg + " has a new tested version")
     return toremove
 
 def cleanup_notes(notes, toremove):
@@ -96,5 +107,13 @@ if __name__ == '__main__':
     notes = load_notes()
     toremove = find_old_notes(testedpkgs, notes)
     notes = cleanup_notes(notes, toremove)
-    write_out(notes)
+    if args.db:
+        conn = start_db_connection()
+        bugs = get_bugs()
+        bugs = parse_bugs(bugs)
+        notes = join_notes_bugs(notes, bugs)
+    if not args.dry_run:
+        write_out(notes)
+    else:
+        print("Don\'t write out a notes.yml file, as requested (dry-run).")
 

-- 
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