mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
made get_file_lines rely on get_file_content which deals with many error
conditions that the former did not.
This commit is contained in:
parent
74d76105aa
commit
37ae243587
1 changed files with 7 additions and 6 deletions
|
@ -2982,12 +2982,13 @@ def get_file_content(path, default=None, strip=True):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_file_lines(path):
|
def get_file_lines(path):
|
||||||
'''file.readlines() that closes the file'''
|
'''get list of lines from file'''
|
||||||
datafile = open(path)
|
data = get_file_content(path)
|
||||||
try:
|
if data:
|
||||||
return datafile.readlines()
|
ret = data.splitlines()
|
||||||
finally:
|
else:
|
||||||
datafile.close()
|
ret = []
|
||||||
|
return ret
|
||||||
|
|
||||||
def ansible_facts(module):
|
def ansible_facts(module):
|
||||||
facts = {}
|
facts = {}
|
||||||
|
|
Loading…
Reference in a new issue