Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(modules.config): clean game dir subfolders #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import configparser
import os
import re
from modules.common.singleton import Singleton
from modules.errors import NoTokenError
from modules.find_game import find_lostark_directory
Expand Down Expand Up @@ -106,8 +107,8 @@ def load_config(self):
self.screenshots_directory = None

if self._config.has_option("Watcher", "game_directory"):
self.game_directory = self._config.get(
"Watcher", "game_directory")
self.game_directory = self.clean_game_directory(self._config.get(
"Watcher", "game_directory"))
else:
self.game_directory = find_lostark_directory()
changes = True
Expand Down Expand Up @@ -177,7 +178,7 @@ def update_config_file(self):
"Watcher", "upload_threads", self.upload_threads
)
self.set_or_remove_config_option(
"Watcher", "game_directory", self.game_directory
"Watcher", "game_directory", self.clean_game_directory(self.game_directory)
)
self.set_or_remove_config_option(
"Watcher", "screenshots_directory", self.screenshots_directory
Expand Down Expand Up @@ -223,6 +224,9 @@ def update_config(self, new_config):
self.open_log_on_start = new_config["open_log_on_start"]
self.update_config_file()

def clean_game_directory(self, game_directory):
return re.sub(r'EFGame[/\\]?(Screenshots[/\\]?)?$', '', game_directory)

def get_game_region(self):
try:
tree = ET.parse(os.path.abspath(os.path.join(
Expand Down