vcs 0.4.0 documentation
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.
Returns True if node’s kind is NodeKind.SUBMODULE, False otherwise.
Returns name of the node so if its path then only last part is returned.
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 |
Attribute : | mode: octal stat mode for a node. Default is 0100644. |
Only one of content and changeset may be given. Passing both would raise NodeError exception.
Parameters: |
|
---|
Returns a list of three element tuples with lineno,changeset and line
Returns lazily content of the FileNode. If possible, would try to decode content from UTF-8.
Returns filenode extension
Mimetype is calculated based on the file’s content. If _mimetype attribute is available, it will be returned (backends which store mimetypes or can easily recognize them, should set this private attribute to indicate that type should NOT be calculated).
Returns a list of changeset for this file in which the file was changed
Returns True if file has binary content.
Returns True if file has executable flag turned on.
Returns pygment’s lexer class. Would try to guess lexer taking file’s content, name and mimetype.
Returns first alias of the lexer guessed for this file.
Wrapper around full mimetype info. It returns only type of fetched mimetype without the encoding part. use get_mimetype function to fetch full set of (type,encoding)
Returns lazily mode of the FileNode. If changeset is not set, would use value given at initialization or 0100644 (default).
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.