pymhf.core.mod_loader module#
- class pymhf.core.mod_loader.ModManager#
Bases:
object
- instantiate_mod(mod: type[Mod], quiet: bool = False) Mod #
Register all the functions within the mod as hooks.
- load_mod(fpath) ModuleType | None #
Load a mod from the given filepath.
This returns the loaded module if it contains a valid mod and can be loaded correctly.
- load_mod_folder(folder: str, bind: bool = True) tuple[int, int] #
Load the mod folder.
Params#
- folder
The path of the folder to be loaded. All mod files within this directory will be loaded and installed.
- bind
Whether or not to actual bind and initialize the hooks within the mod. This should almost always be True except when loading the internal mods initially since it’s not necessary. If this function is called with False, then it MUST be called again with True before the hooks are enabled.
- load_single_mod(fpath: str, bind: bool = True)#
Load a single mod file.
Params#
- folder
The path of the folder to be loaded. All mod files within this directory will be loaded and installed.
- bind
Whether or not to actual bind and initialize the hooks within the mod. This should almost always be True except when loading the internal mods initially since it’s not necessary. If this function is called with False, then it MUST be called again with True before the hooks are enabled.
- class pymhf.core.mod_loader.ModState#
Bases:
ABC
A class which is used as a base class to indicate that the class is to be used as a mod state.
Mod State classes will persist across mod reloads so any variables set in it will have the same value after the mod has been reloaded.
- class pymhf.core.mod_loader.StructEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#
Bases:
JSONEncoder
- default(obj)#
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)