summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-01-23 14:39:06 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-01-25 21:51:53 +0530
commitccbdf67e36e7819548d75de9b89b2fabe47f3001 (patch)
treeaaa4eed06ac5e112cf91c6ba87002be816ba4a1d
parent8a50a50a803860a853b1412899769678bed48f9e (diff)
downloadphosphor-led-manager-ccbdf67e36e7819548d75de9b89b2fabe47f3001.tar.gz
phosphor-led-manager-ccbdf67e36e7819548d75de9b89b2fabe47f3001.zip
Update parse_led.py to accept command line arguments
Existing parse_led.py had a hardcoded reference to the current directory and the file name 'led.yaml'. This patch introduces changes through which an arbitrary directory and filename can be passed. What would still remain the older way is the generation of led-gen.hpp into the current source directorty Change-Id: I352dadd6aa99ef80192dfca3071357917d4593b8 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rwxr-xr-xparse_led.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/parse_led.py b/parse_led.py
index c86764c..8ecfb94 100755
--- a/parse_led.py
+++ b/parse_led.py
@@ -1,10 +1,26 @@
#!/usr/bin/env python
import yaml
import os
+import argparse
if __name__ == '__main__':
script_dir = os.path.dirname(os.path.realpath(__file__))
- with open(os.path.join(script_dir, 'led.yaml'), 'r') as f:
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-f","--filename", default='led.yaml', help="Input File Name")
+ parser.add_argument("-d","--directory", default=script_dir, help="Input directory")
+ args = parser.parse_args()
+
+ # Default to the one that is in the current.
+ yaml_dir = script_dir;
+ yaml_file = os.path.join(yaml_dir, 'led.yaml')
+
+ if args.directory:
+ yaml_dir = args.directory
+
+ if args.filename:
+ yaml_file = os.path.join(yaml_dir, args.filename)
+
+ with open(yaml_file, 'r') as f:
ifile = yaml.safe_load(f)
with open(os.path.join(script_dir, 'led-gen.hpp'), 'w') as ofile:
OpenPOWER on IntegriCloud