Add the ability to specify a config directory
This commit is contained in:
parent
23f323f52d
commit
f3f48ea958
@ -95,6 +95,10 @@ def rotate(handler: logging.handlers.RotatingFileHandler, filename: pathlib.Path
|
||||
|
||||
|
||||
def ctmain():
|
||||
opts = Options()
|
||||
opts.parse_cmd_line_args()
|
||||
SETTINGS = ComicTaggerSettings(opts.config_path)
|
||||
|
||||
os.makedirs(ComicTaggerSettings.get_settings_folder() / "logs", exist_ok=True)
|
||||
stream_handler = logging.StreamHandler()
|
||||
stream_handler.setLevel(logging.WARNING)
|
||||
@ -111,11 +115,7 @@ def ctmain():
|
||||
format="%(asctime)s | %(name)s | %(levelname)s | %(message)s",
|
||||
datefmt="%Y-%m-%dT%H:%M:%S",
|
||||
)
|
||||
opts = Options()
|
||||
opts.parse_cmd_line_args()
|
||||
|
||||
# Need to load setting before anything else
|
||||
SETTINGS = ComicTaggerSettings()
|
||||
|
||||
# manage the CV API key
|
||||
if opts.cv_api_key:
|
||||
|
@ -28,13 +28,16 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ComicTaggerSettings:
|
||||
folder = ""
|
||||
|
||||
@staticmethod
|
||||
def get_settings_folder():
|
||||
if platform.system() == "Windows":
|
||||
folder = os.path.join(os.environ["APPDATA"], "ComicTagger")
|
||||
else:
|
||||
folder = os.path.join(os.path.expanduser("~"), ".ComicTagger")
|
||||
return pathlib.Path(folder)
|
||||
if not ComicTaggerSettings.folder:
|
||||
if platform.system() == "Windows":
|
||||
ComicTaggerSettings.folder = os.path.join(os.environ["APPDATA"], "ComicTagger")
|
||||
else:
|
||||
ComicTaggerSettings.folder = os.path.join(os.path.expanduser("~"), ".ComicTagger")
|
||||
return pathlib.Path(ComicTaggerSettings.folder)
|
||||
|
||||
@staticmethod
|
||||
def base_dir():
|
||||
@ -123,10 +126,9 @@ class ComicTaggerSettings:
|
||||
self.remove_archive_after_successful_match = False
|
||||
self.wait_and_retry_on_rate_limit = False
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, folder):
|
||||
|
||||
self.settings_file = ""
|
||||
self.folder = ""
|
||||
# General Settings
|
||||
self.rar_exe_path = ""
|
||||
self.allow_cbi_in_rar = True
|
||||
@ -197,12 +199,15 @@ class ComicTaggerSettings:
|
||||
self.wait_and_retry_on_rate_limit = False
|
||||
|
||||
self.config = configparser.RawConfigParser()
|
||||
self.folder = ComicTaggerSettings.get_settings_folder()
|
||||
if folder:
|
||||
ComicTaggerSettings.folder = pathlib.Path(folder)
|
||||
else:
|
||||
ComicTaggerSettings.folder = ComicTaggerSettings.get_settings_folder()
|
||||
|
||||
if not os.path.exists(self.folder):
|
||||
os.makedirs(self.folder)
|
||||
if not os.path.exists(ComicTaggerSettings.folder):
|
||||
os.makedirs(ComicTaggerSettings.folder)
|
||||
|
||||
self.settings_file = os.path.join(self.folder, "settings")
|
||||
self.settings_file = os.path.join(ComicTaggerSettings.folder, "settings")
|
||||
|
||||
# if config file doesn't exist, write one out
|
||||
if not os.path.exists(self.settings_file):
|
||||
|
@ -130,6 +130,11 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
|
||||
self.immediate_autoselect = autoselect
|
||||
self.cover_index_list = cover_index_list
|
||||
self.cv_search_results = None
|
||||
self.ii = None
|
||||
self.iddialog = None
|
||||
self.id_thread = None
|
||||
self.progdialog = None
|
||||
self.search_thread = None
|
||||
|
||||
self.use_filter = self.settings.always_use_publisher_filter
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user