@@ -27,41 +27,42 @@ def run():
27
27
cwd = pathlib .Path (args .cwd )
28
28
29
29
sources = []
30
- if configs [ "sources" ] is None :
30
+ if ( config_sources := configs . get ( "sources" )) is None :
31
31
logger .error ("Please Specify the sources field in config file" )
32
32
exit (1 )
33
- for i in configs [ "sources" ] :
33
+ for i in config_sources :
34
34
sources .extend ([j for j in cwd .glob (i )])
35
35
36
36
headers = []
37
- if configs [ "headers" ] is None :
37
+ if ( config_headers := configs . get ( "headers" )) is None :
38
38
logger .error ("Please Specify the headers field in config file" )
39
39
exit (1 )
40
- for i in configs [ "headers" ] :
40
+ for i in config_headers :
41
41
headers .extend ([j for j in cwd .glob (i )])
42
42
43
- if configs [ "output_dir" ] is None :
43
+ if ( config_output_dir := configs . get ( "output_dir" )) is None :
44
44
logger .error ("Please Specify the output_dir field in config file" )
45
45
exit (1 )
46
- output_dir = cwd .joinpath (configs [ "output_dir" ] )
46
+ output_dir = cwd .joinpath (config_output_dir )
47
47
48
48
cppygen = Parser (
49
- namespace = configs ["search_namespace" ], library_file = configs ["libclang_path" ]
49
+ namespace = configs .get ("search_namespace" ),
50
+ library_file = configs .get ("libclang_path" ),
50
51
)
51
52
52
- flags = configs [ "flags" ] or []
53
+ flags = configs . get ( "flags" ) or []
53
54
54
- for i in configs [ "include_directories" ] or []:
55
+ for i in configs . get ( "include_directories" ) or []:
55
56
flags .append (f"-I{ str (cwd .joinpath (i ).absolute ())} " )
56
57
print (f"-I{ str (cwd .joinpath (i ).absolute ())} " )
57
58
58
59
for i in sources :
59
- cppygen .parse_from_file (i , lang = "cpp" , flags = configs [ "flags" ])
60
+ cppygen .parse_from_file (i , lang = "cpp" , flags = configs . get ( "flags" ) or [ ])
60
61
61
62
for i in headers :
62
- cppygen .parse_from_file (i , lang = "hpp" , flags = configs [ "flags" ])
63
+ cppygen .parse_from_file (i , lang = "hpp" , flags = configs . get ( "flags" ) or [ ])
63
64
64
- for i in configs [ "include_headers" ] or []:
65
+ for i in configs . get ( "include_headers" ) or []:
65
66
cppygen .add_hpp_includes (i )
66
67
67
68
with open (str (output_dir ) + "/cppygen_generated.hpp" , "w" ) as f :
0 commit comments