-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
36 lines (29 loc) · 881 Bytes
/
test.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
32
33
34
35
36
import configparser
import pprint
from ast import literal_eval
class Config:
# stores the loaded config for easy access in any other module
cfg_file = 'config.ini'
config = configparser.ConfigParser()
config.read(cfg_file)
@staticmethod
def get_val(value):
val = value.strip()
# integers
if val.isnumeric():
return int(val)
# booleans
bool_vals = ('True', 'False')
if val in bool_vals:
return val == bool_vals[0]
# fractions
parts = val.split("/")
if len(parts) == 2 and all(i.isdigit() for i in parts):
return int(parts[0]) / int(parts[1])
# all other data types
try: # except strings
return literal_eval(val)
except:
return val
for x in Config.config.items('Feature Selection'):
print(x)