INNER CODE UNIT · Python
find_spec
metatypedev/metatype · src/pyrt_wit_wire/main.py:170
def find_spec(self, fullname: str, _path, target=None):
if fullname in self._mod_names:
path = self._mod_names[fullname]
# this helper will return a ModuleSpec populating
# its' fields according to methods on the Loader
# note, the loader is ultimately responsible for making
# the module as well. The spec itself is an indirection
# for flexebility purposes
return importlib.util.spec_from_loader(
fullname,
# our fake loader will give out the raw module src
# when asked
FakeFileLoader(
fullname, path, src=self._mods_raw[path], is_package=False
),
)
# when one imports foo.bar.keg
# python will ask us for packages foo and bar