forked from coderwilson/FFX_TAS_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
31 lines (25 loc) · 891 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import logging
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
logger = logging.getLogger(__name__)
# TODO: Make this be set by an argument instead
CONFIG_FILE_PATH = "config.yaml"
# TODO: It's not ideal to open this file many times over, but also not a huge problem
def open_config():
# Open the config file and parse the yaml contents
try:
with open(CONFIG_FILE_PATH) as config_file:
try:
return yaml.load(config_file, Loader=Loader)
except Exception as E:
logger.error(f"Error: Failed to parse config file {CONFIG_FILE_PATH}")
logger.exception(E)
return {}
except Exception as E:
logger.info(
f"Didn't find config file {CONFIG_FILE_PATH}, using default values for run."
)
return {}