[gnome-continuous-yocto/gnomeostree-3.28-rocko: 6847/8267] argparse_oe: Add int_positive type
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 6847/8267] argparse_oe: Add int_positive type
- Date: Sun, 17 Dec 2017 05:25:09 +0000 (UTC)
commit 3aa299d51ba57aa80664e5e92654d5b9abcf443b
Author: Aníbal Limón <anibal limon linux intel com>
Date: 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.
(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>
scripts/lib/argparse_oe.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]