summaryrefslogtreecommitdiffstats
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:25 +0100
commit3aa299d51ba57aa80664e5e92654d5b9abcf443b (patch)
tree6c4a33008efe296bc64b0f4be0e98dec2886a3a8 /scripts
parentc8330a053be17e42954d1ede9e3fd42b9b8a530f (diff)
downloadpoky-3aa299d51ba57aa80664e5e92654d5b9abcf443b.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. (From OE-Core rev: 3ef5b518febd047bf90a0955fa2b9fb78ba6dde5) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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 bf6eb17197..9bdfc1ceca 100644
--- a/scripts/lib/argparse_oe.py
+++ b/scripts/lib/argparse_oe.py
@@ -167,3 +167,10 @@ class OeHelpFormatter(argparse.HelpFormatter):
167 return '\n'.join(lines) 167 return '\n'.join(lines)
168 else: 168 else:
169 return super(OeHelpFormatter, self)._format_action(action) 169 return super(OeHelpFormatter, self)._format_action(action)
170
171def int_positive(value):
172 ivalue = int(value)
173 if ivalue <= 0:
174 raise argparse.ArgumentTypeError(
175 "%s is not a positive int value" % value)
176 return ivalue