2020-06-04 19:16:51 +02:00
|
|
|
import logging
|
2020-06-03 19:41:30 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import appdirs
|
|
|
|
|
2020-06-06 02:00:16 +02:00
|
|
|
log = logging.getLogger("tuxbot.core.data_manager")
|
2020-06-04 19:16:51 +02:00
|
|
|
|
2020-06-03 19:41:30 +02:00
|
|
|
app_dir = appdirs.AppDirs("Tuxbot-bot")
|
|
|
|
config_dir = Path(app_dir.user_config_dir)
|
2020-09-02 00:08:06 +02:00
|
|
|
config_file = config_dir / "config.yaml"
|
2020-06-03 19:41:30 +02:00
|
|
|
|
|
|
|
|
2020-06-04 16:36:22 +02:00
|
|
|
def data_path(instance_name: str) -> Path:
|
2020-06-04 00:46:53 +02:00
|
|
|
"""Return Path for data configs.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
instance_name:str
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
Path
|
|
|
|
Generated path for data configs.
|
|
|
|
"""
|
2020-06-03 19:41:30 +02:00
|
|
|
return Path(app_dir.user_data_dir) / "data" / instance_name
|
|
|
|
|
|
|
|
|
2020-06-04 16:36:22 +02:00
|
|
|
def core_path(instance_name: str) -> Path:
|
2020-06-04 00:46:53 +02:00
|
|
|
"""Return Path for core configs.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
instance_name:str
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
Path
|
|
|
|
Generated path for core configs.
|
|
|
|
"""
|
2020-06-04 16:36:22 +02:00
|
|
|
return data_path(instance_name) / "data" / instance_name / "core"
|
2020-06-03 19:41:30 +02:00
|
|
|
|
|
|
|
|
2020-06-04 16:36:22 +02:00
|
|
|
def cogs_data_path(instance_name: str) -> Path:
|
2020-06-04 00:46:53 +02:00
|
|
|
"""Return Path for cogs configs.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
instance_name:str
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
Path
|
|
|
|
Generated path for cogs configs.
|
|
|
|
"""
|
2020-06-04 16:36:22 +02:00
|
|
|
return data_path(instance_name) / "data" / instance_name / "cogs"
|
2020-06-03 19:41:30 +02:00
|
|
|
|
|
|
|
|
2020-06-04 16:36:22 +02:00
|
|
|
def cog_data_path(instance_name: str, cog_name: str) -> Path:
|
2020-06-04 00:46:53 +02:00
|
|
|
"""Return Path for chosen configs for cog.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
instance_name:str
|
|
|
|
cog_name:str
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
Path
|
|
|
|
Generated path for cog's configs.
|
|
|
|
"""
|
2020-06-04 16:36:22 +02:00
|
|
|
return data_path(instance_name) / "data" / instance_name / "cogs" / cog_name
|
2020-06-05 00:29:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
def logs_data_path(instance_name: str) -> Path:
|
|
|
|
"""Return Path for logs.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
instance_name:str
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
Path
|
|
|
|
Generated path for logs files.
|
|
|
|
"""
|
2020-06-11 19:43:00 +02:00
|
|
|
return data_path(instance_name) / "logs"
|