squirrel-battle/squirrelbattle/resources.py

25 lines
792 B
Python
Raw Permalink Normal View History

2021-01-10 09:46:17 +00:00
# Copyright (C) 2020-2021 by ÿnérant, eichhornchen, nicomarg, charlse
2020-11-27 15:33:17 +00:00
# SPDX-License-Identifier: GPL-3.0-or-later
2020-11-19 01:49:59 +00:00
from pathlib import Path
class ResourceManager:
"""
The ResourceManager loads resources at their right place,
and stores files in config directory.
"""
BASE_DIR = Path(__file__).resolve().parent / 'assets'
# FIXME This might not work on not-UNIX based systems.
CONFIG_DIR = Path.home() / '.config' / 'squirrel-battle'
2020-11-19 01:49:59 +00:00
@classmethod
def get_asset_path(cls, filename: str) -> str:
return str(cls.BASE_DIR / filename)
@classmethod
def get_config_path(cls, filename: str) -> str:
cls.CONFIG_DIR.mkdir(parents=True) if not cls.CONFIG_DIR.is_dir() \
else None
return str(cls.CONFIG_DIR / filename)