On Tue, 2017-07-11 at 15:23 -0500, Aníbal Limón wrote: > 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.li...@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 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) > +
when adding an argument into a script, one can define the type expected so and the library itself does what you are doing for free, so not sure if this is needed. > +def int_positive(value): > + ivalue = int(value) > + if ivalue <= 0: > + raise argparse.ArgumentTypeError( > + "%s is not a positive int value" % value) > + return ivalue -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core