-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigloader.py
More file actions
26 lines (21 loc) · 769 Bytes
/
configloader.py
File metadata and controls
26 lines (21 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#configloader.py: Script to load the configuration file (config.txt).
#Marjorie Decleir
#Created on 6-08-2019.
#Import the necessary package.
import os
#Define the path to the configuration file.
config_file = os.path.dirname(os.path.realpath(__file__)) + '/config.txt'
#Function to open and read the configuration file.
def load_config():
config = {}
with open(config_file, 'r') as configfile:
for line in configfile:
splitline = line.split(' = ')
key, value = splitline[0].strip(), splitline[1].strip()
if key == "years":
if ', ' in value:
value = value.split(', ')
else:
value = [value]
config[key] = value
return config