moved from os to pathlib

This commit is contained in:
Firq 2023-10-02 15:55:13 +02:00
parent 6713d4658b
commit a8bc73c532
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
3 changed files with 6 additions and 8 deletions

View file

@ -1,5 +1,5 @@
# pylint: disable=too-few-public-methods
import os
from pathlib import Path
import __main__
class DefaultSettings:
@ -26,5 +26,4 @@ class DefaultSettings:
'description': 'Support Organizer for FGO'
}
}
FILE_SAVE_DIRECTORY = f"{os.path.dirname(__main__.__file__)}/temp"
FILE_SAVE_DIRECTORY = Path(__main__.__file__).parent / "temp"

View file

@ -1,6 +1,6 @@
# pylint: disable=too-few-public-methods
import os
from pathlib import Path
import __main__
class DatabaseSettings:
DATABASE_DIRECTORY = f"{os.path.dirname(__main__.__file__)}/database/storage"
DATABASE_DIRECTORY = Path(__main__.__file__).parent / "database/storage"

View file

@ -1,6 +1,5 @@
# pylint: disable=too-few-public-methods
import os
import dictdatabase as DDB
from config.db_settings import DatabaseSettings
@ -13,8 +12,8 @@ class Database:
"""
__instance = None
db = DDB
if not os.path.isdir(DatabaseSettings.DATABASE_DIRECTORY):
os.mkdir(DatabaseSettings.DATABASE_DIRECTORY)
if not DatabaseSettings.DATABASE_DIRECTORY.is_dir():
DatabaseSettings.DATABASE_DIRECTORY.mkdir()
db.config.storage_directory = DatabaseSettings.DATABASE_DIRECTORY
if not db.at("requests").exists():
db.at("requests").create({})