]> xenbits.xensource.com Git - xtf.git/commitdiff
mkinfo: Assign names to command line parameters
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 26 Jul 2016 18:53:18 +0000 (19:53 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 Jul 2016 18:39:02 +0000 (19:39 +0100)
This is easier to read, and has a side effect of bailing with a hard error if
the wrong number of parameters are passed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
build/mkinfo.py

index 4b4dc2227546e797a02159caf5319944667ddbe5..e4b5fe22a393227f3ea2a8a6c68312b2ed9d3896 100644 (file)
@@ -3,13 +3,16 @@
 
 import sys, os, json
 
+# Usage: mkcfg.py $OUT $NAME $CATEGORY $ENVS
+_, out, name, cat, envs = sys.argv
+
 template = {
-    "name": sys.argv[2],
-    "category": sys.argv[3],
-    "environments": sys.argv[4].split(" "),
+    "name": name,
+    "category": cat,
+    "environments": envs.split(" "),
     }
 
-open(sys.argv[1], "w").write(
+open(out, "w").write(
     json.dumps(template, indent=4, separators=(',', ': '))
     + "\n"
     )