From 179a242caa31ca4b96ada240fa6a6fef7509aa27 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 1 Mar 2021 02:03:44 -0500 Subject: [PATCH] forall: move nested func out to the class This is in preparation for simplifying the jobs support. The nested function is referenced in the options object which can't be pickled, so pull it out into a static method instead. Change-Id: I01d3c4eaabcb8b8775ddf22312a6e142c84cb77d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298722 Reviewed-by: Michael Mortensen Tested-by: Mike Frysinger --- subcmds/forall.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/subcmds/forall.py b/subcmds/forall.py index 4ea7db66..a2ccb7b6 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -115,13 +115,15 @@ without iterating through the remaining projects. """ PARALLEL_JOBS = DEFAULT_LOCAL_JOBS + @staticmethod + def _cmd_option(option, _opt_str, _value, parser): + setattr(parser.values, option.dest, list(parser.rargs)) + while parser.rargs: + del parser.rargs[0] + def _Options(self, p): super()._Options(p) - def cmd(option, opt_str, value, parser): - setattr(parser.values, option.dest, list(parser.rargs)) - while parser.rargs: - del parser.rargs[0] p.add_option('-r', '--regex', dest='regex', action='store_true', help="Execute the command only on projects matching regex or wildcard expression") @@ -136,7 +138,7 @@ without iterating through the remaining projects. help='Command (and arguments) to execute', dest='command', action='callback', - callback=cmd) + callback=self._cmd_option) p.add_option('-e', '--abort-on-errors', dest='abort_on_errors', action='store_true', help='Abort if a command exits unsuccessfully')