Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

Lookup plugin yang_json2xml python3 support #48

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lookup_plugins/yang_json2xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ def run(self, terms, variables, **kwargs):
try:
json2xml_exec.main()
with open(xml_file_path, 'r+') as fp:
content = fp.read()

b_content = fp.read()
content = to_text(b_content, errors='surrogate_or_strict')
except UnicodeError as uni_error:
raise AnsibleError('Error while translating to text: %s' % str(uni_error))
except SystemExit:
pass
finally:
Expand All @@ -225,7 +227,7 @@ def run(self, terms, variables, **kwargs):
if not keep_tmp_files:
temp_dir = os.path.join(JSON2XML_DIR_PATH, plugin_instance)
shutil.rmtree(os.path.realpath(os.path.expanduser(temp_dir)), ignore_errors=True)
res.append(etree.tostring(root))
res.append(etree.tostring(root).decode('utf-8'))

return res

Expand Down