IModList

class mobase.IModList

Bases: object

Interface to the mod-list.

All api functions in this interface work need the internal name of a mod to find a mod. For regular mods (mods the user installed) the display name (as shown to the user) and internal name are identical. For other mods (non-MO mods) there is currently no way to translate from display name to internal name because the display name might not me un-ambiguous.

Methods Summary

allMods()

rtype:

Sequence[str]

allModsByProfilePriority([profile])

rtype:

Sequence[str]

displayName(name)

Retrieve the display name of a mod from its internal name.

getMod(name)

Retrieve an interface to a mod using its name.

onModInstalled(callback)

Install a new handler to be called when a new mod is installed.

onModMoved(callback)

Install a handler to be called when a mod is moved.

onModRemoved(callback)

Install a new handler to be called when a mod is removed.

onModStateChanged(callback)

Install a handler to be called when mod states change (enabled/disabled, endorsed, ...).

priority(name)

Retrieve the priority of a mod.

removeMod(mod)

Remove a mod (from disc and from the UI).

renameMod(mod, name)

Rename the given mod.

setActive(**kwds)

Helper for @overload to raise when called.

setPriority(name, priority)

Change the priority of a mod.

state(name)

Retrieve the state of a mod.

Methods Documentation

allMods()
Return type:

Sequence[str]

Returns:

A list containing the internal names of all installed mods.

allModsByProfilePriority(profile=None)
Return type:

Sequence[str]

Returns:

The list of mod (names), sorted according to the current profile priorities.

displayName(name)

Retrieve the display name of a mod from its internal name.

If you received an internal name from the API (e.g. IPluginList.origin) then you should use that name to identify the mod in all other api calls but use this function to retrieve the name to show to the user.

Return type:

str

Parameters:

name – Internal name of the mod.

Returns:

The display name of the given mod.

getMod(name)

Retrieve an interface to a mod using its name.

Return type:

IModInterface

Parameters:

name – Name of the mod to retrieve.

Returns:

An interface to the given mod, or None if there is no mod with this name.

onModInstalled(callback)

Install a new handler to be called when a new mod is installed.

Return type:

bool

Parameters:

callback – The function to call when a mod is installed. The parameter of the function is the name of the newly installed mod.

Returns:

True if the handler was installed properly (there are currently no reasons for this to fail).

onModMoved(callback)

Install a handler to be called when a mod is moved.

Return type:

bool

Parameters:

callback – The function to call when a mod is moved. The first argument is the internal name of the mod, the second argument the old priority and the third argument the new priority.

Returns:

True if the handler was installed properly (there are currently no reasons for this to fail).

onModRemoved(callback)

Install a new handler to be called when a mod is removed.

Return type:

bool

Parameters:

callback – The function to call when a mod is removed. The parameter of the function is the name of the removed mod.

Returns:

True if the handler was installed properly (there are currently no reasons for this to fail).

onModStateChanged(callback)

Install a handler to be called when mod states change (enabled/disabled, endorsed, …).

Return type:

bool

Parameters:

callback – The function to call when the states of mod change. The argument is a map containing the mods whose states have changed. Keys are internal mod names and values are mod states.

Returns:

True if the handler was installed properly (there are currently no reasons for this to fail).

priority(name)

Retrieve the priority of a mod.

Return type:

int

Parameters:

name – Internal name of the mod.

Returns:

The priority of the given mod.

removeMod(mod)

Remove a mod (from disc and from the UI).

Return type:

bool

Parameters:

mod – The mod to remove.

Returns:

True if the mod was removed, False otherwise.

renameMod(mod, name)

Rename the given mod.

This method usually invalidates the given mod so you should use the returned value after calling it instead of the passed value.

Return type:

IModInterface

Parameters:
  • mod – The mod to rename.

  • name – The new name of the mod.

Returns:

A valid reference to the given mod after renaming it.

setActive(**kwds)

Helper for @overload to raise when called.

setPriority(name, priority)

Change the priority of a mod.

priority is the new priority after the move. Keep in mind that the mod disappears from its old location and all mods with higher priority than the moved mod decrease in priority by one.

Return type:

bool

Parameters:
  • name – Internal name of the mod.

  • priority – The new priority of the mod.

Returns:

True if the priority was changed, False otherwise (if the name or priority were invalid).

state(name)

Retrieve the state of a mod.

Return type:

ModState

Parameters:

name – Internal name of the mod.

Returns:

The state of the given mod.