You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like the ability to access the site object that has the key named bar like so:
>>>room.parent().parent().nameu'bar'
Current Work Around
We have a class that wraps our graph, within that we have the following method:
defget_parent(self, object, generations=1):
# Split up the yang path and remove empty stringspath= [xforxinobject._yang_path().split('/') ifx]
# Transform parts of the path from: domain[name='foo'] to: domain['foo']path= [re.sub(r"(.+?)\[.+='(.+)'\]", "\g<1>['\g<2>']", x) forxinpath]
# Remove the number of generations from the pathpath=path[:generations*-1]
# create the string and evaluate itreturneval('self.graph.{}'.format('.'.join(path)))
This works, but it would be super helpful having this baked into pyyangbind.
In this workaround self holds an attribute graph that stores the value of my actual graph generated from pyyangbind code. Note that I have not tested this with objects that have multiple keys.
The text was updated successfully, but these errors were encountered:
Hello,
I think a valuable feature would be the ability to access a parent object given any yang path object.
Example:
Given a room object
I would like the ability to access the site object that has the key named
bar
like so:Current Work Around
We have a class that wraps our graph, within that we have the following method:
This works, but it would be super helpful having this baked into pyyangbind.
In this workaround self holds an attribute
graph
that stores the value of my actual graph generated from pyyangbind code. Note that I have not tested this with objects that have multiple keys.The text was updated successfully, but these errors were encountered: