mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
[PR #9579/0de39a6f backport][stable-10] use open() as context manager (#9596)
use open() as context manager (#9579)
* use open() as context manager
* add changelog frag
(cherry picked from commit 0de39a6f47)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
@@ -36,16 +36,14 @@ def inventory():
|
||||
|
||||
|
||||
def load_txt_data(path):
|
||||
f = open(path, 'r')
|
||||
s = f.read()
|
||||
f.close()
|
||||
with open(path, 'r') as f:
|
||||
s = f.read()
|
||||
return s
|
||||
|
||||
|
||||
def load_yml_data(path):
|
||||
f = open(path, 'r')
|
||||
d = yaml.safe_load(f)
|
||||
f.close()
|
||||
with open(path, 'r') as f:
|
||||
d = yaml.safe_load(f)
|
||||
return d
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user