File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -11,27 +11,24 @@ def __init__(self, path) -> None:
11
11
:param path: path to the ab3cfg.sh file, with the filename
12
12
'''
13
13
self .cfgpath = path
14
- self .file = None
15
14
self .vars = None
16
15
self .stage2 = False
17
16
try :
18
- self .file = open (self .cfgpath , 'rt' )
19
- except IOError :
17
+ with open (self .cfgpath , 'rt' ) as cfgfile :
18
+ self .parse (cfgfile )
19
+ except Exception as e :
20
20
# You run ACBS then you should have AB3, eh?
21
21
raise RuntimeError (f'Autobuild3 config file { self .cfgpath } does not exist\n ' +
22
- 'Unable to read Autobuild3 config file.' )
23
- if self .file :
24
- self .parse ()
22
+ 'Unable to read Autobuild3 config file.' ) from e
25
23
26
- def parse (self ):
24
+ def parse (self , file ):
27
25
'''
28
26
Parse the ab3cfg.sh file.
29
27
'''
30
- if self .file :
31
- try :
32
- self .vars = bashvar .eval_bashvar (self .file .read (), filename = self .cfgpath )
33
- except Exception as e :
34
- raise RuntimeError (f'Error parsing autobuild3 config file: { e } .' )
28
+ try :
29
+ self .vars = bashvar .eval_bashvar (file .read (), filename = self .cfgpath )
30
+ except Exception as e :
31
+ raise RuntimeError (f'Error parsing autobuild3 config file: { e } .' ) from e
35
32
36
33
def is_in_stage2 (self ) -> bool :
37
34
'''
You can’t perform that action at this time.
0 commit comments