Store config in APPDATA directory

This commit is contained in:
Wiktor Mazur
2020-10-11 16:20:43 +02:00
parent 1497473e7b
commit 86478d7d81
3 changed files with 12 additions and 3 deletions
View File
+11 -3
View File
@@ -1,4 +1,5 @@
import os import os
import platform
import sys import sys
import toml import toml
@@ -30,15 +31,22 @@ _script_path = sys.argv[0]
_config = None _config = None
def get_config_path():
cfg_file_name = 'albion-online-stats.cfg'
script_dir = os.path.dirname(_script_path)
if platform.system() == 'Windows':
return os.path.join(os.getenv('APPDATA', script_dir), cfg_file_name)
else:
return os.path.join(script_dir, cfg_file_name)
def config(): def config():
global _script_path
global _config global _config
if _config: if _config:
return _config return _config
conf_file = os.path.join(os.path.dirname( conf_file = get_config_path()
_script_path), 'albion-online-stats.cfg')
try: try:
with open(conf_file, "r") as cfg_file: with open(conf_file, "r") as cfg_file:
+1
View File
@@ -28,6 +28,7 @@ commands =
python -m pytest tests python -m pytest tests
[testenv:dev] [testenv:dev]
passenv = APPDATA
deps = deps =
--editable=file:///{toxinidir}/../aoaddons-python --editable=file:///{toxinidir}/../aoaddons-python
pyside2~=5.13 pyside2~=5.13