[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [emerge/kde-4.8] bin: use argparse for repackage.py
From: Patrick Spendrin <ps_ml () gmx ! de>
Date: 2012-01-31 23:05:41
Message-ID: 20120131230541.F25C3A60C9 () git ! kde ! org
[Download RAW message or body]
Git commit 3b915dd373ec382faf60011079ad142e988437c3 by Patrick Spendrin.
Committed on 01/02/2012 at 00:05.
Pushed by sengels into branch 'kde-4.8'.
use argparse for repackage.py
M +20 -9 bin/repackage.py
http://commits.kde.org/emerge/3b915dd373ec382faf60011079ad142e988437c3
diff --git a/bin/repackage.py b/bin/repackage.py
index e53c94f..7dff7df 100644
--- a/bin/repackage.py
+++ b/bin/repackage.py
@@ -1,25 +1,36 @@
import sys
import os
+import argparse
-def usage():
- print()
- print("can be used to repackage a packagelist")
- print("Syntax:")
- print("\t", sys.argv[0], "packagelist.txt")
+usage = "%(prog)s -f list.txt\n" \
+ " or: %(prog)s --file=list.txt \n"
+parser = argparse.ArgumentParser(prog=sys.argv[0], usage=usage)
+
+parser.add_argument("-f", "--file", dest = "filename", metavar = "list.txt",
+ help="the filename for a packagelist")
+parser.add_argument("-t", "--type", action = "store", default = OUTPUT_DOT,
+ help="Change the output format type possible values: xml kwi, dot")
+
+args, rest = parser.parse_known_args()
if len(sys.argv) == 1:
- usage()
+ parser.print_help()
exit(1)
-if not os.path.exists(sys.argv[1]):
- print("error: couldn't find packagelist file", sys.argv[1])
- usage()
+if not hasattr(args, "filename") or args.filename != None or not os.path.exists(args.filename):
+ print("error: couldn't find packagelist or can't read it")
+ parser.print_help()
exit(1)
+filename = args.filename
+
cmdtemplate = "emerge --package%s %s/%s"
targettemplate = " --target=%s"
patchleveltemplate = " --patchlevel=%s"
+
+
+
with open(sys.argv[1], 'r') as f:
for line in f:
if line.startswith('#'):
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic