Skip to content

Commit ea390e4

Browse files
committed
Additional Cleanup
1 parent 870fbc6 commit ea390e4

14 files changed

Lines changed: 277 additions & 141 deletions

games/game_noita.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1+
from functools import cached_property
2+
from pathlib import Path
13
import os
24
import shutil
3-
import json
4-
import mobase
55

6-
from json import JSONDecodeError
7-
from pathlib import Path
8-
from functools import cached_property
6+
import mobase
7+
from PyQt6.QtCore import QDir, QFileInfo
98

109
from ..basic_game import BasicGame
1110

12-
from PyQt6.QtCore import QDir, QFileInfo
13-
1411

1512
class NoitaModDataChecker(mobase.ModDataChecker):
1613
def __init__(self, organizer: mobase.IOrganizer):
@@ -39,7 +36,9 @@ def _Fix_Installed_Mod(self, mod: mobase.IModInterface):
3936
filetree: mobase.IFileTree = mod.fileTree()
4037
fixed = False
4138
modname = mod.name()
42-
if filetree is not None and filetree.exists(GameModsPath + "/FOLDERNAME", mobase.IFileTree.DIRECTORY):
39+
if filetree is not None and filetree.exists(
40+
GameModsPath + "/FOLDERNAME", mobase.IFileTree.DIRECTORY
41+
):
4342
path = mod.absolutePath()
4443
old_path = os.path.join(path, GameModsPath + "/FOLDERNAME")
4544
new_path = os.path.join(path, GameModsPath + f"/{modname}")
@@ -49,7 +48,9 @@ def _Fix_Installed_Mod(self, mod: mobase.IModInterface):
4948
return
5049
self.needsNameFix = False
5150

52-
def dataLooksValid(self, filetree: mobase.IFileTree) -> mobase.ModDataChecker.CheckReturn:
51+
def dataLooksValid(
52+
self, filetree: mobase.IFileTree
53+
) -> mobase.ModDataChecker.CheckReturn:
5354
if filetree.exists("mods", mobase.IFileTree.DIRECTORY):
5455
return mobase.ModDataChecker.VALID
5556
return mobase.ModDataChecker.FIXABLE
@@ -131,15 +132,23 @@ def executableForcedLoads(self) -> list[mobase.ExecutableForcedLoadSetting]:
131132
except AttributeError:
132133
efls = []
133134
libs: set[str] = set()
134-
tree: mobase.IFileTree | mobase.FileTreeEntry | None = self._organizer.virtualFileTree()
135+
tree: mobase.IFileTree | mobase.FileTreeEntry | None = (
136+
self._organizer.virtualFileTree()
137+
)
135138
if type(tree) is not mobase.IFileTree:
136139
return efls
137140
for e in tree:
138141
relpath = e.pathFrom(tree)
139142
if relpath and e.hasSuffix("dll") and relpath not in self._base_dlls:
140143
libs.add(relpath)
141144
exes = self.executables()
142-
efls = efls + [mobase.ExecutableForcedLoadSetting(exe.binary().fileName(), lib).withEnabled(True) for lib in libs for exe in exes]
145+
efls = efls + [
146+
mobase.ExecutableForcedLoadSetting(
147+
exe.binary().fileName(), lib
148+
).withEnabled(True)
149+
for lib in libs
150+
for exe in exes
151+
]
143152
return efls
144153

145154
def initializeProfile(self, directory: QDir, settings: mobase.ProfileSetting):

games/game_ovkwalkingdead.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1+
from enum import IntEnum, auto
2+
from functools import cached_property
3+
from pathlib import Path
14
import json
25
import os
36
import shutil
4-
import mobase
57

6-
from enum import IntEnum, auto
7-
from pathlib import Path
8-
from typing import Any, List, Set, cast
9-
from functools import cached_property
8+
import mobase
9+
from PyQt6.QtCore import QDir, QFileInfo
10+
from PyQt6.QtWidgets import QMainWindow, QTabWidget, QWidget
1011

12+
from ..basic_game import BasicGame
1113
from .unreal_tabs.constants import DEFAULT_UE4SS_MODS, UE4SSModInfo
1214
from .unreal_tabs.manage_paks.widget import PaksTabWidget
1315
from .unreal_tabs.manage_ue4ss.widget import UE4SSTabWidget
1416

15-
from ..basic_game import BasicGame
16-
17-
from PyQt6.QtWidgets import QMainWindow, QTabWidget, QWidget
18-
from PyQt6.QtCore import QDir, QFileInfo
19-
2017

2118
class Content(IntEnum):
2219
UCAS = auto()

games/game_pacificdrive.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1+
from enum import IntEnum, auto
2+
from functools import cached_property
3+
from pathlib import Path
14
import json
25
import os
36
import shutil
4-
import mobase
57

