class documentation

class ResourceManager(object): (source)

View In Hierarchy

This class manages a list of search paths and helps to find and open application-bound resources (files). :param base: default value for :meth:`add_path` calls. :param opener: callable used to open resources. :param cachemode: controls which lookups are cached. One of 'all', 'found' or 'none'.

Method __init__ Undocumented
Method __iter__ Iterate over all existing files in all registered paths.
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 base Undocumented
Instance Variable cache Undocumented
Instance Variable cachemode Undocumented
Instance Variable opener Undocumented
Instance Variable path Undocumented
def __init__(self, base='./', opener=open, cachemode='all'): (source)

Undocumented

def __iter__(self): (source)

Iterate over all existing files in all registered paths.

def add_path(self, path, base=None, index=None, create=False): (source)

Add a new path to the list of search paths. Return False if the path does not exist. :param 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. :param base: Path used to absolutize relative search paths. Defaults to :attr:`base` which defaults to ``os.getcwd()``. :param index: Position within the list of search paths. Defaults to last index (appends to the list). The `base` parameter makes it easy to reference files installed along with a python module or package:: res.add_path('./resources/', __file__)

def lookup(self, name): (source)

Search for a resource and return an absolute file path, or `None`. The :attr:`path` list is searched in order. The first match is returend. Symlinks are followed. The result is cached to speed up future lookups.

def open(self, name, mode='r', *args, **kwargs): (source)

Find a resource and return a file object, or raise IOError.

Undocumented

Undocumented

cachemode = (source)

Undocumented

Undocumented

Undocumented