loki.tools.files
Functions
|
|
|
A function that creates a decorator which will cache the result of a function |
|
Generate a filename from a hash of |
|
Case-insensitive alternative for glob patterns that recursively walks all sub-directories and matches a case-insensitive regex pattern. |
|
Utility function to generate a list of file paths based on include and exclude patterns applied to a root directory. |
Create a Loki-specific tempdir in the systems temporary directory. |
- gettempdir()
Create a Loki-specific tempdir in the systems temporary directory.
- filehash(source, prefix=None, suffix=None)
Generate a filename from a hash of
source
with an optionalprefix
.
- delete(filename, force=False)
- find_paths(directory, pattern, ignore=None, sort=True)
Utility function to generate a list of file paths based on include and exclude patterns applied to a root directory.
- Parameters:
directory (str or
pathlib.Path
) – Root directory from which to glob files.pattern (list of str) – A list of glob patterns generating files to include in the list.
ignore (list of str, optional) – A list of glob patterns generating files to exclude from the list.
sort (bool, optional) – Flag to indicate alphabetic ordering of files
- Returns:
The list of file names
- Return type:
- find_files(pattern, srcdir='.')
Case-insensitive alternative for glob patterns that recursively walks all sub-directories and matches a case-insensitive regex pattern.
Basic idea from: http://stackoverflow.com/questions/8151300/ignore-case-in-glob-on-linux
- disk_cached(argname, suffix='cache')
A function that creates a decorator which will cache the result of a function
- Parameters:
argname – Name of the argument that holds the filename