tuxbot-bot/tuxbot/core/data_manager.py

69 lines
1.3 KiB
Python
Raw Normal View History

2020-06-03 19:41:30 +02:00
from pathlib import Path
import appdirs
app_dir = appdirs.AppDirs("Tuxbot-bot")
config_dir = Path(app_dir.user_config_dir)
config_file = config_dir / "config.json"
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
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.
"""
return data_path(instance_name) / "data" / instance_name / "core"
2020-06-03 19:41:30 +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.
"""
return data_path(instance_name) / "data" / instance_name / "cogs"
2020-06-03 19:41:30 +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.
"""
return data_path(instance_name) / "data" / instance_name / "cogs" / cog_name