You've already forked community.general
mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-30 18:43:09 +03:00
use open() as context manager (#9579)
* use open() as context manager * add changelog frag
This commit is contained in:
@ -103,13 +103,11 @@ def not_in_host_file(self, host):
|
||||
continue
|
||||
|
||||
try:
|
||||
host_fh = open(hf)
|
||||
with open(hf) as host_fh:
|
||||
data = host_fh.read()
|
||||
except IOError:
|
||||
hfiles_not_found += 1
|
||||
continue
|
||||
else:
|
||||
data = host_fh.read()
|
||||
host_fh.close()
|
||||
|
||||
for line in data.split("\n"):
|
||||
if line is None or " " not in line:
|
||||
|
Reference in New Issue
Block a user