lck.common 0.4.4 documentation

This Page

lck.files

lck.files

Filesystem based utilities.

Functions

finder(explicit_path, envvar=None, multiple_allowed=False)

Finds a specific file using explicitly given path (or given by an environment variable). The algorithm is as follows: for every given path from the args (explicitly given, environment variable, fallback) check whether the file exists. If it doesn’t and the path is not absolute, search the working directory, its parent directory and all child directories, the current user’s home directory and /etc.

Parameters:
  • explicit_path – path explicitly given by the user, can be a single entry or a sequence
  • envvar – name of the environment variable where to look for the path
  • fallback – name of the file to check if everything else fails
  • multiple_allowed – False by default. If True, the returned type is a tuple with potentially many entries.
Returns:

the real absolute path to the file. Raises IOError if no found.

..note::
Works only on POSIX systems.