We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 428be2a + a1382dc commit 0eefc87Copy full SHA for 0eefc87
evdev/util.py
@@ -118,6 +118,8 @@ def find_ecodes_by_regex(regex):
118
'''
119
Find ecodes matching a regex and return a mapping of event type to event codes.
120
121
+ regex can be a pattern string or a compiled regular expression object.
122
+
123
Example
124
-------
125
>>> find_ecodes_by_regex(r'(ABS|KEY)_BR(AKE|EAK)')
@@ -130,7 +132,7 @@ def find_ecodes_by_regex(regex):
130
132
}
131
133
134
- regex = regex if isinstance(regex, re.Pattern) else re.compile(regex)
135
+ regex = re.compile(regex) # re.compile is idempotent
136
result = collections.defaultdict(list)
137
138
for type_code, codes in ecodes.bytype.items():
0 commit comments