Panda3D
|
Classes | |
class | VFSImporter |
class | VFSLoader |
class | VFSSharedImporter |
class | VFSSharedLoader |
Functions | |
register () | |
reloadSharedPackage (mod) | |
reloadSharedPackages () | |
Variables | |
bool | _registered = False |
list | compiledExtensions = [ 'pyc', 'pyo' ] |
dict | sharedPackages = {} |
The sharedPackages dictionary lists all of the "shared packages", special Python packages that automatically span multiple directories via magic in the VFSImporter. | |
vfs = VirtualFileSystem.getGlobalPtr() | |
The VFS importer allows importing Python modules from Panda3D's virtual file system, through Python's standard import mechanism. Calling the :func:`register()` function to register the import hooks should be sufficient to enable this functionality.
register | ( | ) |
Register the VFSImporter on the path_hooks, if it has not already been registered, so that future Python import statements will vector through here (and therefore will take advantage of Panda's virtual file system).
reloadSharedPackage | ( | mod | ) |
Reloads the specific module as a shared package, adding any new directories that might have appeared on the search path.
reloadSharedPackages | ( | ) |
Walks through the sharedPackages list, and forces a reload of any modules on that list that have already been loaded. This allows new directories to be added to the search path.
|
protected |
list compiledExtensions = [ 'pyc', 'pyo' ] |
dict sharedPackages = {} |
The sharedPackages dictionary lists all of the "shared packages", special Python packages that automatically span multiple directories via magic in the VFSImporter.
You can make a package "shared" simply by adding its name into this dictionary (and then calling reloadSharedPackages() if it's already been imported).
When a package name is in this dictionary at import time, all instances of the package are located along sys.path, and merged into a single Python module with a path setting that represents the union. Thus, you can have a direct.showbase.foo in your own application, and loading it won't shadow the system direct.showbase.ShowBase which is in a different directory on disk.
vfs = VirtualFileSystem.getGlobalPtr() |