6-
from enum import IntEnum, auto
7-
from pathlib import Path
8-
from typing import Any, List, Set, cast
9-
from functools import cached_property
8+
import mobase
9+
from PyQt6.QtCore import QDir, QFileInfo
10+
from PyQt6.QtWidgets import QMainWindow, QTabWidget, QWidget
1011

12+
from ..basic_game import BasicGame
1113
from .unreal_tabs.constants import DEFAULT_UE4SS_MODS, UE4SSModInfo
1214
from .unreal_tabs.manage_paks.widget import PaksTabWidget
1315
from .unreal_tabs.manage_ue4ss.widget import UE4SSTabWidget
1416

15-
from ..basic_game import BasicGame
16-
17-
from PyQt6.QtWidgets import QMainWindow, QTabWidget, QWidget
18-
from PyQt6.QtCore import QDir, QFileInfo
19-
20-
2117

2218
class Content(IntEnum):
2319
UCAS = auto()

games/game_payday1.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import os
2-
import shutil
3-
import mobase
4-
51
from enum import IntEnum, auto
6-
from pathlib import Path
72
from functools import cached_property
3+
from pathlib import Path
4+
import os
5+
import shutil
86

9-
from ..basic_game import BasicGame
10-
7+
import mobase
118
from PyQt6.QtCore import QDir, QFileInfo
129

10+
from ..basic_game import BasicGame
1311

1412
class Content(IntEnum):
1513
TEXTURE = auto()

games/game_payday2.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import os
2-
import shutil
3-
import mobase
4-
51
from enum import IntEnum, auto
6-
from pathlib import Path
7-
from typing import Any, List, Set, cast
82
from functools import cached_property
3+
from pathlib import Path
4+
import os
5+
import shutil
96

10-
from ..basic_game import BasicGame
11-
7+
import mobase
128
from PyQt6.QtCore import QDir, QFileInfo
139

10+
from ..basic_game import BasicGame
1411

1512
class Content(IntEnum):
1613
TEXTURE = auto()

games/game_payday3.py

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ class Payday3ModDataContent(mobase.ModDataContent):
3838
]
3939

4040
def getAllContents(self) -> list[mobase.ModDataContent.Content]:
41-
return [mobase.ModDataContent.Content(id, name, icon, *filter_only) for id, name, icon, *filter_only in self.GAMECONTENTS]
41+
return [
42+
mobase.ModDataContent.Content(id, name, icon, *filter_only)
43+
for id, name, icon, *filter_only in self.GAMECONTENTS
44+
]
4245

4346
def walkContent(self, path: str, entry: mobase.FileTreeEntry):
4447
if entry.isFile():
@@ -83,7 +86,9 @@ def move_overwrite_merge(self, source, destination):
8386
self.move_overwrite_merge(s_item, d_item)
8487
os.rmdir(source)
8588

