implemented base dir for all files

This commit is contained in:
Hellow 2024-02-13 21:43:29 +01:00
parent 61536240f3
commit d19406d3b4
4 changed files with 10 additions and 16 deletions

View File

@ -1,7 +0,0 @@
from pathlib import Path
import json
import logging
import toml
from .utils import config

View File

@ -3,12 +3,12 @@ from pathlib import Path
from mastodon import Mastodon
from . import Feed
from ..utils import PROGRAM_NAME, prompt, config
from ..utils import PROGRAM_DATA_DIR, prompt, config
class MastodonFeed(Feed):
__config_name__ = "mastodon"
CLIENTCRED_PATH: Path = config.CONFIG_PATH.joinpath("mastodon_clientcred.secret")
CLIENTCRED_PATH: Path = PROGRAM_DATA_DIR.joinpath("mastodon_clientcred.secret")
@classmethod
def prompt_auth(cls) -> dict:

View File

@ -1,9 +1,12 @@
import logging
import platformdirs
logging.basicConfig(level=logging.INFO)
PROGRAM_NAME: str = "publish-meetups"
PROGRAM_DATA_DIR: str = platformdirs.user_config_path(appname=PROGRAM_NAME)
PROGRAM_DATA_DIR.mkdir(parents=True, exist_ok=True)
__all__ = ["prompt", "CONFIG_PATH", "PROGRAM_NAME", "errors", "config"]
__all__ = ["prompt", "PROGRAM_DATA_DIR", "PROGRAM_NAME", "errors", "config"]

View File

@ -3,7 +3,7 @@ import logging
import toml
import platformdirs
from . import PROGRAM_NAME
from . import PROGRAM_DATA_DIR, PROGRAM_NAME
logger = logging.getLogger("config")
_config: dict = {
@ -17,9 +17,7 @@ _config: dict = {
}
CONFIG_PATH = platformdirs.user_config_path(appname=PROGRAM_NAME)
CONFIG_PATH.mkdir(parents=True, exist_ok=True)
CONFIG_FILE = CONFIG_PATH / f"{PROGRAM_NAME}.toml"
CONFIG_FILE = PROGRAM_DATA_DIR / f"{PROGRAM_NAME}.toml"
logger.info(f"Config file: {CONFIG_FILE}")