Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
| 1 |
import os |
| 2 |
import re |
| 3 |
|
| 4 |
from lxml import etree |
| 5 |
|
| 6 |
from sepaxml import validation |
| 7 |
|
| 8 |
|
| 9 |
def validate_xml(xmlout, schema): |
| 10 |
with open(os.path.join(os.path.dirname(validation.__file__), 'schemas', schema + '.xsd'), 'rb') as schema_file: |
| 11 |
schema_xml = schema_file.read() |
| 12 |
schema_root = etree.XML(schema_xml) |
| 13 |
schema = etree.XMLSchema(schema_root) |
| 14 |
parser = etree.XMLParser(schema=schema) |
| 15 |
xml_root = etree.fromstring(xmlout, parser) |
| 16 |
return etree.tostring(xml_root, pretty_print=True) |
| 17 |
|
| 18 |
|
| 19 |
def clean_ids(xmlout): |
| 20 |
pat1 = re.compile(b'-[0-9a-f]{12}') |
| 21 |
pat2 = re.compile(b'<MsgId>[^<]*</MsgId>') |
| 22 |
pat3 = re.compile(b'\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d') |
| 23 |
pat4 = re.compile(b'\\d\\d\\d\\d-\\d\\d-\\d\\d') |
| 24 |
return pat4.sub(b'0000-00-00', pat3.sub(b'0000-00-00T00:00:00', pat2.sub(b'<MsgId></MsgId>', pat1.sub(b'-000000000000', xmlout)))) |