Add src/__init__.py
This commit is contained in:
36
src/__init__.py
Normal file
36
src/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from .utils.icon import Icon
|
||||||
|
|
||||||
|
__version__ = "1.0.0"
|
||||||
|
__author__ = "Alexander Kirchner"
|
||||||
|
__all__ = ["Icon", "__author__", "__version__", "settings"]
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
from appdirs import AppDirs
|
||||||
|
|
||||||
|
from config import Config
|
||||||
|
|
||||||
|
app = AppDirs("SemesterApparatsManager", "SAM")
|
||||||
|
LOG_DIR: str = app.user_log_dir # type: ignore
|
||||||
|
CONFIG_DIR: str = app.user_config_dir # type: ignore
|
||||||
|
if not Path(LOG_DIR).exists(): # type: ignore
|
||||||
|
os.makedirs(LOG_DIR) # type: ignore
|
||||||
|
if not Path(CONFIG_DIR).exists(): # type: ignore
|
||||||
|
os.makedirs(CONFIG_DIR) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
settings = Config(f"{CONFIG_DIR}/config.yaml")
|
||||||
|
DATABASE_DIR: Union[Path, str] = ( # type: ignore
|
||||||
|
app.user_config_dir if settings.database.path is None else settings.database.path # type: ignore
|
||||||
|
)
|
||||||
|
if not Path(DATABASE_DIR).exists(): # type: ignore
|
||||||
|
os.makedirs(DATABASE_DIR) # type: ignore
|
||||||
|
first_launch = settings.exists
|
||||||
|
if not Path(settings.database.temp.expanduser()).exists(): # type: ignore
|
||||||
|
settings.database.temp.expanduser().mkdir(parents=True, exist_ok=True) # type: ignore
|
||||||
|
|
||||||
|
if not Path("logs").exists():
|
||||||
|
Path("logs").mkdir(exist_ok=True)
|
||||||
|
# open and close the file to create it
|
||||||
Reference in New Issue
Block a user