Skip to content

Commit 10f906a

Browse files
committed
Making edge cases more Pythonic
1 parent 0f76619 commit 10f906a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

mbed_lstools/linux.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,21 @@ def _sysfs_block_devices(self, block_devices):
122122
full_sysfs_path = os.readlink(sysfs_path)
123123
path_parts = full_sysfs_path.split('/')
124124

125-
end_index = -1
125+
end_index = None
126126
for index, part in enumerate(path_parts):
127127
if self.udp.search(part):
128128
end_index = index
129129
break
130130

131-
if end_index == -1:
131+
if end_index == None:
132132
logger.debug('Did not find suitable usb folder for usb info: %s', full_sysfs_path)
133133
continue
134134

135135
usb_info_rel_path = path_parts[:end_index + 1]
136136
usb_info_path = os.path.join(SYSFS_BLOCK_DEVICE_PATH, os.sep.join(usb_info_rel_path))
137137

138-
vendor_id = 'unknown'
139-
product_id = 'unknown'
138+
vendor_id = None
139+
product_id = None
140140

141141
vendor_id_file_paths = os.path.join(usb_info_path, 'idVendor')
142142
product_id_file_paths = os.path.join(usb_info_path, 'idProduct')

mbed_lstools/windows.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ def _vid_pid_path_to_usb_info(vid_pid_path):
187187
"""! Provide the vendor ID and product ID of a device based on its entry in the registry
188188
@return Returns {'vendor_id': '<vendor ID>', 'product': '<product ID>'}
189189
@details If the vendor ID or product ID can't be determined, they will be returned
190-
as 'unknown'.
190+
as None.
191191
"""
192192
result = {
193-
'vendor_id': 'unknown',
194-
'product_id': 'unknown'
193+
'vendor_id': None,
194+
'product_id': None
195195
}
196196

197197
for component in vid_pid_path.split('&'):

0 commit comments

Comments
 (0)