File tree Expand file tree Collapse file tree 1 file changed +27
-8
lines changed Expand file tree Collapse file tree 1 file changed +27
-8
lines changed Original file line number Diff line number Diff line change
1
+ import pdb
2
+
1
3
import yaml
2
4
3
- def readYaml (path ) -> {}:
4
- config = {}
5
- with open (path ) as file :
6
- try :
7
- config = yaml .safe_load (file )
8
- except yaml .YAMLError as exc :
9
- print (exc )
10
- return config
5
+
6
+ class Yaml ():
7
+
8
+ def __init__ (self , path ):
9
+ super (Yaml , self ).__init__ ()
10
+ self .config = self .readYaml (path )
11
+
12
+ def value (self , value : str ):
13
+ def fun (f ):
14
+ values = value .split ("." )
15
+ r_value = None
16
+ for v in values :
17
+ r_value = self .config [v ] if r_value is None else r_value [v ]
18
+ return r_value
19
+
20
+ return fun
21
+
22
+ def readYaml (self , path ) -> {}:
23
+ config = {}
24
+ with open (path ) as file :
25
+ try :
26
+ config = yaml .safe_load (file )
27
+ except yaml .YAMLError as exc :
28
+ print (exc )
29
+ return config
You can’t perform that action at this time.
0 commit comments