Commit c2d6511a authored by Jacek Sowiński's avatar Jacek Sowiński

Use Command.name() when looking for read-only cmds

parent 19cca43a
...@@ -27,7 +27,7 @@ from topydo.lib.TopydoString import TopydoString ...@@ -27,7 +27,7 @@ from topydo.lib.TopydoString import TopydoString
MAIN_OPTS = "ac:C:d:ht:v" MAIN_OPTS = "ac:C:d:ht:v"
MAIN_LONG_OPTS = ('version') MAIN_LONG_OPTS = ('version')
READ_ONLY_COMMANDS = ('List', 'ListContext', 'ListProject') READ_ONLY_COMMANDS = ('list', 'listcontext', 'listproject')
GENERIC_HELP="""Available commands: GENERIC_HELP="""Available commands:
...@@ -245,9 +245,9 @@ class CLIApplicationBase(object): ...@@ -245,9 +245,9 @@ class CLIApplicationBase(object):
def is_read_only(self, p_command): def is_read_only(self, p_command):
""" Returns True when the given command class is read-only. """ """ Returns True when the given command class is read-only. """
read_only_commands = tuple(cmd + 'Command' for cmd in ('Revert', ) + read_only_commands = tuple(cmd for cmd
READ_ONLY_COMMANDS) in ('revert', ) + READ_ONLY_COMMANDS)
return p_command.__module__.endswith(read_only_commands) return p_command.name() in read_only_commands
def _backup(self, p_command, p_args=[], p_label=None): def _backup(self, p_command, p_args=[], p_label=None):
if config().backup_count() > 0 and p_command and not self.is_read_only(p_command): if config().backup_count() > 0 and p_command and not self.is_read_only(p_command):
......
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