Commit 99f47050 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Deal with pep8 errors in affected files

parent 96a0b656
...@@ -142,13 +142,13 @@ class Shell(Cmd): ...@@ -142,13 +142,13 @@ class Shell(Cmd):
return '' return ''
@classmethod @classmethod
def _register_method(self, method, name): def _register_method(cls, method, name):
self.__dict__[name] = method cls.__dict__[name] = method
@classmethod @classmethod
def _unregister_method(self, name): def _unregister_method(cls, name):
try: try:
self.__dict__.pop(name) cls.__dict__.pop(name)
except KeyError: except KeyError:
pass pass
...@@ -159,17 +159,16 @@ class Shell(Cmd): ...@@ -159,17 +159,16 @@ class Shell(Cmd):
self._unregister_method('help_%s' % subname) self._unregister_method('help_%s' % subname)
@classmethod @classmethod
def _backup(self): def _backup(cls):
return dict(self.__dict__) return dict(cls.__dict__)
@classmethod @classmethod
def _restore(self, oldcontext): def _restore(cls, oldcontext):
self.__dict__ = oldcontext cls.__dict__ = oldcontext
@staticmethod @staticmethod
def _create_help_method(cmd_name, args, required, descr, syntax): def _create_help_method(cmd_name, args, required, descr, syntax):
tmp_args = dict(args) tmp_args = dict(args)
#tmp_args.pop('options', None)
tmp_args.pop('cloud', None) tmp_args.pop('cloud', None)
tmp_args.pop('debug', None) tmp_args.pop('debug', None)
tmp_args.pop('verbose', None) tmp_args.pop('verbose', None)
...@@ -234,8 +233,6 @@ class Shell(Cmd): ...@@ -234,8 +233,6 @@ class Shell(Cmd):
cmd_parser.parsed, name, arg.default) cmd_parser.parsed, name, arg.default)
exec_cmd(instance, cmd_parser.unparsed, help_method) exec_cmd(instance, cmd_parser.unparsed, help_method)
#[term for term in cmd_parser.unparsed\
# if not term.startswith('-')],
except (ClientError, CLIError) as err: except (ClientError, CLIError) as err:
print_error_message(err) print_error_message(err)
elif ('-h' in cmd_args or '--help' in cmd_args) or len(cmd_args): elif ('-h' in cmd_args or '--help' in cmd_args) or len(cmd_args):
...@@ -243,17 +240,16 @@ class Shell(Cmd): ...@@ -243,17 +240,16 @@ class Shell(Cmd):
print('%s' % cmd.help) print('%s' % cmd.help)
print_subcommands_help(cmd) print_subcommands_help(cmd)
else: # change context else: # change context
#new_context = this
backup_context = self._backup() backup_context = self._backup()
old_prompt = self.prompt old_prompt = self.prompt
new_context._roll_command(cmd.parent_path) new_context._roll_command(cmd.parent_path)
new_context.set_prompt(subcmd.path.replace('_', ' ')) new_context.set_prompt(subcmd.path.replace('_', ' '))
newcmds = [subcmd for subcmd in subcmd.subcommands.values()] newcmds = [scmd for scmd in subcmd.subcommands.values()]
for subcmd in newcmds: for scmd in newcmds:
new_context._register_command(subcmd.path) new_context._register_command(scmd.path)
new_context.cmdloop() new_context.cmdloop()
self.prompt = old_prompt self.prompt = old_prompt
#when new context is over, roll back to the old one # when new context is over, roll back to the old one
self._restore(backup_context) self._restore(backup_context)
self._register_method(do_method, 'do_%s' % cmd.name) self._register_method(do_method, 'do_%s' % cmd.name)
...@@ -262,7 +258,6 @@ class Shell(Cmd): ...@@ -262,7 +258,6 @@ class Shell(Cmd):
if cmd.is_command: if cmd.is_command:
cls = cmd.cmd_class cls = cmd.cmd_class
ldescr = getattr(cls, 'long_description', '') ldescr = getattr(cls, 'long_description', '')
#_construct_command_syntax(cls)
plist = self.prompt[len(self._prefix):-len(self._suffix)] plist = self.prompt[len(self._prefix):-len(self._suffix)]
plist = plist.split(' ') plist = plist.split(' ')
clist = cmd.path.split('_') clist = cmd.path.split('_')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment