Skip to content

Commit

Permalink
Merge pull request #49 from Wolfmyths/future-update
Browse files Browse the repository at this point in the history
Version 1.4.1
  • Loading branch information
Wolfmyths authored Jan 26, 2024
2 parents 5a53d29 + a52ed39 commit 527742c
Show file tree
Hide file tree
Showing 22 changed files with 173 additions and 199 deletions.
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PySide6==6.6.0
PySide6==6.6.1
semantic-version==2.10.0
patool==1.12.0

# For external purposes
pyinstaller==6.2.0
pytest==7.4.2
pytest-qt==4.2.0
pyinstaller==6.3.0
pytest==7.4.4
pytest-qt==4.3.1
2 changes: 1 addition & 1 deletion src/constant_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ class ProfileRole():
# Program Info
PROGRAM_NAME = 'Myth Mod Manager'

VERSION = semantic_version.Version(major=1, minor=4, patch=0)
VERSION = semantic_version.Version(major=1, minor=4, patch=1)
8 changes: 4 additions & 4 deletions src/getPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ def __init__(self, optionFile: str = OPTIONS_CONFIG) -> None:

def __getGamepath(self) -> str:
return OptionsManager(self.option).getGamepath()

def mod_overrides(self) -> str:
'''Returns mod_overrides path'''
return os.path.join(self.__getGamepath(), 'assets', 'mod_overrides')

def mods(self) -> str:
'''Returns mods directory path'''
return os.path.join(self.__getGamepath(), 'mods')

def maps(self) -> str:
'''Returns maps directory path'''
return os.path.join(self.__getGamepath(), 'Maps')

def mod(self, type: ModType, modName: str) -> list[str] | str:
'''
Returns mod path given the type and name,
Expand Down
18 changes: 0 additions & 18 deletions src/threaded/QThread.py

This file was deleted.

13 changes: 3 additions & 10 deletions src/threaded/backupMods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
import shutil
import logging

from src.threaded.file_mover import FileMover
from src.threaded.workerQObject import Worker
from src.constant_vars import ModType, BACKUP_MODS, MODSIGNORE, MOD_CONFIG

class BackupMods(FileMover):
class BackupMods(Worker):

bundledFilePath = os.path.join(os.path.abspath(os.curdir), BACKUP_MODS)

def run(self) -> None:
self.backupMods()
return super().run()

def backupMods(self) -> None:
def start(self) -> None:
'''Takes all of the mods and compresses them into a zip file, the output is in the exe directory'''

# Step 1: Gather Options
Expand Down Expand Up @@ -113,7 +109,4 @@ def backupMods(self) -> None:
shutil.rmtree(self.bundledFilePath)

if not self.cancel:
logging.error('Something went wrong in FileSaver.backupMods():\n%s', str(e))
self.error.emit(f'Something went wrong in FileSaver.backupMods():\n{e}')

self.cancel = True
18 changes: 6 additions & 12 deletions src/threaded/changeModType.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@
import os

import src.errorChecking as errorChecking
from src.threaded.file_mover import FileMover
from src.threaded.workerQObject import Worker
from src.constant_vars import ModType

class ChangeModType(FileMover):
class ChangeModType(Worker):
def __init__(self, *mods: tuple[str, ModType]):
super().__init__()
logging.getLogger(__name__)

self.mods = mods

def run(self) -> None:
self.changeModType(*self.mods)
return super().run()

def changeModType(self, *mods: tuple[str, ModType]) -> None:
def start(self) -> None:
'''
Moves the mod to a new directory
'''

try:
self.setTotalProgress.emit(len(mods))
self.setTotalProgress.emit(len(self.mods))

ChosenDir = None

for mod in mods:
for mod in self.mods:

self.cancelCheck()

Expand All @@ -47,6 +43,4 @@ def changeModType(self, *mods: tuple[str, ModType]) -> None:
self.succeeded.emit()

except Exception as e:
logging.error('An error occured in changeModType:\n%s', str(e))
self.error.emit(str(e))
self.cancel = True
self.error.emit(f'An error occured in changeModType:\n{e}')
29 changes: 12 additions & 17 deletions src/threaded/deleteMod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@
import os
import shutil

from src.threaded.file_mover import FileMover
from src.threaded.workerQObject import Worker

class DeleteMod(FileMover):
def __init__(self, *mods: str):
super().__init__()
logging.getLogger(__name__)
from src.constant_vars import MOD_CONFIG, OPTIONS_CONFIG

class DeleteMod(Worker):
def __init__(self, *mods: str, optionsPath: str = OPTIONS_CONFIG, savePath: str = MOD_CONFIG):
super().__init__(optionsPath=optionsPath, savePath=savePath)

self.mods = mods

def run(self) -> None:
self.deleteMod(*self.mods)
return super().run()

def deleteMod(self, *mods: str) -> None:

def start(self) -> None:
'''Removes the mod(s) from the user's computer'''

logging.info('Deleting mods from computer: %s', ', '.join(mods))
logging.info('Deleting mods from computer: %s', ', '.join(self.mods))

self.setTotalProgress.emit(len(mods))
self.setTotalProgress.emit(len(self.mods))

