Known subclasses: twisted.python.filepath.FilePath, twisted.python.zippath.ZipPath

Abstract implementation of an IFilePath; must be completed by a subclass.

This class primarily exists to provide common implementations of certain methods in IFilePath. It is *not* a required parent class for IFilePath implementations, just a useful starting point.

Method getContent Retrieve the contents of the file at this path.
Method parents Retrieve an iterator of all the ancestors of this path.
Method children List the children of this path object.
Method walk Yield myself, then each of my children, and each of those children's children in turn.
Method sibling Return a FilePath with the same directory as this instance but with a basename of path.
Method descendant Retrieve a child or child's child of this path.
Method segmentsFrom Return a list of segments between a child and its ancestor.
Method __hash__ Hash the same as another FilePath with the same path as mine.
Method getmtime Deprecated. Use getModificationTime instead.
Method getatime Deprecated. Use getAccessTime instead.
Method getctime Deprecated. Use getStatusChangeTime instead.
def getContent(self):

Retrieve the contents of the file at this path.

Returnsthe contents of the file (type: bytes)
def parents(self):

Retrieve an iterator of all the ancestors of this path.

Returnsan iterator of all the ancestors of this path, from the most recent (its immediate parent) to the root of its filesystem.
def children(self):

List the children of this path object.

Returnsan iterable of all currently-existing children of this object.
RaisesOSErrorIf an error occurs while listing the directory. If the error is 'serious', meaning that the operation failed due to an access violation, exhaustion of some kind of resource (file descriptors or memory), OSError or a platform-specific variant will be raised.
UnlistableErrorIf the inability to list the directory is due to this path not existing or not being a directory, the more specific OSError subclass UnlistableError is raised instead.
def walk(self, descend=None):

Yield myself, then each of my children, and each of those children's children in turn.

The optional argument descend is a predicate that takes a FilePath, and determines whether or not that FilePath is traversed/descended into. It will be called with each path for which isdir returns True. If descend is not specified, all directories will be traversed (including symbolic links which refer to directories).

ParametersdescendA one-argument callable that will return True for FilePaths that should be traversed, False otherwise.
Returnsa generator yielding FilePath-like objects.
def sibling(self, path):

Return a FilePath with the same directory as this instance but with a basename of path.

ParameterspathThe basename of the FilePath to return. (type: str)
ReturnsThe sibling path. (type: FilePath)
def descendant(self, segments):

Retrieve a child or child's child of this path.

ParameterssegmentsA sequence of path segments as str instances.
ReturnsA FilePath constructed by looking up the segments[0] child of this path, the segments[1] child of that path, and so on.
Present Since10.2
def segmentsFrom(self, ancestor):

Return a list of segments between a child and its ancestor.

For example, in the case of a path X representing /a/b/c/d and a path Y representing /a/b, Y.segmentsFrom(X) will return ['c', 'd'].

Parametersancestoran instance of the same class as self, ostensibly an ancestor of self.
Returnsa list of strs
RaisesValueError if the 'ancestor' parameter is not actually an ancestor, i.e. a path for /x/y/z is passed as an ancestor for /a/b/c/d.
def __hash__(self):

Hash the same as another FilePath with the same path as mine.

def getmtime(self):

Deprecated. Use getModificationTime instead.

def getatime(self):

Deprecated. Use getAccessTime instead.

def getctime(self):

Deprecated. Use getStatusChangeTime instead.

API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.