Skip to content

Commit

Permalink
[REF] tools check_with_xsd: Supports generic stream
Browse files Browse the repository at this point in the history
  • Loading branch information
moylop260 committed Sep 25, 2017
1 parent b90006e commit 268f684
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions odoo/tools/xml_utils.py
@@ -1,12 +1,21 @@
# -*- coding: utf-8 -*-

import base64

from io import BytesIO

from lxml import etree
from odoo.tools.misc import file_open

def check_with_xsd(tree_or_str, xsd_path):

def check_with_xsd(tree_or_str, stream):
raise UserError("Method 'check_with_xsd' deprecated ")


def _check_with_xsd(tree_or_str, stream):
if not isinstance(tree_or_str, etree._Element):
tree_or_str = etree.fromstring(tree_or_str)
xml_schema_doc = etree.parse(file_open(xsd_path))
xml_schema_doc = etree.parse(stream)
xsd_schema = etree.XMLSchema(xml_schema_doc)
try:
xsd_schema.assertValid(tree_or_str)
Expand All @@ -15,6 +24,7 @@ def check_with_xsd(tree_or_str, xsd_path):
from odoo.exceptions import UserError
raise UserError('\n'.join(str(e) for e in xml_errors.error_log))


def create_xml_node_chain(first_parent_node, nodes_list, last_node_value=None):
""" Utility function for generating XML files nodes. Generates as a hierarchical
chain of nodes (each new node being the son of the previous one) based on the tags
Expand Down

0 comments on commit 268f684

Please sign in to comment.