flpelerin commited on
Commit
e423ce0
·
1 Parent(s): 53bc8f4

Update file util.py

Browse files
Files changed (1) hide show
  1. util.py +9 -5
util.py CHANGED
@@ -1,18 +1,22 @@
1
- from types import SimpleNamespace
2
  import json
3
 
4
 
5
 
 
 
 
 
 
 
6
  class ConfigParser:
7
  def __init__(self, path: str):
8
  with open(path, 'r') as f:
9
- json_str = f.read()
10
 
11
- config = json.loads(json_str, object_hook=lambda x: SimpleNamespace(**x))
 
12
 
13
- self.path = path
14
  self.config = config
15
- self.json_str = json_str
16
 
17
 
18
 
 
 
1
  import json
2
 
3
 
4
 
5
+
6
+ class Config:
7
+ def __init__(self, data):
8
+ self.__dict__ = data
9
+
10
+
11
  class ConfigParser:
12
  def __init__(self, path: str):
13
  with open(path, 'r') as f:
14
+ json_dict = json.load(f)
15
 
16
+ #config = json.loads(json_str, object_hook=lambda x: SimpleNamespace(**x))
17
+ config = Config(json_dict)
18
 
 
19
  self.config = config
 
20
 
21
 
22