forked from pool/python-evdev
- Add evdev-re-Pattern.patch -- gh#gvalkov/python-evdev#152 OBS-URL: https://build.opensuse.org/request/show/884132 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-evdev?expand=0&rev=17
23 lines
725 B
Diff
23 lines
725 B
Diff
diff --git a/evdev/util.py b/evdev/util.py
|
|
index 818be69..e8009f7 100644
|
|
--- a/evdev/util.py
|
|
+++ b/evdev/util.py
|
|
@@ -118,6 +118,8 @@ def find_ecodes_by_regex(regex):
|
|
'''
|
|
Find ecodes matching a regex and return a mapping of event type to event codes.
|
|
|
|
+ regex can be a pattern string or a compiled regular expression object.
|
|
+
|
|
Example
|
|
-------
|
|
>>> find_ecodes_by_regex(r'(ABS|KEY)_BR(AKE|EAK)')
|
|
@@ -130,7 +132,7 @@ def find_ecodes_by_regex(regex):
|
|
}
|
|
'''
|
|
|
|
- regex = regex if isinstance(regex, re.Pattern) else re.compile(regex)
|
|
+ regex = re.compile(regex) # re.compile is idempotent
|
|
result = collections.defaultdict(list)
|
|
|
|
for type_code, codes in ecodes.bytype.items():
|