From ae72c54fac2ab7f7475b29f32cb8e874900cda99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 22 Jan 2019 00:00:00 +0000 Subject: [PATCH] only forward common args that were given, stop forwarding _args_given --- cli_function.py | 6 +----- common.py | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cli_function.py b/cli_function.py index 54f9cda..6d91f60 100755 --- a/cli_function.py +++ b/cli_function.py @@ -162,7 +162,6 @@ class CliFunction: Resolve default arguments from the config file and CLI param defaults. Add an extra _args_given argument which determines if an argument was given or not. - If _args_given is already present in kwargs, preserve it. ''' args_with_defaults = kwargs.copy() # Add missing args from config file. @@ -198,10 +197,7 @@ class CliFunction: args_with_defaults[key] = argument.default else: raise Exception('Value not given for mandatory argument: ' + key) - if '_args_given' in kwargs: - args_with_defaults['_args_given'] = kwargs['_args_given'] - else: - args_with_defaults['_args_given'] = args_given + args_with_defaults['_args_given'] = args_given if 'config_file' in args_with_defaults: del args_with_defaults['config_file'] return args_with_defaults diff --git a/common.py b/common.py index 7b4f394..9f666ee 100644 --- a/common.py +++ b/common.py @@ -682,7 +682,9 @@ Valid emulators: {} and are all defined in this class instead of in the derived class of the script. ''' - return {key:self.env[key] for key in self._common_args | {'_args_given'}} + return { + key:self.env[key] for key in self._common_args if self.env['_args_given'][key] + } def get_stats(self, stat_re=None, stats_file=None): if stat_re is None: