Treat commands using ;; in key config as valid.
This commit is contained in:
parent
f865b87a74
commit
31bcc70efb
@ -257,15 +257,32 @@ class KeyConfigParser(QObject):
|
|||||||
self.is_dirty = True
|
self.is_dirty = True
|
||||||
self.config_dirty.emit()
|
self.config_dirty.emit()
|
||||||
|
|
||||||
|
def _validate_command(self, line):
|
||||||
|
"""Check if a given command is valid."""
|
||||||
|
commands = line.split(';;')
|
||||||
|
try:
|
||||||
|
cmd = cmdutils.cmd_dict[commands[0]]
|
||||||
|
if cmd.no_cmd_split:
|
||||||
|
commands = [line]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
for cmd in commands:
|
||||||
|
if not cmd.strip():
|
||||||
|
raise KeyConfigError("Got empty command (line: {!r})!".format(
|
||||||
|
line))
|
||||||
|
commands = [c.split(maxsplit=1)[0].strip() for c in commands]
|
||||||
|
for cmd in commands:
|
||||||
|
if cmd not in cmdutils.cmd_dict:
|
||||||
|
raise KeyConfigError("Invalid command '{}'!".format(cmd))
|
||||||
|
|
||||||
def _read_command(self, line):
|
def _read_command(self, line):
|
||||||
"""Read a command from a line."""
|
"""Read a command from a line."""
|
||||||
if self._cur_section is None:
|
if self._cur_section is None:
|
||||||
raise KeyConfigError("Got command '{}' without getting a "
|
raise KeyConfigError("Got command '{}' without getting a "
|
||||||
"section!".format(line))
|
"section!".format(line))
|
||||||
else:
|
else:
|
||||||
command = line.split(maxsplit=1)[0]
|
self._validate_command(line)
|
||||||
if command not in cmdutils.cmd_dict:
|
|
||||||
raise KeyConfigError("Invalid command '{}'!".format(command))
|
|
||||||
for rgx, repl in configdata.CHANGED_KEY_COMMANDS:
|
for rgx, repl in configdata.CHANGED_KEY_COMMANDS:
|
||||||
if rgx.match(line):
|
if rgx.match(line):
|
||||||
line = rgx.sub(repl, line)
|
line = rgx.sub(repl, line)
|
||||||
|
Loading…
Reference in New Issue
Block a user