file i/o: use 'with' keyword
This commit is contained in:
@@ -70,7 +70,8 @@ def _find_system_cameras():
|
||||
if os.path.exists(device_root):
|
||||
for device in os.listdir(device_root):
|
||||
try:
|
||||
name = open(os.path.join(device_root, device, 'name')).read()
|
||||
with open(os.path.join(device_root, device, 'name')) as f:
|
||||
name = f.read()
|
||||
except IOError:
|
||||
continue
|
||||
name = name.strip('\n')
|
||||
|
||||
Reference in New Issue
Block a user