class bp.memory.MemoryPath(fs, path=())

An IFilePath which shows a view into a MemoryFS.


List the children of the given path.

Returns:an iterable of all currently-existing children of the path.
Return type:iterable

Pretend that we are a directory and get a listing of child names.


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
segmentsFrom(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
sibling(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}
walk(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