Given an object instance, returns a list of path locations corresponding to the physical location of the implementation of that instance, with a specified suffix.
ie. if provided an
Fooinstance, whose class is defined in project/subclass/foo.py, and
Bar, whose class is defined in project/bar.py, the returned make_loadpath will return
Returns True iff the named resource can be found anywhere in any place where this loader searches, False otherwise
Returns the contents of the resource, either as a string or a bytes object, depending on whether
binaryis False or True.
Opens the specified resource and returns a open file object. Caller must call .close() on this object when done.
Opens the specified resource as a context manager, ie call with
>>> loader = ResourceLoader() >>> with resource.open("robots.txt") as fp: ... fp.read()
Return a filename pointing to the physical location of the resource. If the resource is only found using the ResourceManager API, extract ‘ the resource to a temporary file and return its path.
extractdir(resourcedir, target, suffixes=None)¶
Extract all file resources contained in the specified resource directory to the target directory.
Searches all loadpaths and optionally the Resources API for any file contained within. This means the target dir may end up with eg. one file from a high-priority path and other files from the system dirs/resources. This in turns makes it easy to just override a single file in a larger set of resource files.
Even if the resourcedir might contain resources in subdirectories (eg “source/sub/dir/resource.xml”), the extraction will be to the top-level target directory (eg “target/resource.xml”).