disPath = self.optionsManager.getDispath()

try:
for modName in mods:
for modName in self.mods:

self.cancelCheck()

Expand All @@ -47,6 +44,4 @@ def deleteMod(self, *mods: str) -> None:
self.succeeded.emit()

except Exception as e:
logging.error('An error has occured in deleteMod():\n%s', str(e))
self.error.emit(str(e))
self.cancel = True
self.error.emit(f'An error has occured in deleteMod():\n{e}')
28 changes: 11 additions & 17 deletions src/threaded/moveToDisabledDir.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import os
import logging

from src.threaded.file_mover import FileMover
from src.threaded.workerQObject import Worker

from src.constant_vars import MOD_CONFIG, OPTIONS_CONFIG

class MoveToDisabledDir(FileMover):
def __init__(self, *mods: str) -> None:
super().__init__()
class MoveToDisabledDir(Worker):
def __init__(self, *mods: str, optionsPath: str = OPTIONS_CONFIG, savePath: str = MOD_CONFIG) -> None:
super().__init__(optionsPath=optionsPath, savePath=savePath)

self.mods = mods

def run(self) -> None:
self.moveToDisabledDir(*self.mods)
return super().run()

def moveToDisabledDir(self, *mods: str) -> None:

def start(self) -> None:
'''Moves a mod to the disabled folder'''

self.setTotalProgress.emit(len(mods))
self.setTotalProgress.emit(len(self.mods))

disabledModsPath = self.optionsManager.getDispath()

try:

for mod in mods:
for mod in self.mods:

self.cancelCheck()

Expand All @@ -37,11 +34,8 @@ def moveToDisabledDir(self, *mods: str) -> None:
self.move(modPath, os.path.join(disabledModsPath, mod))
else:
logging.info('%s is already in the disabled directory', mod)

self.succeeded.emit()

except Exception as e:
logging.error('An error occured while disabling a mod:\n%s', str(e))
self.error.emit(f'An error occured while disabling a mod:\n{e}')

self.cancel = True
26 changes: 11 additions & 15 deletions src/threaded/moveToEnabledDir.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import logging
import os

from src.threaded.file_mover import FileMover
from src.threaded.workerQObject import Worker

class MoveToEnabledModDir(FileMover):
def __init__(self, *mods: str):
super().__init__()
from src.constant_vars import MOD_CONFIG, OPTIONS_CONFIG

class MoveToEnabledModDir(Worker):

def __init__(self, *mods: str, optionsPath: str = OPTIONS_CONFIG, savePath: str = MOD_CONFIG):
super().__init__(optionsPath=optionsPath, savePath=savePath)

self.mods = mods

def run(self) -> None:
self.moveToEnableModDir(*self.mods)
return super().run()

def moveToEnableModDir(self, *mods: str) -> None:

def start(self) -> None:
'''Returns a mod to their respective directory'''

try:

self.setTotalProgress.emit(len(mods))
self.setTotalProgress.emit(len(self.mods))

disabledModsPath = self.optionsManager.getDispath()

for mod in mods:
for mod in self.mods:

self.cancelCheck()

Expand All @@ -39,7 +38,4 @@ def moveToEnableModDir(self, *mods: str) -> None:
self.succeeded.emit()

except Exception as e:
logging.error('An error occured while enabling a mod:\n%s', str(e))
self.error.emit(f'An error occured while enabling a mod:\n{e}')

self.cancel = True
22 changes: 5 additions & 17 deletions src/threaded/unZipMod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,25 @@

import patoolib

from src.threaded.file_mover import FileMover
from src.threaded.workerQObject import Worker
from src.constant_vars import ModType

class UnZipMod(FileMover):
class UnZipMod(Worker):
def __init__(self, *mods: tuple[str, ModType]):
super().__init__()

self.mods = mods

def run(self) -> None:
self.unZipMod(*self.mods)
return super().run()

def unZipMod(self, *mods: tuple[str, ModType]) -> None:
def start(self) -> None:
'''Extracts a mod and puts it into a destination based off the ModType Enum given'''

self.setTotalProgress.emit(len(mods))
self.setTotalProgress.emit(len(self.mods))

modDestDict = {ModType.mods : self.p.mods(), ModType.mods_override : self.p.mod_overrides(), ModType.maps : self.p.maps()}

try:

for modURL in mods:
for modURL in self.mods:

src = modURL[0]

Expand All @@ -48,15 +44,7 @@ def unZipMod(self, *mods: tuple[str, ModType]) -> None:
self.succeeded.emit()

except patoolib.util.PatoolError as e:

logging.error('An error was raised in FileMover.unZipMod():\n%s\nTry extracting the mod manually first', str(e))
self.error.emit(f'An error was raised in FileMover.unZipMod():\n{e}\nTry extracting the mod manually first')

self.cancel = True

except Exception as e:

logging.error('An error was raised in FileMover.unZipMod():\n%s', str(e))
self.error.emit(f'An error was raised in FileMover.unZipMod():\n{e}')

self.cancel = True
Loading

0 comments on commit 527742c

Please sign in to comment.