IOrganizer

class mobase.IOrganizer

Bases: object

Interface to class that provides information about the running session of Mod Organizer to be used by plugins.

Methods Summary

appVersion()

rtype:

VersionInfo

basePath()

rtype:

str

createMod(name)

Create a new mod with the specified name.

createNexusBridge()

Create a new Nexus interface.

downloadManager()

rtype:

IDownloadManager

downloadsPath()

rtype:

str

findFileInfos(path, filter)

Find files in the virtual directory matching the specified filter.

findFiles(**kwds)

Helper for @overload to raise when called.

getFileOrigins(filename)

Retrieve the file origins for the specified file.

getGame(name)

Retrieve the game plugin matching the given name.

getPluginDataPath()

rtype:

str

installMod(filename[, name_suggestion])

Install a mod archive at the specified location.

isPluginEnabled(**kwds)

Helper for @overload to raise when called.

listDirectories(directory)

Retrieve the list of (virtual) subdirectories in the given path.

managedGame()

rtype:

IPluginGame

modDataChanged(mod)

Notify the organizer that the given mod has changed.

modList()

rtype:

IModList

modsPath()

rtype:

str

onAboutToRun(**kwds)

Helper for @overload to raise when called.

onFinishedRun(callback)

Install a new handler to be called when an application has finished running.

onNextRefresh(callback[, immediate_if_possible])

Install a new handler to be called on the next refresh or immediately.

onPluginDisabled(**kwds)

Helper for @overload to raise when called.

onPluginEnabled(**kwds)

Helper for @overload to raise when called.

onPluginSettingChanged(callback)

Install a new handler to be called when a plugin setting is changed.

onProfileChanged(callback)

Install a new handler to be called when the current profile is changed.

onProfileCreated(callback)

Install a new handler to be called when a new profile is created.

onProfileRemoved(callback)

Install a new handler to be called when a profile is remove.

onProfileRenamed(callback)

Install a new handler to be called when a profile is renamed.

onUserInterfaceInitialized(callback)

Install a new handler to be called when the UI has been fully initialized.

overwritePath()

rtype:

str

persistent(plugin_name, key[, default])

Retrieve the specified persistent value for a plugin.

pluginDataPath()

Retrieve the path to a directory where plugin data should be stored.

pluginList()

rtype:

IPluginList

pluginSetting(plugin_name, key)

Retrieve settings of plugins.

profile()

rtype:

IProfile

profileName()

rtype:

str

profilePath()

rtype:

str

refresh([save_changes])

Refresh the internal mods file structure from disk.

resolvePath(filename)

Resolves a path relative to the virtual data directory to its absolute real path.

setPersistent(plugin_name, key, value[, sync])

Set the specified persistent value for a plugin.

setPluginSetting(plugin_name, key, value)

Set the specified setting for a plugin.

startApplication(executable[, args, cwd, ...])

Starts an application with virtual filesystem active.

virtualFileTree()

Retrieve a IFileTree object representing the virtual file tree.

waitForApplication(handle[, refresh])

Wait for the application corresponding to the given handle to finish.

Methods Documentation

appVersion()
Return type:

VersionInfo

Returns:

The running version of Mod Organizer.

basePath()
Return type:

str

Returns:

The absolute path to the base directory of Mod Organizer.

createMod(name)

Create a new mod with the specified name.

If a mod with the same name already exists, the user will be queried. If the user chooses to merge or replace, the call will succeed, otherwise the call will fail.

Return type:

IModInterface

Parameters:

name – Name of the mod to create.

Returns:

An interface to the newly created mod that can be used to modify it, or None if the mod

could not be created.

createNexusBridge()

Create a new Nexus interface.

Return type:

IModRepositoryBridge

Returns:

The newly created Nexus interface.

downloadManager()
Return type:

IDownloadManager

Returns:

The interface to the download manager.

downloadsPath()
Return type:

str

Returns:

The absolute path to the download directory.

findFileInfos(path, filter)

Find files in the virtual directory matching the specified filter.

Return type:

Sequence[FileInfo]

Parameters:
  • path – The path to search in (relative to the ‘data’ folder).

  • filter – The function to use to filter files. Should return True for the files to keep.

Returns:

The list of QFileInfo corresponding to the matching files.

findFiles(**kwds)

Helper for @overload to raise when called.

getFileOrigins(filename)

Retrieve the file origins for the specified file.

The origins are listed with their internal name. The internal name of a mod can differ from the display name for disambiguation.

Return type:

Sequence[str]

Parameters:

