mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
# -*- encoding: utf-8 -*-
|
|
|
|
from typing import Union, cast
|
|
|
|
import mobase
|
|
|
|
|
|
# we do not implement everything since this will do fine if we do not call anything
|
|
# from the C++ side
|
|
#
|
|
class DummyInstaller(mobase.IPluginInstallerSimple):
|
|
def isManualInstaller(self) -> bool:
|
|
return False
|
|
|
|
def priority(self) -> int:
|
|
return 10
|
|
|
|
def isArchiveSupported(self, tree: mobase.IFileTree) -> bool:
|
|
return tree.find("needed-file.txt") is not None
|
|
|
|
def install(
|
|
self,
|
|
name: mobase.GuessedString,
|
|
tree: mobase.IFileTree,
|
|
version: str,
|
|
nexus_id: int,
|
|
) -> Union[
|
|
mobase.InstallResult,
|
|
mobase.IFileTree,
|
|
tuple[mobase.InstallResult, mobase.IFileTree, str, int],
|
|
]:
|
|
if tree.find("needed-file.txt") is None:
|
|
return mobase.InstallResult.FAILED
|
|
|
|
if tree.find("extra-file.txt"):
|
|
name.update("new name")
|
|
new_tree = tree.createOrphanTree()
|
|
new_tree.move(tree, "subtree")
|
|
cast(mobase.IFileTree, new_tree.find("subtree")).remove("extra-file.txt")
|
|
return new_tree
|
|
|
|
return (mobase.InstallResult.NOT_ATTEMPTED, tree, "2.4.5", 33)
|
|
|
|
|
|
def createPlugin() -> mobase.IPlugin:
|
|
return DummyInstaller() # type: ignore
|