summaryrefslogtreecommitdiffstats
path: root/utils_xml.py
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-06-13 20:31:11 +0200
committerJan Pokorný <jpokorny@redhat.com>2014-06-13 20:31:11 +0200
commit835ecc03681383e76b6338240c2ce06ae6ecbcf2 (patch)
tree0f85c3f9b6908c7a49d73128190b05e7597fdaaa /utils_xml.py
parent84c51f33d29c6009e817aa53f59ca170658e023a (diff)
downloadclufter-835ecc03681383e76b6338240c2ce06ae6ecbcf2.tar.gz
clufter-835ecc03681383e76b6338240c2ce06ae6ecbcf2.tar.xz
clufter-835ecc03681383e76b6338240c2ce06ae6ecbcf2.zip
xml_utils: make rng_pivot return "starting" definition
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'utils_xml.py')
-rw-r--r--utils_xml.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/utils_xml.py b/utils_xml.py
index 2ed06a5..9e27b65 100644
--- a/utils_xml.py
+++ b/utils_xml.py
@@ -59,7 +59,19 @@ RNG_ELEMENT = ("/{0}//{1}".format(namespaced('rng', 'grammar'),
@selfaware
def rng_pivot(me, et, tag):
- """Given Relax NG grammar etree as `et`, change start tag (in situ!)"""
+ """Given Relax NG grammar etree as `et`, change start tag (in situ!)
+
+ Use copy.deepcopy or so to (somewhat) preserve the original.
+
+ Returns the live reference to the target element, i.e.,
+
+ at_start = rng_pivot(et, tag)
+
+ is equivalent to
+
+ rng_pivot(et, tag)
+ at_start = rng_get_start(et)[0]
+ """
start = rng_get_start(et)
localname = xmltag_get_localname(tag)
if len(start) != 1:
@@ -90,4 +102,4 @@ def rng_pivot(me, et, tag):
start.clear()
start.append(start_ref)
- return et
+ return target