portage.util.path module

portage.util.path.first_existing(path)

Returns the first existing path element, traversing from the given path to the root directory. A path is considered to exist if lstat either succeeds or raises an error other than ENOENT or ESTALE.

This can be particularly useful to check if there is permission to create a particular file or directory, without actually creating anything.

Parameters

path (str) – a filesystem path

Return type

str

Returns

the element that exists

portage.util.path.iter_parents(path)
Parameters

path (str) – a filesystem path

Return type

iterator

Returns

an iterator which yields path and all parents of path, ending with the root directory