pymhf.core.mod_loader module#

class pymhf.core.mod_loader.Mod#

Bases: ABC

get_members(predicate)#
pymhf_gui: GUI#
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.

reload(name: str, gui: GUI)#

Reload a mod with the given name.

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.

load(name: str)#

Load the mod state from a file.

Parameters:

name – The name of the file this ModState will be loaded from. Note that this will be a json file loaded from the MOD_SAVE_DIR directory.

save(name: str)#

Save the current mod state to a file.

Parameters:

name – The name of the file this ModState will be saved to. Note that this will be a json file saved within the MOD_SAVE_DIR directory.

class pymhf.core.mod_loader.StructDecoder#

Bases: JSONDecoder

object_hook(obj: dict)#
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 a TypeError).

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)