mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
Allow ini plugin to load file using other encoding than utf8.
- New option for ini plugins: encoding - Add a new option encoding to _get_file_contents - Use replace option in test/runner/lib/util.py when calling decode on stdout/err output when diff have non-utf8 sequences
This commit is contained in:
parent
806da6e7c7
commit
6a57ad34c0
9 changed files with 78 additions and 35 deletions
|
@ -179,7 +179,7 @@ class DataLoader:
|
|||
except AttributeError:
|
||||
pass # older versions of yaml don't have dispose function, ignore
|
||||
|
||||
def _get_file_contents(self, file_name):
|
||||
def _get_file_contents(self, file_name, encoding='utf-8'):
|
||||
'''
|
||||
Reads the file contents from the given file name, and will decrypt them
|
||||
if they are found to be vault-encrypted.
|
||||
|
@ -194,7 +194,7 @@ class DataLoader:
|
|||
show_content = True
|
||||
try:
|
||||
with open(b_file_name, 'rb') as f:
|
||||
data = f.read()
|
||||
data = to_text(f.read(), encoding=encoding)
|
||||
if is_encrypted(data):
|
||||
data = self._vault.decrypt(data, filename=b_file_name)
|
||||
show_content = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue