mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
use open() as context manager (#9579)
* use open() as context manager * add changelog frag
This commit is contained in:
@@ -588,11 +588,8 @@ def read_record(file_path, default=None):
|
||||
Reads the first line of a file and returns it.
|
||||
"""
|
||||
try:
|
||||
f = open(file_path, 'r')
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
return f.readline().strip()
|
||||
finally:
|
||||
f.close()
|
||||
except IOError:
|
||||
return default
|
||||
|
||||
|
||||
Reference in New Issue
Block a user