[oe-commits] [openembedded-core] 01/02: argparse_oe: Add int_positive type
git at git.openembedded.org
git at git.openembedded.org
Thu Jul 20 22:14:24 UTC 2017
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit c9a54052308b63100978564012a4650e6575b427
Author: Aníbal Limón <anibal.limon at linux.intel.com>
AuthorDate: Tue Jul 11 09:16:28 2017 -0700
argparse_oe: Add int_positive type
Sometimes only expect positive values from cmdline so it's better
to filter at parsing cmdline step instead of validate later.
Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
scripts/lib/argparse_oe.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/scripts/lib/argparse_oe.py b/scripts/lib/argparse_oe.py
index bf6eb17..9bdfc1c 100644
--- a/scripts/lib/argparse_oe.py
+++ b/scripts/lib/argparse_oe.py
@@ -167,3 +167,10 @@ class OeHelpFormatter(argparse.HelpFormatter):
return '\n'.join(lines)
else:
return super(OeHelpFormatter, self)._format_action(action)
+
+def int_positive(value):
+ ivalue = int(value)
+ if ivalue <= 0:
+ raise argparse.ArgumentTypeError(
+ "%s is not a positive int value" % value)
+ return ivalue
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list