Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`python`.`filepath`.`AbstractFilePath``

class documentation

`class AbstractFilePath(Generic[AnyStr]): (source)`

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

View In Hierarchy

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 | `__hash__` | Hash the same as another `AbstractFilePath` with the same path as mine.
Method | `basename` | Subclasses must implement this.
Method | `child` | Subclasses must implement this.
Method | `children` | List the children of this path object.
Method | `descendant` | Retrieve a child or child's child of this path.
Method | `getAccessTime` | Subclasses must implement this.
Method | `getatime` | Deprecated. Use getAccessTime instead.
Method | `getContent` | Retrieve the contents of the file at this path.
Method | `getctime` | Deprecated. Use getStatusChangeTime instead.
Method | `getModificationTime` | Subclasses must implement this.
Method | `getmtime` | Deprecated. Use getModificationTime instead.
Method | `getStatusChangeTime` | Subclasses must implement this.
Method | `isdir` | Subclasses must implement this.
Method | `listdir` | Subclasses must implement this.
Method | `open` | Subclasses must implement this.
Method | `parent` | Subclasses must implement this.
Method | `parents` | Retrieve an iterator of all the ancestors of this path.
Method | `segmentsFrom` | Return a list of segments between a child and its ancestor.
Method | `sibling` | Return a `FilePath` with the same directory as this instance but with a basename of `path`.
Method | `walk` | Yield myself, then each of my children, and each of those children's children in turn.
Type Variable | `Selfish` | Undocumented
Instance Variable | `path` | Subclasses must set this variable.

def __hash__(self) -> `int`: (source)

Hash the same as another `AbstractFilePath` with the same path as mine.

def basename(self) -> `AnyStr`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

def child(self, path: `OtherAnyStr`) -> `AbstractFilePath[OtherAnyStr]`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

def children(self: `_Self`) -> `Iterable[_Self]`: (source)

List the children of this path object.

Returns
`Iterable[_Self]` | an iterable of all currently-existing children of this object.
Raises
`OSError` | If 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.
`UnlistableError` | If 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 descendant(self, segments: `Sequence[OtherAnyStr]`) -> `AbstractFilePath[OtherAnyStr]`: (source)
overridden in `twisted.python.filepath.FilePath`

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

Parameters
segments:`Sequence[OtherAnyStr]` | A sequence of path segments as `str` instances.
Returns
`AbstractFilePath[OtherAnyStr]` | A `FilePath` constructed by looking up the `segments[0]` child of this path, the `segments[1]` child of that path, and so on.
Present Since
10.2
Note
for type-checking, subclasses should override this signature to make it clear that it returns the subclass and not `AbstractFilePath`.

def getAccessTime(self) -> `float`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

See Also
`FilePath.getAccessTime`

def getatime(self) -> `int`: (source)

Deprecated. Use getAccessTime instead.

def getContent(self) -> `bytes`: (source)

Retrieve the contents of the file at this path.

Returns
`bytes` | the contents of the file

def getctime(self) -> `int`: (source)

Deprecated. Use getStatusChangeTime instead.

def getModificationTime(self) -> `float`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

See Also
`FilePath.getModificationTime`

def getmtime(self) -> `int`: (source)

Deprecated. Use getModificationTime instead.

def getStatusChangeTime(self) -> `float`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

See Also
`FilePath.getStatusChangeTime`

def isdir(self) -> `bool`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

def listdir(self) -> `List[AnyStr]`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

def open(self, mode: `FileMode` = 'r') -> `IO[bytes]`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

def parent(self) -> `AbstractFilePath[AnyStr]`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must implement this.

def parents(self) -> `Iterable[AbstractFilePath[AnyStr]]`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Retrieve an iterator of all the ancestors of this path.

Returns
`Iterable[AbstractFilePath[AnyStr]]` | an iterator of all the ancestors of this path, from the most recent (its immediate parent) to the root of its filesystem.

def segmentsFrom(self: `_Self`, ancestor: `_Self`) -> `List[AnyStr]`: (source)

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']`.

Parameters
ancestor:`_Self` | an instance of the same class as self, ostensibly an ancestor of self.
Returns
`List[AnyStr]` | a list of strs
Raises
`ValueError` | 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 sibling(self: `_Self`, path: `OtherAnyStr`) -> `AbstractFilePath[OtherAnyStr]`: (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

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

Parameters
path:`str` | The basename of the `FilePath` to return.
Returns
`FilePath` | The sibling path.
Note
for type-checking, subclasses should override this signature to make it clear that it returns the subclass and not `AbstractFilePath`.

def walk(self: `_Self`, descend: `Optional[Callable[[_Self], bool]]` = None) -> `Iterable[_Self]`: (source)

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).

Parameters
descend:`Optional[Callable[[_Self], bool]]` | A one-argument callable that will return True for FilePaths that should be traversed, False otherwise.
Returns
`Iterable[_Self]` | a generator yielding FilePath-like objects.

Selfish = (source)

Undocumented

Value

    TypeVar('Selfish',
            bound='AbstractFilePath[AnyStr]')

path: `AnyStr` = (source)
overridden in `twisted.python.filepath.FilePath`, `twisted.python.zippath.ZipPath`

Subclasses must set this variable.