[OE-core] [wic][PATCH 5/6] wic: override ArgumentParser.error
Ed Bartosh
ed.bartosh at linux.intel.com
Mon Jan 18 12:22:45 UTC 2016
Overriden error method to throw exception instead of
printing usage error message. Exception is caught by
KickStart code to add .ks file name and line number.
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
scripts/lib/wic/kickstart.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/scripts/lib/wic/kickstart.py b/scripts/lib/wic/kickstart.py
index 5d3a572..7dbe052 100644
--- a/scripts/lib/wic/kickstart.py
+++ b/scripts/lib/wic/kickstart.py
@@ -34,6 +34,14 @@ from wic.partition import Partition
class KickStartError(Exception):
pass
+class KickStartParser(ArgumentParser):
+ """
+ This class overwrites error method to throw exception
+ instead of producing usage message(default argparse behavior).
+ """
+ def error(self, message):
+ raise ArgumentError(None, message)
+
def sizetype(arg):
"""
Custom type for ArgumentParser
@@ -77,7 +85,7 @@ class KickStart(object):
self.bootloader = None
self.lineno = 0
- parser = ArgumentParser()
+ parser = KickStartParser()
subparsers = parser.add_subparsers()
part = subparsers.add_parser('part')
--
2.1.4
More information about the Openembedded-core
mailing list