Skip to content
Snippets Groups Projects
Commit 21b8296e authored by Ladislav Lhotka's avatar Ladislav Lhotka
Browse files

Add method InstanceNode::xpath_parent.

parent f75aa172
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ def contents(*filenames):
setup(
name = "yangson",
packages = ["yangson"],
version = "0.1.49",
version = "0.1.50",
description = "Library for working with YANG schemas and data",
author = "Ladislav Lhotka",
author_email = "lhotka@nic.cz",
......
......@@ -278,6 +278,9 @@ class InstanceNode:
"""Return the node-set of receiver's XPath following-siblings."""
return []
def xpath_parent(self) -> List["InstanceNode"]:
return [self.up()]
def deref(self) -> List["InstanceNode"]:
"""Return the list of nodes that the receiver refers to.
......@@ -522,6 +525,9 @@ class ArrayEntry(InstanceNode):
return ([] if qname and self.qualName != qname
else self.following_entries())
def xpath_parent(self) -> List["InstanceNode"]:
return [self.up().up()]
class InstancePath(list):
"""Instance route."""
......
......@@ -309,7 +309,7 @@ class Step(Expr):
lambda n, qn=self.qname: n.following_siblings(qn),
Axis.parent: (
lambda n, qn=self.qname: [] if qn and qn != n.parent.qualName
else [n.up()]),
else n.xpath_parent()),
Axis.preceding_sibling:
lambda n, qn=self.qname: n.preceding_siblings(qn),
Axis.self:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment