facho/facho.py: maneja rutas relativas.

FossilOrigin-Name: cd97ead663dbbc1e2252f83da6e9cf17f9b3ae32e0ff411427ec62ad3658e89d
This commit is contained in:
2020-10-27 03:19:08 +00:00
parent cb366aa1c5
commit 1a2bd38b35
2 changed files with 28 additions and 3 deletions

View File

@@ -173,12 +173,17 @@ class FachoXML:
xpath = self._path_xpath_for(xpath)
node_paths = xpath.split('/')
node_paths.pop(0) #remove empty /
root_tag = node_paths.pop(0)
root_node = self.builder.build_from_expression(node_paths[0])
root_node = self.builder.build_from_expression(root_tag)
if xpath.startswith('.'):
# restaurar ya que no es la raiz y asignar actual como raiz
node_paths.insert(0, root_tag)
root_node = self.root
if not self.builder.same_tag(root_node.tag, self.root.tag):
raise ValueError('xpath %s must be absolute to /%s' % (xpath, self.root.tag))
else:
node_paths.pop(0)
# crea jerarquia segun xpath indicado
parent = None