Replace string paths with pathlib's path #11
1 changed files with 10 additions and 10 deletions
|
|
@ -1,13 +1,14 @@
|
||||||
from PySide6.QtQml import QmlElement
|
from PySide6.QtQml import QmlElement
|
||||||
from PySide6.QtCore import QAbstractListModel, QModelIndex
|
from PySide6.QtCore import QAbstractListModel, QModelIndex
|
||||||
from leek.mod import Mod, InvalidModError
|
from leek.mod import Mod, InvalidModError
|
||||||
import os
|
from pathlib import Path
|
||||||
|
|
||||||
QML_IMPORT_NAME = "Leek"
|
QML_IMPORT_NAME = "Leek"
|
||||||
QML_IMPORT_MAJOR_VERSION = 1
|
QML_IMPORT_MAJOR_VERSION = 1
|
||||||
|
|
||||||
# TODO: Don't harcode the mods path
|
# TODO: Don't harcode the mods path
|
||||||
GAME_PATH = "/home/toast/.local/share/Steam/steamapps/common/Hatsune Miku Project DIVA Mega Mix Plus/"
|
GAME_PATH = Path("/home/toast/.local/share/Steam/steamapps/common/Hatsune Miku Project DIVA Mega Mix Plus/")
|
||||||
|
MOD_PATH = Path(GAME_PATH, "mods")
|
||||||
|
|
||||||
# Qt follows C++ naming conventions
|
# Qt follows C++ naming conventions
|
||||||
# ruff: noqa: N802
|
# ruff: noqa: N802
|
||||||
|
|
@ -17,13 +18,12 @@ class QModListModel(QAbstractListModel):
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
mods: list[Mod] = []
|
mods: list[Mod] = []
|
||||||
|
|
||||||
with os.scandir(GAME_PATH + "mods/") as dirs:
|
for dir in MOD_PATH.iterdir():
|
||||||
for dir in dirs:
|
|
||||||
try:
|
try:
|
||||||
new_mod: Mod = Mod(dir.path + "/" )
|
new_mod: Mod = Mod(f"{dir.as_posix()}/")
|
||||||
mods.append(new_mod)
|
mods.append(new_mod)
|
||||||
except InvalidModError as e:
|
except InvalidModError as e:
|
||||||
print(f"Found invalid mod at {dir.path}: {e.message}")
|
print(f"Found invalid mod at {dir}: {e.message}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.mods = mods
|
self.mods = mods
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue