optparse has a helpful lambda facility, so you can pass a lambda
directly to add_argument. But optparse is deprecated so we are using
argparse, in which this facility was unaccountably removed.
Instead you have to subclass argparse.Action.
The resulting ArgActionLambda will still be a bit awkward to use but a
lot better than lifting what ought to be each lambda body into its own
subclass.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
ok=self._re_ok(Tainted.bad_base91,what,4096)
return self._rtn(ok)
+class ArgActionLambda(argparse.Action):
+ def __init__(self, fn, **kwargs):
+ self.fn=fn
+ argparse.Action.__init__(self,**kwargs)
+ def __call__(self,ap,ns,values,option_string):
+ self.fn(values,ns,ap,option_string)
+
def parse_args():
global service
global inputfile