Simplest class representing file or directory on repository. SCM backends should use FileNode and DirNode subclasses rather than Node directly.
Node’s path cannot start with slash as we operate on relative paths only. Moreover, every single node is identified by the path attribute, so it cannot end with slash, too. Otherwise, path could lead to mistakes.
Returns node’s parent path or empty string if node is root.
Returns True if node’s kind is NodeKind.DIR, False otherwise.
Returns True if node’s kind is NodeKind.FILE, False otherwise.
Returns True if node is a root node and False otherwise.
Class representing file nodes.
Attribute : | path: path to the node, relative to repostiory’s root |
---|---|
Attribute : | content: if given arbitrary sets content of the file |
Attribute : | changeset: if given, first time content is accessed, callback |
Only one of content and changeset may be given. Passing both would raise NodeError exception.
Parameters: |
|
---|
Dummy FileNode class - trying to access any public attribute except path, name, kind or state (or methods/attributes checking those two) would raise RemovedFileNodeError.
Parameters: | path – relative path to the node |
---|
DirNode stores list of files and directories within this node. Nodes may be used standalone but within repository context they lazily fetch data within same repositorty’s changeset.
Only one of nodes and changeset may be given. Passing both would raise NodeError exception.
Parameters: |
|
---|
Returns node from within this particular DirNode, so it is now allowed to fetch, i.e. node located at ‘docs/api/index.rst’ from node ‘docs’. In order to access deeper nodes one must fetch nodes between them first - this would work:
docs = root.get_node('docs')
docs.get_node('api').get_node('index.rst')
Param : | path - relative to the current node |
---|
Note
To access lazily (as in example above) node have to be initialized with related changeset object - without it node is out of context and may know nothing about anything else than nearest (located at same level) nodes.