Skip to content

Commit f502fb4

Browse files
authored
Add pre-commit hook (#179)
* Update dev dependencies. * Add pre-commit hook.
1 parent 9e30d7d commit f502fb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+663
-577
lines changed

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-toml
9+
- id: check-merge-conflict
10+
- id: mixed-line-ending
11+
args: [--fix=lf]
12+
- id: check-case-conflict
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.11.7 # must match pyproject.toml
15+
hooks:
16+
- id: ruff
17+
args: [--extend-select, I, --fix]
18+
- id: ruff-format
19+
20+
ci:
21+
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
22+
autofix_prs: true
23+
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
24+
autoupdate_schedule: quarterly
25+
submodules: false

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
44

55
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

basic_features/basic_local_savegames.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import mobase
21
from PyQt6.QtCore import QDir
32

3+
import mobase
4+
45

56
class BasicLocalSavegames(mobase.LocalSavegames):
67
def __init__(self, game_save_dir: QDir):

basic_features/basic_mod_data_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class GlobPatterns:
7878
unfold: list[str] | None = None
7979
valid: list[str] | None = None
8080
delete: list[str] | None = None
81-
move: dict[str, str] = field(default_factory=dict)
81+
move: dict[str, str] = field(default_factory=dict[str, str])
8282

8383
def merge(
8484
self, other: GlobPatterns, mode: Literal["merge", "replace"] = "replace"

basic_features/basic_save_game_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from pathlib import Path
77
from typing import Any, Callable, Self, Sequence
88

9-
import mobase
109
from PyQt6.QtCore import QDateTime, QLocale, Qt
1110
from PyQt6.QtGui import QImage, QPixmap
1211
from PyQt6.QtWidgets import QFormLayout, QLabel, QSizePolicy, QVBoxLayout, QWidget
1312

13+
import mobase
14+
1415

1516
def format_date(date_time: QDateTime | datetime | str, format_str: str | None = None):
1617
"""Default format for date and time in the `BasicGameSaveGameInfoWidget`.

basic_game.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
from pathlib import Path
66
from typing import Callable, Generic, TypeVar
77

8-
import mobase
98
from PyQt6.QtCore import QDir, QFileInfo, QStandardPaths
109
from PyQt6.QtGui import QIcon
1110
from PyQt6.QtWidgets import QMessageBox
1211

12+
import mobase
13+
1314
from .basic_features.basic_save_game_info import (
1415
BasicGameSaveGame,
1516
BasicGameSaveGameInfo,

games/game_arkhamcity.py

Lines changed: 87 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,87 @@
1-
import mobase
2-
from PyQt6.QtCore import QDir, QFileInfo
3-
4-
from ..basic_features import BasicLocalSavegames
5-
from ..basic_game import BasicGame
6-
from ..steam_utils import find_steam_path
7-
8-
9-
# Lifted from https://github.com/ModOrganizer2/modorganizer-basic_games/blob/71dbb8c557d43cba9d290674a332e7ecd1650261/games/game_darkestdungeon.py
10-
class ArkhamCityModDataChecker(mobase.ModDataChecker):
11-
def __init__(self):
12-
super().__init__()
13-
self.validDirNames = [
14-
"config",
15-
"cookedpcconsole",
16-
"localization",
17-
"movies",
18-
"moviesstereo",
19-
"splash",
20-
]
21-
22-
def dataLooksValid(
23-
self, filetree: mobase.IFileTree
24-
) -> mobase.ModDataChecker.CheckReturn:
25-
for entry in filetree:
26-
if not entry.isDir():
27-
continue
28-
if entry.name().casefold() in self.validDirNames:
29-
return mobase.ModDataChecker.VALID
30-
return mobase.ModDataChecker.INVALID
31-
32-
33-
class ArkhamCityGame(BasicGame):
34-
Name = "Batman: Arkham City Plugin"
35-
Author = "Paynamia"
36-
Version = "0.5.3"
37-
38-
GameName = "Batman: Arkham City"
39-
GameShortName = "batmanarkhamcity"
40-
GameNexusId = 372
41-
GameSteamId = 200260
42-
GameGogId = 1260066469
43-
GameEpicId = "Egret"
44-
GameBinary = "Binaries/Win32/BatmanAC.exe"
45-
GameLauncher = "Binaries/Win32/BmLauncher.exe"
46-
GameDataPath = "BmGame"
47-
GameDocumentsDirectory = (
48-
"%DOCUMENTS%/WB Games/Batman Arkham City GOTY/BmGame/Config"
49-
)
50-
GameIniFiles = ["UserEngine.ini", "UserGame.ini", "UserInput.ini"]
51-
GameSaveExtension = "sgd"
52-
53-
# This will only detect saves from the earliest-created Steam profile on the user's PC.
54-
def savesDirectory(self) -> QDir:
55-
docSaves = QDir(self.documentsDirectory().cleanPath("../../SaveData"))
56-
if self.is_steam():
57-
if (steamDir := find_steam_path()) is None:
58-
return docSaves
59-
for child in steamDir.joinpath("userdata").iterdir():
60-
if not child.is_dir() or child.name == "0":
61-
continue
62-
steamSaves = child.joinpath("200260", "remote")
63-
if steamSaves.is_dir():
64-
return QDir(str(steamSaves))
65-
else:
66-
return docSaves
67-
else:
68-
return docSaves
69-
70-
def init(self, organizer: mobase.IOrganizer) -> bool:
71-
super().init(organizer)
72-
self._register_feature(ArkhamCityModDataChecker())
73-
self._register_feature(BasicLocalSavegames(self.savesDirectory()))
74-
return True
75-
76-
def executables(self):
77-
return [
78-
mobase.ExecutableInfo(
79-
"Batman: Arkham City",
80-
QFileInfo(self.gameDirectory(), "Binaries/Win32/BatmanAC.exe"),
81-
),
82-
mobase.ExecutableInfo(
83-
"Arkham City Launcher",
84-
QFileInfo(self.gameDirectory(), "Binaries/Win32/BmLauncher.exe"),
85-
),
86-
]
1+
from PyQt6.QtCore import QDir, QFileInfo
2+
3+
import mobase
4+
5+
from ..basic_features import BasicLocalSavegames
6+
from ..basic_game import BasicGame
7+
from ..steam_utils import find_steam_path
8+
9+
10+
# Lifted from https://github.com/ModOrganizer2/modorganizer-basic_games/blob/71dbb8c557d43cba9d290674a332e7ecd1650261/games/game_darkestdungeon.py
11+
class ArkhamCityModDataChecker(mobase.ModDataChecker):
12+
def __init__(self):
13+
super().__init__()
14+
self.validDirNames = [
15+
"config",
16+
"cookedpcconsole",
17+
"localization",
18+
"movies",
19+
"moviesstereo",
20+
"splash",
21+
]
22+
23+
def dataLooksValid(
24+
self, filetree: mobase.IFileTree
25+
) -> mobase.ModDataChecker.CheckReturn:
26+
for entry in filetree:
27+
if not entry.isDir():
28+
continue
29+
if entry.name().casefold() in self.validDirNames:
30+
return mobase.ModDataChecker.VALID
31+
return mobase.ModDataChecker.INVALID
32+
33+
34+
class ArkhamCityGame(BasicGame):
35+
Name = "Batman: Arkham City Plugin"
36+
Author = "Paynamia"
37+
Version = "0.5.3"
38+
39+
GameName = "Batman: Arkham City"
40+
GameShortName = "batmanarkhamcity"
41+
GameNexusId = 372
42+
GameSteamId = 200260
43+
GameGogId = 1260066469
44+
GameEpicId = "Egret"
45+
GameBinary = "Binaries/Win32/BatmanAC.exe"
46+
GameLauncher = "Binaries/Win32/BmLauncher.exe"
47+
GameDataPath = "BmGame"
48+
GameDocumentsDirectory = (
49+
"%DOCUMENTS%/WB Games/Batman Arkham City GOTY/BmGame/Config"
50+
)
51+
GameIniFiles = ["UserEngine.ini", "UserGame.ini", "UserInput.ini"]
52+
GameSaveExtension = "sgd"
53+
54+
# This will only detect saves from the earliest-created Steam profile on the user's PC.
55+
def savesDirectory(self) -> QDir:
56+
docSaves = QDir(self.documentsDirectory().cleanPath("../../SaveData"))
57+
if self.is_steam():
58+
if (steamDir := find_steam_path()) is None:
59+
return docSaves
60+
for child in steamDir.joinpath("userdata").iterdir():
61+
if not child.is_dir() or child.name == "0":
62+
continue
63+
steamSaves = child.joinpath("200260", "remote")
64+
if steamSaves.is_dir():
65+
return QDir(str(steamSaves))
66+
else:
67+
return docSaves
68+
else:
69+
return docSaves
70+
71+
def init(self, organizer: mobase.IOrganizer) -> bool:
72+
super().init(organizer)
73+
self._register_feature(ArkhamCityModDataChecker())
74+
self._register_feature(BasicLocalSavegames(self.savesDirectory()))
75+
return True
76+
77+
def executables(self):
78+
return [
79+
mobase.ExecutableInfo(
80+
"Batman: Arkham City",
81+
QFileInfo(self.gameDirectory(), "Binaries/Win32/BatmanAC.exe"),
82+
),
83+
mobase.ExecutableInfo(
84+
"Arkham City Launcher",
85+
QFileInfo(self.gameDirectory(), "Binaries/Win32/BmLauncher.exe"),
86+
),
87+
]

games/game_blackandwhite2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
from pathlib import Path
77
from typing import BinaryIO
88

9-
import mobase
109
from PyQt6.QtCore import QDateTime, QDir, QFile, QFileInfo
1110

11+
import mobase
12+
1213
from ..basic_features import BasicLocalSavegames
1314
from ..basic_features.basic_save_game_info import (
1415
BasicGameSaveGame,

games/game_bladeandsorcery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
from collections.abc import Mapping
33
from pathlib import Path
44

5-
import mobase
65
from PyQt6.QtCore import QDateTime, QDir
76

7+
import mobase
8+
89
from ..basic_features.basic_save_game_info import (
910
BasicGameSaveGame,
1011
BasicGameSaveGameInfo,

games/game_control.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22

3-
import mobase
43
from PyQt6.QtCore import QFileInfo
54

5+
import mobase
6+
67
from ..basic_game import BasicGame
78

89

0 commit comments

Comments
 (0)