direct.showbase.VFSImporter

from direct.showbase.VFSImporter import VFSCompiledLoader, VFSExtensionLoader, VFSFinder, VFSLoader, VFSNamespaceLoader, VFSSourceLoader, register

The VFS importer allows importing Python modules from Panda3D’s virtual file system, through Python’s standard import mechanism.

Calling the register() function to register the import hooks should be sufficient to enable this functionality.

Inheritance diagram

Inheritance diagram of direct.showbase.VFSImporter

class VFSCompiledLoader(fullname: str, vfile: VirtualFile)[source]

Bases: VFSLoader

get_code(self, fullname)[source]
get_source(self, fullname)[source]
class VFSExtensionLoader(fullname: str, vfile: VirtualFile)[source]

Bases: VFSLoader

create_module(self, spec)[source]
exec_module(self, module)[source]
get_code(self, fullname)[source]
get_source(self, fullname)[source]
is_package(self, fullname)[source]
class VFSFinder(path: str)[source]

Bases: object

This class serves as a Python importer to support loading Python .py and .pyc/.pyo files from Panda’s Virtual File System, which allows loading Python source files from mounted .mf files (among other places).

__init__(self, path: str) None[source]
find_spec(self, fullname: str, target: module | None = None) _frozen_importlib.ModuleSpec | None[source]
class VFSLoader(fullname: str, vfile: VirtualFile)[source]

Bases: Loader

__init__(self, fullname: str, vfile: VirtualFile) None[source]
create_module(self, spec: ModuleSpec) module | None[source]

Use default semantics for module creation.

exec_module(self, module: module) None[source]

Execute the module.

get_data(path: str) bytes[source]
get_filename(self, fullname: str) str[source]
is_package(self, fullname)[source]
path_mtime(path)[source]
path_stats(path: str) dict[str, Any][source]
class VFSNamespaceLoader[source]

Bases: Loader

create_module(self, spec: ModuleSpec) module | None[source]

Use default semantics for module creation.

exec_module(self, module: module) None[source]
get_code(self, fullname)[source]
get_source(self, fullname)[source]
is_package(self, fullname)[source]
class VFSSourceLoader(fullname: str, vfile: VirtualFile)[source]

Bases: VFSLoader, SourceLoader

get_source(self, fullname)[source]
register() None[source]

Register the VFSFinder 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).