filename – Path to the file to retrieve origins for (relative to the ‘data’ folder).

Returns:

The list of origins that contain the specified file, sorted by their priority.

getGame(name)

Retrieve the game plugin matching the given name.

Return type:

IPluginGame

Parameters:

name – Name of the game (short name).

Returns:

The plugin for the given game, or None if none was found.

static getPluginDataPath()
Return type:

str

Returns:

The directory for plugin data, typically plugins/data.

installMod(filename, name_suggestion='')

Install a mod archive at the specified location.

Return type:

IModInterface

Parameters:
  • filename – Absolute filepath to the archive to install.

  • name_suggestion – Suggested name for this mod. This can still be changed by the user.

Returns:

An interface to the new installed mod, or None if no installation took place (canceled or failure).

isPluginEnabled(**kwds)

Helper for @overload to raise when called.

listDirectories(directory)

Retrieve the list of (virtual) subdirectories in the given path.

Return type:

Sequence[str]

Parameters:

directory – Path to the directory to list (relative to the ‘data’ folder).

Returns:

The list of directories in the given directory.

managedGame()
Return type:

IPluginGame

Returns:

The plugin corresponding to the current game.

modDataChanged(mod)

Notify the organizer that the given mod has changed.

Return type:

None

Parameters:

mod – The mod that has changed.

modList()
Return type:

IModList

Returns:

The interface to the mod list.

modsPath()
Return type:

str

Returns:

The (absolute) path to the mods directory.

onAboutToRun(**kwds)

Helper for @overload to raise when called.

onFinishedRun(callback)

Install a new handler to be called when an application has finished running.

Return type:

bool

Parameters:

callback – The function to call when an application has finished running. The first parameter is the absolute path to the application, and the second parameter is the exit code of the application.

Returns:

True if the handler was installed properly (there are currently no reasons for

this to fail).

onNextRefresh(callback, immediate_if_possible=True)

Install a new handler to be called on the next refresh or immediately.

Return type:

bool

Parameters:
  • callback – Function to call on the next refresh (or immediately).

  • immediate_if_possible – If True, immediately run the callback if no refresh is currently running.

Returns:

True if the handler was installed properly (there are currently no reasons for

this to fail).

onPluginDisabled(**kwds)

Helper for @overload to raise when called.

onPluginEnabled(**kwds)

Helper for @overload to raise when called.

onPluginSettingChanged(callback)

Install a new handler to be called when a plugin setting is changed.

Return type:

bool

Parameters:

callback – The function to call when a plugin setting is changed. The parameters are: The name of the plugin, the name of the setting, the old value (or None if the setting did not exist before) and the new value of the setting (or None if the setting has been removed).

Returns:

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

onProfileChanged(callback)

Install a new handler to be called when the current profile is changed.

The function is called when the profile is changed but some operations related to the profile might not be finished when this is called (e.g., the virtual file system might not be up-to-date).

Return type:

bool

Parameters:

callback – The function to call when the current profile is changed. The first parameter is the old profile (can be None, e.g. at startup), and the second parameter is the new profile (cannot be None).

Returns:

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

onProfileCreated(callback)

Install a new handler to be called when a new profile is created.

Return type:

bool

Parameters:

callback – The function to call when a new profile is created. The parameter is the new profile (can be a temporary object and should not be stored).

Returns:

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

onProfileRemoved(callback)

Install a new handler to be called when a profile is remove.

The callbacks are called after the profile has been removed so the profile is not accessible anymore.

Return type:

bool

Parameters:

callback – The function to call when a profile is remove. The parameter is the name of the profile that was removed.

Returns:

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

onProfileRenamed(callback)

Install a new handler to be called when a profile is renamed.

Return type:

bool

Parameters:

callback – The function to call when a profile is renamed. The first parameter is the profile being renamed, the second parameter the previous name and the third parameter the new name.

Returns:

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

onUserInterfaceInitialized(callback)

Install a new handler to be called when the UI has been fully initialized.

Return type:

bool

Parameters:

callback – The function to call when the user-interface has been fully initialized. The parameter is the main window of the application (QMainWindow).

Returns:

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

overwritePath()
Return type:

str

Returns:

The (absolute) path to the overwrite directory.

persistent(plugin_name, key, default=None)

Retrieve the specified persistent value for a plugin.

A persistent is an arbitrary value that the plugin can set and retrieve that is persistently stored by the main application. There is no UI for the user to change this value but they can directly access the storage

Return type:

UnionType[None, bool, int, str, list[object], dict[str, object]]

