From 8bfae017bda18f0c9b38e9ae36fca031e1844b17 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Mon, 22 Oct 2012 19:51:43 +0300 Subject: [PATCH] version-info.py: ability to use positional arguments as extra dictionary keys --- make/scripts/version-info.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 6fe6b7d9e..63c2531a8 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -324,6 +324,12 @@ variable substitution and writes the result into output file. Output file will be overwritten only if its content differs from expected. Otherwise it will not be touched, so make utility will not remake dependent targets. + +Optional positional arguments may be used to add more dictionary +strings for replacement. Each argument has the form: + VARIABLE=replacement +and each ${VARIABLE} reference will be replaced with replacement +string given. """ # Parse command line. @@ -359,8 +365,6 @@ dependent targets. parser.add_option('--uavodir', default = "", help='uav object definition directory'); (args, positional_args) = parser.parse_args() - if len(positional_args) != 0: - parser.error("incorrect number of arguments, try --help for help") # Process arguments. No advanced error handling is here. # Any error will raise an exception and terminate process @@ -387,6 +391,12 @@ dependent targets. UAVOSHA1 = GetHashofDirs(args.uavodir,verbose=0,raw=0), ) + # Process positional arguments in the form of: + # VAR1=str1 VAR2="string 2" + for var in positional_args: + (key, value) = var.split('=', 1) + dictionary[key] = value + if args.info: r.info()