Source code for anytree.node.symlinknode

# -*- coding: utf-8 -*-
from .symlinknodemixin import SymlinkNodeMixin
from .util import _repr

[docs]class SymlinkNode(SymlinkNodeMixin): def __init__(self, target, parent=None, children=None, **kwargs): u""" Tree node which references to another tree node. Args: target: Symbolic Link Target. Another tree node, which is refered to. Keyword Args: parent: Reference to parent node. children: Iterable with child nodes. *: Any other given attribute is just stored as attribute **in** `target`. The :any:`SymlinkNode` has its own parent and its own child nodes. All other attribute accesses are just forwarded to the target node. >>> from anytree import SymlinkNode, Node, RenderTree >>> root = Node("root") >>> s1 = Node("sub1", parent=root, bar=17) >>> l = SymlinkNode(s1, parent=root, baz=18) >>> l0 = Node("l0", parent=l) >>> print(RenderTree(root)) Node('/root') ├── Node('/root/sub1', bar=17, baz=18) └── SymlinkNode(Node('/root/sub1', bar=17, baz=18)) └── Node('/root/sub1/l0') Any modifications on the target node are also available on the linked node and vice-versa: >>> = 4 >>> 4 >>> 4 >>> = 9 >>> 9 >>> 9 """ = target self.parent = parent if children: self.children = children def __repr__(self): return _repr(self, [repr(], nameblacklist=("target", ))