IOrganizer¶
-
class
mobase.IOrganizer¶ Bases:
objectInterface to class that provides information about the running session of Mod Organizer to be used by plugins.
Methods Summary
- returns
The running version of Mod Organizer.
basePath()- returns
The absolute path to the base directory of Mod Organizer.
createMod(name)Create a new mod with the specified name.
Create a new Nexus interface.
- returns
The interface to the download manager.
- returns
The absolute path to the download directory.
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.
- returns
The directory for plugin data, typically plugins/data.
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.
- returns
The plugin corresponding to the current game.
modDataChanged(mod)Notify the organizer that the given mod has changed.
modList()- returns
The interface to the mod list.
modsPath()- returns
The (absolute) path to the mods directory.
onAboutToRun(callback)Install a new handler to be called when an application is about to run.
onFinishedRun(callback)Install a new handler to be called when an application has finished running.
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.
- returns
The (absolute) path to the overwrite directory.
persistent(plugin_name, key[, default])Retrieve the specified persistent value for a plugin.
Retrieve the path to a directory where plugin data should be stored.
- returns
The plugin list interface.
pluginSetting(plugin_name, key)Retrieve settings of plugins.
profile()- returns
The interface to the current profile.
- returns
The name of the current profile, or an empty string if no profile has been loaded (yet).
- returns
The absolute path to the active profile or an empty string if no profile has been loaded (yet).
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.
waitForApplication(handle[, refresh])Wait for the application corresponding to the given handle to finish.
Methods Documentation
-
appVersion()¶ - Returns
The running version of Mod Organizer.
- Return type
-
basePath()¶ - Returns
The absolute path to the base directory of Mod Organizer.
- Return type
str
-
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.
- 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.
- Return type
-
createNexusBridge()¶ Create a new Nexus interface.
- Returns
The newly created Nexus interface.
- Return type
-
downloadManager()¶ - Returns
The interface to the download manager.
- Return type
-
downloadsPath()¶ - Returns
The absolute path to the download directory.
- Return type
str
-
findFileInfos(path, filter)¶ Find files in the virtual directory matching the specified filter.
- 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.
- Return type
List[FileInfo]
-
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.
- 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.
- Return type
List[str]
-
getGame(name)¶ Retrieve the game plugin matching the given name.
- Parameters
name – Name of the game (short name).
- Returns
The plugin for the given game, or None if none was found.
- Return type
-
static
getPluginDataPath()¶ - Returns
The directory for plugin data, typically plugins/data.
- Return type
str
-
installMod(filename, name_suggestion='')¶ Install a mod archive at the specified location.
- 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).
- Return type
-
isPluginEnabled(**kwds)¶ Helper for @overload to raise when called.
-
listDirectories(directory)¶ Retrieve the list of (virtual) subdirectories in the given path.
- Parameters
directory – Path to the directory to list (relative to the ‘data’ folder).
- Returns
The list of directories in the given directory.
- Return type
List[str]
-
managedGame()¶ - Returns
The plugin corresponding to the current game.
- Return type
-
modDataChanged(mod)¶ Notify the organizer that the given mod has changed.
- Parameters
mod – The mod that has changed.
-
modsPath()¶ - Returns
The (absolute) path to the mods directory.
- Return type
str
-
onAboutToRun(callback)¶ Install a new handler to be called when an application is about to run.
Multiple handlers can be installed. If any of the handler returns False, the application will not run.
- Parameters
callback – The function to call when an application is about to run. The parameter is the absolute path to the application to run. The function can return False to prevent the application from running.
- Returns
True if the handler was installed properly (there are currently no reasons for this to fail).
- Return type
bool
-
onFinishedRun(callback)¶ Install a new handler to be called when an application has finished running.
- 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).
- Return type
bool
-
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.
- 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).
- Return type
bool
-
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).
- 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).
- Return type
bool
-
onProfileCreated(callback)¶ Install a new handler to be called when a new profile is created.
- 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).
- Return type
bool
-
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.
- 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).
- Return type
bool
-
onProfileRenamed(callback)¶ Install a new handler to be called when a profile is renamed.
- 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).
- Return type
bool
-
onUserInterfaceInitialized(callback)¶ Install a new handler to be called when the UI has been fully initialized.
- 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).
- Return type
bool
-
overwritePath()¶ - Returns
The (absolute) path to the overwrite directory.
- Return type
str
-
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
- 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.
- Return type
Union[None,bool,int,str,List[Any],Dict[str,Any]]
-
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).
- Returns
Path to a directory where plugin data should be stored.
- Return type
str
-
pluginList()¶ - Returns
The plugin list interface.
- Return type
-
pluginSetting(plugin_name, key)¶ Retrieve settings of plugins.
- 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.
- Return type
Union[None,bool,int,str,List[Any],Dict[str,Any]]
-
profileName()¶ - Returns
The name of the current profile, or an empty string if no profile has been loaded (yet).
- Return type
str
-
profilePath()¶ - Returns
The absolute path to the active profile or an empty string if no profile has been loaded (yet).
- Return type
str
-
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.
- 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.
- Parameters
filename – Path to resolve.
- Returns
The absolute real path, or an empty string if the path was not found.
- Return type
str
-
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.
- 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.
- 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.
- 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.
- Return type
int
-
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.
- 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.
- Return type
Tuple[bool,int]