Handle more file closing using context manager (#11942)

This commit is contained in:
Ville Skyttä authored and Pascal Vizeli committed 2018-01-31 11:30:48 +01:00
1 parent 4cb1f93019
commit 0376cc0917
4 files changed
+12 -11

No files matched your search

+2 -2
View File
@@ -66,8 +66,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
device_file, 'temperature'))
else:
for family_file_path in glob(os.path.join(base_dir, '*', 'family')):
family_file = open(family_file_path, "r")
family = family_file.read()
with open(family_file_path, "r") as family_file:
family = family_file.read()
if family in DEVICE_SENSORS:
for sensor_key, sensor_value in DEVICE_SENSORS[family].items():
sensor_id = os.path.split(