Move parsing to class
This commit is contained in:
parent
705767bcfb
commit
cc747b00ce
@ -1655,4 +1655,4 @@ class Key(BaseType):
|
|||||||
#if utils.is_special_key(value):
|
#if utils.is_special_key(value):
|
||||||
# value = '<{}>'.format(utils.normalize_keystr(value[1:-1]))
|
# value = '<{}>'.format(utils.normalize_keystr(value[1:-1]))
|
||||||
#return value
|
#return value
|
||||||
return keyutils.parse_keystring(value)
|
return keyutils.KeySequence.parse(value)
|
||||||
|
@ -205,12 +205,6 @@ def _parse_keystring(keystr):
|
|||||||
yield 'Shift+' + c if c.isupper() else c
|
yield 'Shift+' + c if c.isupper() else c
|
||||||
|
|
||||||
|
|
||||||
def parse_keystring(keystr):
|
|
||||||
"""Parse a keystring like <Ctrl-x> or xyz and return a KeyInfo list."""
|
|
||||||
s = ', '.join(_parse_keystring(keystr))
|
|
||||||
return KeySequence(s)
|
|
||||||
|
|
||||||
|
|
||||||
def normalize_keystr(keystr):
|
def normalize_keystr(keystr):
|
||||||
"""Normalize a keystring like Ctrl-Q to a keystring like Ctrl+Q.
|
"""Normalize a keystring like Ctrl-Q to a keystring like Ctrl+Q.
|
||||||
|
|
||||||
@ -266,3 +260,9 @@ class KeySequence:
|
|||||||
|
|
||||||
def append_event(self, ev):
|
def append_event(self, ev):
|
||||||
return self.__class__(*self._sequence, ev.modifiers() | ev.key())
|
return self.__class__(*self._sequence, ev.modifiers() | ev.key())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse(cls, keystr):
|
||||||
|
"""Parse a keystring like <Ctrl-x> or xyz and return a KeySequence."""
|
||||||
|
s = ', '.join(_parse_keystring(keystr))
|
||||||
|
return cls(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user