VFSImporter Example

I was recently informed of the VFSImporter class, and had a little difficulty figuring out quite how to use it–perhaps especially as there seemed to be little documentation and few examples.

So, I thought that a simple example might be of use to others!

The example

The example files should be available via the following zip-file:
VFSImporterExample.zip (2.2 KB)

It should contain the following:

  • Game.py
    • The main example-program, containing the actual use of VFSImporter
  • ModuleSource/ASubDirectory/Cat.py
    • A simple module that the example imports–albeit not from this directory!
  • MultifileDirectory/moduleStore.mf
    • A multifile containing the above, starting with “ASubDirectory”; that is, it contains “ASubDirectory/Cat.py”. This is what we’ll actually import.

As to how it works, Game.py should hopefully cover that in its code-comments! It’s all fairly straightforward, I do believe.

The multifile was created via the “multify” command (to be specific, “multify -c -v -f moduleStore.mf *”), run from the “ModuleSource” directory, I believe.

1 Like