diff options
-rw-r--r-- | WebappConfig/config.py | 36 | ||||
-rw-r--r-- | WebappConfig/debug.py | 38 |
2 files changed, 37 insertions, 37 deletions
diff --git a/WebappConfig/config.py b/WebappConfig/config.py index 597dc18..5a04fb5 100644 --- a/WebappConfig/config.py +++ b/WebappConfig/config.py @@ -846,18 +846,18 @@ class Config: # Handle -E envmap = [] - if ('envall' in options.__dict__ and - options.__dict__['envall']): + if ('envall' in options and + options['envall']): envmap = 'all' - elif ('envvar' in options.__dict__ and - options.__dict__['envvar']): - envmap = [x.lower() for x in options.__dict__['envvar']] + elif ('envvar' in options and + options['envvar']): + envmap = [x.lower() for x in options['envvar']] OUT.debug('Trying to import environment variables', 7) if envmap: - for (key, value) in list(os.environ.items()): + for (key, value) in os.environ.items(): if envmap == 'all' or key.lower() in envmap: @@ -867,16 +867,16 @@ class Config: key.lower(), value) - if ('define' in options.__dict__ and - options.__dict__['define']): - for i in options.__dict__['define']: + if ('define' in options and + options['define']): + for i in options['define']: if '=' in i: self.config.set('USER', i.split('=')[0].lower(), i.split('=')[1]) # Indicate that --dir was found - if 'dir' in options.__dict__: + if 'dir' in options: self.flag_dir = True # Map command line options into the configuration @@ -894,14 +894,14 @@ class Config: 'verbose' : 'g_verbose', 'bug_report' : 'g_bugreport'} - for i in list(option_to_config.keys()): - if i in options.__dict__ and options.__dict__[i]: + for i in option_to_config.keys(): + if i in options and options[i]: self.config.set('USER', option_to_config[i], - str(options.__dict__[i])) + str(options[i])) # handle verbosity - if ('pretend' in options.__dict__ - and options.__dict__['pretend']): + if ('pretend' in options + and options['pretend']): self.config.set('USER', 'g_verbose', 'True') @@ -944,12 +944,12 @@ class Config: 'show_postupgrade', 'check_config', 'query'] for i in work: - if options.__dict__.get(i): + if options.get(i): self.work = i break - if options.__dict__.get('prune_database'): - self.prune_action = options.__dict__.get('prune_database') + if options.get('prune_database'): + self.prune_action = options.get('prune_database') OUT.debug('Checking command line arguments', 1) diff --git a/WebappConfig/debug.py b/WebappConfig/debug.py index 1e6bd2c..3ced649 100644 --- a/WebappConfig/debug.py +++ b/WebappConfig/debug.py @@ -169,37 +169,37 @@ class Message: def cli_handle(self, options): - if ('debug' in options.__dict__ - and options.__dict__['debug']): + if ('debug' in options + and options['debug']): self.debug_on() else: self.debug_off() return - if ('debug_class_vars' in options.__dict__ - and options.__dict__['debug_class_vars']): + if ('debug_class_vars' in options + and options['debug_class_vars']): self.class_variables_on() else: self.class_variables_off() - if ('debug_nocolor' in options.__dict__ - and options.__dict__['debug_nocolor']): + if ('debug_nocolor' in options + and options['debug_nocolor']): self.color_off() else: self.color_on() - if ('debug_level' in options.__dict__ and - options.__dict__['debug_level']): - dbglvl = int(options.__dict__['debug_level']) + if ('debug_level' in options and + options['debug_level']): + dbglvl = int(options['debug_level']) if dbglvl < 0: dbglvl = 0 if dbglvl > 10: dbglvl = 10 self.set_debug_level(dbglvl) - if ('debug_verbose' in options.__dict__ and - options.__dict__['debug_verbose']): - dbgvrb = int(options.__dict__['debug_verbose']) + if ('debug_verbose' in options and + options['debug_verbose']): + dbgvrb = int(options['debug_verbose']) if dbgvrb < 1: dbgvrb = 1 if dbgvrb > 3: @@ -210,9 +210,9 @@ class Message: ('debug_classes', self.set_debug_classes), ('debug_variables', self.set_debug_variables),]: - if (i[0] in options.__dict__ and - options.__dict__[i[0]]): - i[1](options.__dict__[i[0]]) + if (i[0] in options and + options[i[0]]): + i[1](options[i[0]]) ############################################################################# @@ -395,7 +395,7 @@ class Message: callerlocals = inspect.getargvalues(caller[0])[3] ## Is the caller an obejct? If so he provides 'self' - if 'self' in list(callerlocals.keys()): + if 'self' in callerlocals.keys(): callerobject = callerlocals['self'] del callerlocals['self'] if self.show_class_variables: @@ -407,7 +407,7 @@ class Message: # Remove variables not requested if not '*' in self.debug_var: - callerlocals = dict([i for i in list(callerlocals.items()) + callerlocals = dict([i for i in callerlocals.items() if i[0] in self.debug_var]) ## Is the object among the list of objects to debug? @@ -445,7 +445,7 @@ class Message: print('// ' + c, file=self.debug_out) # Selected variables follow if callerlocals: - for i,j in list(callerlocals.items()): + for i,j in callerlocals.items(): print('// ' \ + self.maybe_color('turquoise', str(i)) + ':' + str(j), file=self.debug_out) # Finally the message @@ -480,7 +480,7 @@ class Message: if self.debug_vrb == 3: print(ls + '//', file=self.debug_out) print(ls + '// VALUES ', file=self.debug_out) - for i,j in list(callerlocals.items()): + for i,j in callerlocals.items(): print(ls + '// ------------------> ' \ + self.maybe_color('turquoise', str(i)) + ':', file=self.debug_out) breaklines(str(j)) |