Handle more file closing using context manager (#11942)

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

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(