88import shutil
99import re
1010import os
11+
1112try :
1213 # py 311 adds this library natively
1314 import tomllib as toml
@@ -67,6 +68,7 @@ def multiapi_combiner(sdk_code_path: str, package_name: str):
6768 )
6869 check_call ("pip install -e ." , shell = True )
6970
71+
7072@return_origin_path
7173def after_multiapi_combiner (sdk_code_path : str , package_name : str , folder_name : str ):
7274 toml_file = Path (sdk_code_path ) / CONF_NAME
@@ -81,12 +83,14 @@ def after_multiapi_combiner(sdk_code_path: str, package_name: str, folder_name:
8183 # azure-mgmt-resource has subfolders
8284 subfolder_path = Path (sdk_code_path ) / package_name .replace ("-" , "/" )
8385 subfolders_name = [s .name for s in subfolder_path .iterdir () if s .is_dir () and not s .name .startswith ("_" )]
84- content ["packaging" ]["exclude_folders" ] = "," .join ([exclude (f"{ package_name } -{ s } " ) for s in subfolders_name ])
86+ content ["packaging" ]["exclude_folders" ] = "," .join (
87+ [exclude (f"{ package_name } -{ s } " ) for s in subfolders_name ]
88+ )
8589
8690 with open (toml_file , "wb" ) as file_out :
8791 tomlw .dump (content , file_out )
8892 call_build_config (package_name , folder_name )
89-
93+
9094 # remove .egg-info to reinstall package
9195 for item in Path (sdk_code_path ).iterdir ():
9296 if item .suffix == ".egg-info" :
@@ -97,14 +101,20 @@ def after_multiapi_combiner(sdk_code_path: str, package_name: str, folder_name:
97101 _LOGGER .info (f"do not find { toml_file } " )
98102
99103
100- def del_outdated_files (readme : str ):
104+ # readme: ../azure-rest-api-specs/specification/paloaltonetworks/resource-manager/readme.md or absolute path
105+ def get_readme_python_content (readme : str ) -> List [str ]:
101106 python_readme = Path (readme ).parent / "readme.python.md"
102107 if not python_readme .exists ():
103108 _LOGGER .info (f"do not find python configuration: { python_readme } " )
104- return
109+ return []
105110
106111 with open (python_readme , "r" ) as file_in :
107- content = file_in .readlines ()
112+ return file_in .readlines ()
113+
114+
115+ # readme: ../azure-rest-api-specs/specification/paloaltonetworks/resource-manager/readme.md
116+ def del_outdated_files (readme : str ):
117+ content = get_readme_python_content (readme )
108118 sdk_folder = extract_sdk_folder (content )
109119 is_multiapi = is_multiapi_package (content )
110120 if sdk_folder :
@@ -150,7 +160,7 @@ def get_related_swagger(readme_content: List[str], tag: str) -> List[str]:
150160
151161
152162def get_last_commit_info (files : List [str ]) -> str :
153- result = [getoutput (f'git log -1 --pretty="format:%ai %H" { f } ' ).strip (' \n ' ) + " " + f for f in files ]
163+ result = [getoutput (f'git log -1 --pretty="format:%ai %H" { f } ' ).strip (" \n " ) + " " + f for f in files ]
154164 result .sort ()
155165 return result [- 1 ]
156166
@@ -199,7 +209,9 @@ def extract_version_info(config: Dict[str, Any]) -> str:
199209def if_need_regenerate (meta : Dict [str , Any ]) -> bool :
200210 with open (str (Path ("../azure-sdk-for-python" , CONFIG_FILE )), "r" ) as file_in :
201211 config = json .load (file_in )
202- current_info = config ["meta" ]["autorest_options" ]["version" ] + "" .join (sorted (config ["meta" ]["autorest_options" ]["use" ]))
212+ current_info = config ["meta" ]["autorest_options" ]["version" ] + "" .join (
213+ sorted (config ["meta" ]["autorest_options" ]["use" ])
214+ )
203215 recorded_info = meta ["autorest" ] + "" .join (sorted (meta ["use" ]))
204216 return recorded_info != current_info
205217
@@ -327,6 +339,8 @@ def main(generate_input, generate_output):
327339 package_entry ["path" ] = [folder_name ]
328340 package_entry [spec_word ] = [input_readme ]
329341 package_entry ["tagIsStable" ] = not judge_tag_preview (sdk_code_path )
342+ readme_python_content = get_readme_python_content (str (Path (spec_folder ) / input_readme ))
343+ package_entry ["isMultiapi" ] = is_multiapi_package (readme_python_content )
330344 result [package_name ] = package_entry
331345 else :
332346 result [package_name ]["path" ].append (folder_name )
0 commit comments