Generic Helpers

bp.generic.genericChildren(path)

List the children of the given path.

Returns:an iterable of all currently-existing children of the path.
Return type:iterable
bp.generic.genericDescendant(path, segments)

Retrieve a child or child’s child of the given path.

Parameters:segments (iterable) – A sequence of path segments as L{str} instances.
Returns:A L{FilePath} constructed by looking up the C{segments[0]} child of this path, the C{segments[1]} child of that path, and so on.
bp.generic.genericGetContent(path)

Retrieve the data from a given file path.

bp.generic.genericParents(path)

Retrieve an iterator of all the ancestors of the given path.

Returns:An iterator of all the ancestors of the given path, from the most recent (its immediate parent) to the root of its filesystem.
Return type:iterator
bp.generic.genericSegmentsFrom(path, 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, C{Y.segmentsFrom(X)} will return C{[‘c’, ‘d’]}.

Parameters:ancestor – an instance of the same class as self, ostensibly an ancestor of self.
Raises:ValueError – When 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.
Returns:a list of segments
Return type:list
bp.generic.genericSibling(path, segment)

Return an L{IFilePath} with the same directory as the given path, but with a basename of C{segment}.

Parameters:segment (str) – The basename of the L{IFilePath} to return.
Returns:The sibling path.
Return type:L{IFilePath}
bp.generic.genericWalk(path, descend=None)

Yield a path, then each of its children, and each of those children’s children in turn.

Parameters:descend (callable) – A one-argument callable that will return True for FilePaths that should be traversed and False otherwise. It will be called with each path for which isdir() returns True. If omitted, all directories will be traversed, including symbolic links.
Raises:LinkError – A cycle of symbolic links was found
Returns:a generator yielding FilePath-like objects
Return type:generator