diff options
| author | william <wan@odoo.com> | 2020-07-09 08:36:21 +0000 |
|---|---|---|
| committer | william <wan@odoo.com> | 2020-07-10 14:18:13 +0000 |
| commit | bffb3b7fced799a1d8c052cf766c50263de5d2bc (patch) | |
| tree | 6b0cdf72f03330b23524255f193d03f1d6b1d255 /odoo/tools/xml_utils.py | |
| parent | 048c7fef6716e7f459e9f88c10e03a1babf98fae (diff) | |
[REF] base: clean dosctring and remove deprecated function
The function check_with_xsd has been deprecated for more than 3 years.
Docstring is now compliant with PEP 257
closes odoo/odoo#54338
X-original-commit: 29938397ee17835645e89ee0dadb26e14ef45927
Signed-off-by: Josse Colpaert <jco@openerp.com>
Diffstat (limited to 'odoo/tools/xml_utils.py')
| -rw-r--r-- | odoo/tools/xml_utils.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/odoo/tools/xml_utils.py b/odoo/tools/xml_utils.py index 513aa207663..8780dd54d25 100644 --- a/odoo/tools/xml_utils.py +++ b/odoo/tools/xml_utils.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""Utilities for generating, parsing and checking XML/XSD files on top of the lxml.etree module.""" + import base64 from io import BytesIO from lxml import etree @@ -23,9 +25,6 @@ class odoo_resolver(etree.Resolver): return self.resolve_string(base64.b64decode(attachment.datas), context) -def check_with_xsd(tree_or_str, stream): - raise UserError("Method 'check_with_xsd' deprecated ") - def _check_with_xsd(tree_or_str, stream, env=None): """Check an XML against an XSD schema. @@ -55,11 +54,14 @@ def _check_with_xsd(tree_or_str, stream, env=None): 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 - contained in `nodes_list`, under the given node `first_parent_node`. - It will also set the value of the last of these nodes to `last_node_value` if it is - specified. This function returns the list of created nodes. + """Generate a hierarchical chain of nodes. + + Each new node being the child of the previous one based on the tags contained + in `nodes_list`, under the given node `first_parent_node`. + :param first_parent_node (etree._Element): parent of the created tree/chain + :param nodes_list (iterable<str>): tag names to be created + :param last_node_value (str): if specified, set the last node's text to this value + :returns (list<etree._Element>): the list of created nodes """ res = [] current_node = first_parent_node @@ -71,11 +73,13 @@ def create_xml_node_chain(first_parent_node, nodes_list, last_node_value=None): current_node.text = last_node_value return res + def create_xml_node(parent_node, node_name, node_value=None): - """ Utility function for managing XML. It creates a new node with the specified - `node_name` as a child of given `parent_node` and assigns it `node_value` as value. - :param parent_node: valid etree Element - :param node_name: string - :param node_value: string + """Create a new node. + + :param parent_node (etree._Element): parent of the created node + :param node_name (str): name of the created node + :param node_value (str): value of the created node (optional) + :returns (etree._Element): """ return create_xml_node_chain(parent_node, [node_name], node_value)[0] |
