guibot.fileresolver module¶
Cached and reused paths for target files to search in and load target data from.
SUMMARY¶
INTERFACE¶
- class guibot.fileresolver.FileResolver[source]¶
Bases:
objectHandler for currently used target paths or sources of targets with a desired name.
The methods of this class are shared among all of its instances.
- add_path(directory: str) None[source]¶
Add a path to the list of currently accessible paths if it wasn’t already added.
- Parameters:
directory – path to add
- remove_path(directory: str) bool[source]¶
Remove a path from the list of currently accessible paths.
- Parameters:
directory – path to add
- Returns:
whether the removal succeeded
- search(filename: str, restriction: str = '', silent: bool = False) str | None[source]¶
Search for a filename in the currently accessible paths.
- Parameters:
filename – filename of the target to search for
restriction – simple string to restrict the number of paths
silent – whether to return None instead of error out
- Returns:
the full name of the found target file or None if silent and no file was found
- Raises:
FileNotFoundErrorif no such file was found and not silent
- class guibot.fileresolver.CustomFileResolver(*paths: tuple[type, ...])[source]¶
Bases:
objectClass to be used to search for files inside certain paths.
Inside the context of an instance of this class, the paths in the shared list in
FileResolverwill be temporarily replaced by the paths passed to the constructor of this class. This means that any call toFileResolver.search()will take only these paths into account.