From 75647080813c1fa11720fe4d7b42658148f77ff3 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sat, 24 Oct 2009 00:20:14 +0200 Subject: Add --fixes-only option to gitosis.conf extractor --- diff-gitosis-conf-against-repositories-xml.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/diff-gitosis-conf-against-repositories-xml.py b/diff-gitosis-conf-against-repositories-xml.py index e5068b6..6666c41 100755 --- a/diff-gitosis-conf-against-repositories-xml.py +++ b/diff-gitosis-conf-against-repositories-xml.py @@ -4,15 +4,21 @@ # Licensed under GPL 2 or later import sys -import os -if len(sys.argv) not in (3, 4): - print "USAGE:\n python %s foo/gitosis.conf bar/repositories.xml [baz/extended.xml]" % \ - os.path.basename(sys.argv[0]) +from optparse import OptionParser +USAGE = 'Usage: %prog [--fixes-only] foo/gitosis.conf bar/repositories.xml [baz/extended.xml]' +parser = OptionParser(usage=USAGE) +parser.add_option('--fixes-only', + dest = 'fixes_only', + default = False, + action = 'store_true', + help = 'do not add entries that are missing completely') +(opts, args) = parser.parse_args() +if len(args) not in (3, 2): + parser.print_help() sys.exit(1) -gitosis_conf_location = sys.argv[1] -repositories_xml_location = sys.argv[2] -extended_xml_location = (len(sys.argv) == 4) and sys.argv[3] or None - +gitosis_conf_location = args[0] +repositories_xml_location = args[1] +extended_xml_location = (len(args) == 3) and args[2] or None import xml.etree.ElementTree as ET from ConfigParser import ConfigParser @@ -85,6 +91,8 @@ for section_name in gitosis_conf.sections(): is_new = repo_name not in overlays_gentoo_org_dict if is_new: + if opts.fixes_only: + continue repo = ET.Element('repo') repositories.append(repo) name = ET.Element('name') -- cgit v1.2.3-65-gdbad