File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed
src/aaz_dev/swagger/model/specs Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,35 @@ def find_data_plane_entry_files(cls, folder):
4545
4646 @classmethod
4747 def _parse_main_tsp (cls , path ):
48- with open (path , 'r' , encoding = 'utf-8' ) as f :
49- lines = f .readlines ()
48+ def expand (import_path ):
49+ with open (import_path , "r" , encoding = "utf-8" ) as f :
50+ lines = f .readlines ()
51+
52+ base = os .path .dirname (import_path )
53+
54+ content = []
55+ for line in lines :
56+ if match := import_pattern .findall (line ):
57+ rel_path = match [0 ]
58+ abs_path = os .path .abspath (os .path .join (base , rel_path ))
59+
60+ if os .path .isfile (abs_path ): # expand first level only; otherwise, will impact performance
61+ with open (abs_path , "r" , encoding = "utf-8" ) as f :
62+ content .append ("" .join (f .readlines ()))
63+
64+ else :
65+ content .append (line )
66+ else :
67+ content .append (line )
68+
69+ return "" .join (content ).split ("\n " )
70+
71+ import_pattern = re .compile (r'^import "([^"]+)"' )
72+
5073 is_mgmt_plane = False
5174 namespace = None
52- for line in lines :
75+
76+ for line in expand (path ):
5377 if line .startswith ("@armProviderNamespace" ):
5478 is_mgmt_plane = True
5579 if line .startswith ("namespace " ):
You can’t perform that action at this time.
0 commit comments