Created
October 26, 2020 12:12
-
-
Save ottobackwards/93a0ecf8dd3fc844302d9d65378b3f0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import xmltodict | |
import nipyapi | |
from requests import Response | |
with open("Acqusition_and_Processing.xml", "r") as template_file: | |
data = template_file.read() | |
# in order to get the TemplateEntity we need to | |
# 1. parse the xml to a dict | |
# 2. parse that dict to a json string | |
# 3. Create a fake response object, so that ApiClient will work | |
# 4. deserialize | |
client = nipyapi.nifi.ApiClient() | |
response = Response() | |
json_string = json.dumps(xmltodict.parse(data)) | |
response.data = json_string | |
template = client.deserialize(response, 'TemplateEntity') | |
print(f"{template}") | |
nipyapi.config.nifi_config.api_client = client | |
template2 = nipyapi.utils.load(json_string, ('nifi', 'TemplateEntity')) | |
print(f"{template2}") | |
if template == template2: | |
print("\n\nMATCH\n") | |
else: | |
print("\n\nNO MATCH\n") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment