Skip to content

Commit b33533e

Browse files
WasabiFandwalton76
authored andcommitted
Use index instead of name for device ID regex group (#376)
1 parent 4974253 commit b33533e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ev3dev/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Device(object):
109109

110110
DEVICE_ROOT_PATH = '/sys/class'
111111

112-
_DEVICE_INDEX = re.compile(r'^.*(?P<idx>\d+)$')
112+
_DEVICE_INDEX = re.compile(r'^.*(\d+)$')
113113

114114
def __init__(self, class_name, name_pattern='*', name_exact=False, **kwargs):
115115
"""Spin through the Linux sysfs class for the device type and find
@@ -142,7 +142,7 @@ def __init__(self, class_name, name_pattern='*', name_exact=False, **kwargs):
142142
def get_index(file):
143143
match = Device._DEVICE_INDEX.match(file)
144144
if match:
145-
return int(match.group('idx'))
145+
return int(match.group(1))
146146
else:
147147
return None
148148

0 commit comments

Comments
 (0)