Store config in APPDATA directory
This commit is contained in:
+11
-3
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user