diff --git a/setup.py b/setup.py index 21184c0c4b4134b4ecfbfaa0f4057f2089af317d..5fcbaedaf29f89d8d99e2ff2274cbcd77d24861d 100644 --- a/setup.py +++ b/setup.py @@ -148,7 +148,11 @@ setup( # # For an analysis of "install_requires" vs pip's requirements files see: # https://packaging.python.org/en/latest/requirements.html - install_requires=['peppercorn'], # Optional + install_requires=[ + 'lxml', + 'prettierfier', + 'flask' + ], # Optional # List additional groups of dependencies here (e.g. development # dependencies). Users will be able to install these using the "extras" diff --git a/templates/xml/calibration_item.xml b/templates/xml/calibration_item.xml index 66f5e7009cc7a877cae126fc45c67c441d5939fa..aa494ecc8c63dddf7de0a2e4605dc60b48c0f8b3 100644 --- a/templates/xml/calibration_item.xml +++ b/templates/xml/calibration_item.xml @@ -24,7 +24,7 @@ {%- for j in i['description'] %} <dcc:content lang="{{j.lang}}"> {%- for k in j.content %} - {{utils.sanitize_ltx(k)|safe}} + {{k|safe}} {% endfor -%} </dcc:content> {% endfor -%} diff --git a/templates/xml/used_methods.xml b/templates/xml/used_methods.xml index b750d523597e9b485c0f09f5458258abfbc2a3f8..2fccbec21c57f0c14f48c7cd0a093e77664b87fa 100644 --- a/templates/xml/used_methods.xml +++ b/templates/xml/used_methods.xml @@ -14,7 +14,7 @@ {%- for j in i['description'] %} <dcc:content lang="{{j.lang}}"> {%- for k in j.content %} - {{utils.sanitize_ltx(k)|safe}} + {{k|safe}} {% endfor -%} </dcc:content> {% endfor -%} diff --git a/trans.py b/trans.py index f0af9af027445b44d4e779886cb6d429dbd980de..e0ddd8665694112750ebc328305598f7d6047cf8 100644 --- a/trans.py +++ b/trans.py @@ -2,6 +2,7 @@ from flask import Flask, render_template import utils as utils import os +from lxml import etree from prettierfier import prettify_xml config = utils.config @@ -22,7 +23,7 @@ def cert_to_xml(cert_doc): xml = render_template(dcc_template, doc=cert_doc['DCC'], utils=utils) try: - xml = prettify_xml(xml, indent=2, debug=False) + xml = etree.canonicalize(prettify_xml(xml, indent=2, debug=False)) except Exception as error: xml = '<error>' + str(error) + '</error>\n' diff --git a/utils.py b/utils.py index 9412ce5e4b865f0fc6092c041be440c8ac0e978c..84a7e7084dba7f2d287cd0c84199cd00b43f3690 100644 --- a/utils.py +++ b/utils.py @@ -68,7 +68,7 @@ ltx2entity = { '>':'>' } -def sanitize_ltx(x): +def sanitize_ltx(x):# unnecessary, as done by canonicalize for key in ltx2entity: x = x.replace(key, ltx2entity[key]) return x