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:
@@ -460,15 +460,11 @@ def match_depends(module):
|
||||
|
||||
if depends_new:
|
||||
try:
|
||||
try:
|
||||
fl = open(sorcery_depends, 'a')
|
||||
|
||||
with open(sorcery_depends, 'a') as fl:
|
||||
for k in depends_new:
|
||||
fl.write("%s:%s:%s:optional::\n" % (spell, k, depends[k]))
|
||||
except IOError:
|
||||
module.fail_json(msg="I/O error on the depends file")
|
||||
finally:
|
||||
fl.close()
|
||||
except IOError:
|
||||
module.fail_json(msg="I/O error on the depends file")
|
||||
|
||||
depends_ok = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user