aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2017-07-11 09:16:28 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-21 08:44:20 +0100
commit3ef5b518febd047bf90a0955fa2b9fb78ba6dde5 (patch)
tree013219aa0b6f167a22159fa980bfe80646c4940d /scripts
parent33634b4c38d84e1c5d06056766933f1fe4f47e8d (diff)
downloadopenembedded-core-contrib-3ef5b518febd047bf90a0955fa2b9fb78ba6dde5.tar.gz
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@linux.intel.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/argparse_oe.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/lib/argparse_oe.py b/scripts/lib/argparse_oe.py
index bf6eb17197b..9bdfc1ceca2 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