Parameters:
  • plugin_name – Name of the plugin for which to retrieve the value. This should always be IPlugin.name() unless you have a really good reason to access data of another mod AND if you can verify that plugin is actually installed.

  • key – Identifier of the setting.

  • default – Default value to return if the key is not set (yet).

Returns:

The value corresponding to the given persistent setting, or def is the key is not found.

pluginDataPath()

Retrieve the path to a directory where plugin data should be stored.

For python plugins, it is recommended to use a dedicated folder (per plugin) if you need to store data (resources, or multiple python files).

Return type:

str

Returns:

Path to a directory where plugin data should be stored.

pluginList()
Return type:

IPluginList

Returns:

The plugin list interface.

pluginSetting(plugin_name, key)

Retrieve settings of plugins.

Return type:

UnionType[None, bool, int, str, list[object], dict[str, object]]

Parameters:
  • plugin_name – Name of the plugin to retrieve the setting for.

  • key – Name of the setting to retrieve the value for.

Returns:

The value of the setting.

profile()
Return type:

IProfile

Returns:

The interface to the current profile.

profileName()
Return type:

str

Returns:

The name of the current profile, or an empty string if no profile has been loaded (yet).

profilePath()
Return type:

str

Returns:

The absolute path to the active profile or an empty string if no profile has been loaded (yet).

refresh(save_changes=True)

Refresh the internal mods file structure from disk. This includes the mod list, the plugin list, data tab and other smaller things like problems button (same as pressing F5).

The main part of the refresh of the mods file structure, mod list and plugin list is done asynchronously, so you should not expect them to be up-to-date when this function returns.

Return type:

None

Parameters:

save_changes – If True, the relevant profile information is saved first (enabled mods and order of mods).

resolvePath(filename)

Resolves a path relative to the virtual data directory to its absolute real path.

Return type:

str

Parameters:

filename – Path to resolve.

Returns:

The absolute real path, or an empty string if the path was not found.

setPersistent(plugin_name, key, value, sync=True)

Set the specified persistent value for a plugin.

This does not update the in-memory value for this setting, see setPluginSetting() for this.

Return type:

None

Parameters:
  • plugin_name – Name of the plugin for which to change a value. This should always be IPlugin.name() unless you have a really good reason to access data of another mod AND if you can verify that plugin is actually installed.

  • key – Identifier of the setting.

  • value – New value for the setting.

  • sync – If True, the storage is immediately written to disc. This costs performance but is safer against data loss.

setPluginSetting(plugin_name, key, value)

Set the specified setting for a plugin.

This automatically notify handlers register with onPluginSettingChanged, so you do not have to do it yourself.

Return type:

None

Parameters:
  • plugin_name – Name of the plugin for which to change a value. This should always be IPlugin.name() unless you have a really good reason to access data of another mod AND if you can verify that plugin is actually installed.

  • key – Identifier of the setting.

  • value – New value for the setting.

startApplication(executable, args=[], cwd='', profile='', forcedCustomOverwrite='', ignoreCustomOverwrite=False)

Starts an application with virtual filesystem active.

Return type:

int

Parameters:
  • executable – Name or path of the executable. If this is only a filename, it will only work if it has been configured in MO as an executable. If it is a relative path it is expected to be relative to the game directory.

  • args – Arguments to pass to the executable. If the list is empty, and executable refers to a configured executable, the configured arguments are used.

  • cwd – The working directory for the executable. If this is empty, the path to the executable is used unless executable referred to a configured MO executable, in which case the configured cwd is used.

  • profile – Profile to use. If this is empty (the default) the current profile is used.

  • forcedCustomOverwrite – The mod to set as the custom overwrite, regardless of what the profile has configured.

  • ignoreCustomOverwrite – Set to true to ignore the profile’s configured custom overwrite.

Returns:

The handle to the started application, or 0 if the application failed to start.

virtualFileTree()

Retrieve a IFileTree object representing the virtual file tree.

Return type:

IFileTree

Returns:

An IFileTree representing the virtual file tree.

waitForApplication(handle, refresh=True)

Wait for the application corresponding to the given handle to finish.

This will always show the lock overlay, regardless of whether the user has disabled locking in the setting, so use this with care. Note that the lock overlay will always allow the user to unlock, in which case this will return False.

Return type:

Tuple[bool, int]

Parameters:
  • handle – Handle of the application to wait for (as returned by startApplication()).

  • refresh – Whether ModOrganizer should refresh after the process completed or not.

Returns:

A tuple (result, exitcode), where result is a boolean indicating if the application

completed successfully, and exitcode is the exit code of the application.