class ResourceManager(object):
Parameters | |
base | default value for add_path calls. |
opener | callable used to open resources. |
cachemode | controls which lookups are cached. One of 'all', 'found' or 'none'. |
Method | add​_path |
Add a new path to the list of search paths. Return False if the path does not exist. |
Method | lookup |
Search for a resource and return an absolute file path, or None . |
Method | open |
Find a resource and return a file object, or raise IOError. |
Instance Variable | cache |
Undocumented |
Instance Variable | path |
Undocumented |
Method | __init__ |
Undocumented |
Method | __iter__ |
Iterate over all existing files in all registered paths. |
Instance Variable | base |
Undocumented |
Instance Variable | cachemode |
Undocumented |
Instance Variable | opener |
Undocumented |
Add a new path to the list of search paths. Return False if the path does not exist.
The base
parameter makes it easy to reference files installed
along with a python module or package:
res.add_path('./resources/', __file__)
Parameters | |
path | The new search path. Relative paths are turned into
an absolute and normalized form. If the path looks like a file
(not ending in / ), the filename is stripped off. |
base | Path used to absolutize relative search paths.
Defaults to base which defaults to os.getcwd(). |
index | Position within the list of search paths. Defaults to last index (appends to the list). |
create | Undocumented |
Search for a resource and return an absolute file path, or None
.
The path
list is searched in order. The first match is
returend. Symlinks are followed. The result is cached to speed up
future lookups.