86-
def dataLooksValid(self, filetree: mobase.IFileTree) -> mobase.ModDataChecker.CheckReturn:
89+
def dataLooksValid(
90+
self, filetree: mobase.IFileTree
91+
) -> mobase.ModDataChecker.CheckReturn:
8792
GameDataUE4SSMods = self.organizer.managedGame().GameDataUE4SSMods
8893
GameDataPakMods = self.organizer.managedGame().GameDataPakMods
8994
GameDataMovies = self.organizer.managedGame().GameDataMovieMods
@@ -120,10 +125,14 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
120125
GameDataMovies = self.organizer.managedGame().GameDataMovieMods + "/"
121126
treefixed = 0
122127
if filetree.exists("UE4SS.dll", mobase.IFileTree.FILE):
123-
treefixed = self.allMoveTo(filetree, os.path.dirname(os.path.dirname(GameDataUE4SSMods)) + "/")
128+
treefixed = self.allMoveTo(
129+
filetree, os.path.dirname(os.path.dirname(GameDataUE4SSMods)) + "/"
130+
)
124131
if treefixed == 1:
125132
return filetree
126-
if filetree.exists("Scripts", mobase.IFileTree.DIRECTORY) or filetree.exists("dlls", mobase.IFileTree.DIRECTORY):
133+
if filetree.exists("Scripts", mobase.IFileTree.DIRECTORY) or filetree.exists(
134+
"dlls", mobase.IFileTree.DIRECTORY
135+
):
127136
treefixed = self.allMoveTo(filetree, GameDataUE4SSMods)
128137
if treefixed == 1:
129138
return filetree
@@ -139,14 +148,32 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
139148
if mod_name == "":
140149
mod_name = e.name()
141150
mod_path = os.path.join(self.organizer.modsPath(), mod_name)
142-
if filetree.createOrphanTree("OrphanTree") is None and os.path.exists(mod_path):
151+
if filetree.createOrphanTree(
152+
"OrphanTree"
153+
) is None and os.path.exists(mod_path):
143154
match e.suffix().casefold():
144155
case "pak" | "utoc" | "ucas":
145-
os.makedirs(os.path.join(mod_path, GameDataPakMods), exist_ok=True)
146-
shutil.move(os.path.join(mod_path, e.name()), os.path.join(mod_path, GameDataPakMods, e.name()))
156+
os.makedirs(
157+
os.path.join(mod_path, GameDataPakMods),
158+
exist_ok=True,
159+
)
160+
shutil.move(
161+
os.path.join(mod_path, e.name()),
162+
os.path.join(
163+
mod_path, GameDataPakMods, e.name()
164+
),
165+
)
147166
case "bk2":
148-
os.makedirs(os.path.join(mod_path, GameDataMovies), exist_ok=True)
149-
shutil.move(os.path.join(mod_path, e.name()), os.path.join(mod_path, GameDataMovies, e.name()))
167+
os.makedirs(
168+
os.path.join(mod_path, GameDataMovies),
169+
exist_ok=True,
170+
)
171+
shutil.move(
172+
os.path.join(mod_path, e.name()),
173+
os.path.join(
174+
mod_path, GameDataMovies, e.name()
175+
),
176+
)
150177
case _:
151178
pass
152179
treefixed = 1
@@ -158,7 +185,11 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
158185
case "pak" | "utoc" | "ucas":
159186
filetree.move(e, GameDataPakMods, mobase.IFileTree.MERGE)
160187
case "dll":
161-
filetree.move(e, os.path.dirname(GameDataUE4SSMods) + "/", mobase.IFileTree.MERGE)
188+
filetree.move(
189+
e,
190+
os.path.dirname(GameDataUE4SSMods) + "/",
191+
mobase.IFileTree.MERGE,
192+
)
162193
case "bk2":
163194
filetree.move(e, GameDataMovies, mobase.IFileTree.MERGE)
164195
case _:
@@ -231,15 +262,23 @@ def executableForcedLoads(self) -> list[mobase.ExecutableForcedLoadSetting]:
231262
except AttributeError:
232263
efls = []
233264
libs: set[str] = set()
234-
tree: mobase.IFileTree | mobase.FileTreeEntry | None = self._organizer.virtualFileTree()
265+
tree: mobase.IFileTree | mobase.FileTreeEntry | None = (
266+
self._organizer.virtualFileTree()
267+
)
235268
if type(tree) is not mobase.IFileTree:
236269
return efls
237270
for e in tree:
238271
relpath = e.pathFrom(tree)
239272
if relpath and e.hasSuffix("dll") and relpath not in self._base_dlls:
240273
libs.add(relpath)
241274
exes = self.executables()
242-
efls = efls + [mobase.ExecutableForcedLoadSetting(exe.binary().fileName(), lib).withEnabled(True) for lib in libs for exe in exes]
275+
efls = efls + [
276+
mobase.ExecutableForcedLoadSetting(
277+
exe.binary().fileName(), lib
278+
).withEnabled(True)
279+
for lib in libs
280+
for exe in exes
281+
]
243282
return efls
244283

245284
def paksDirectory(self) -> QDir:

games/game_roadtovostok.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import os
22
import shutil
3-
import mobase
43

5-
from pathlib import Path
4+
import mobase
5+
from PyQt6.QtCore import QDir, QFileInfo
66

77
from ..basic_game import BasicGame
88

9-
from PyQt6.QtCore import QDir, QFileInfo
10-
119
class RoadToVostokModDataChecker(mobase.ModDataChecker):
1210
def __init__(self, organizer: mobase.IOrganizer):
1311
super().__init__()

games/game_silenthill2remake.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1+
from enum import IntEnum, auto
2+
from functools import cached_property
3+
from pathlib import Path
14
import json
25
import os
36
import shutil
4-
import mobase
57

6-
from enum import IntEnum, auto
7-
from pathlib import Path
8-
from functools import cached_property
8+
import mobase
9+
from PyQt6.QtCore import QDir, QFileInfo
10+
from PyQt6.QtWidgets import QMainWindow, QTabWidget, QWidget
911

12+
from ..basic_game import BasicGame
1013
from .unreal_tabs.constants import DEFAULT_UE4SS_MODS, UE4SSModInfo
1114
from .unreal_tabs.manage_paks.widget import PaksTabWidget
1215
from .unreal_tabs.manage_ue4ss.widget import UE4SSTabWidget
1316

14-
from ..basic_game import BasicGame
15-
16-
from PyQt6.QtWidgets import QMainWindow, QTabWidget, QWidget
17-
from PyQt6.QtCore import QDir, QFileInfo
18-
19-
2017
class Content(IntEnum):
2118
UCAS = auto()
2219
UTOC = auto()

0 commit comments

Comments
 (0)