Handle more file closing using context manager (#11942)
This commit is contained in:
parent
4cb1f93019
commit
0376cc0917
4 changed files with 12 additions and 11 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue