@@ -379,17 +379,21 @@ def check_changelog_file(self):
379
379
self .edit_changelog ()
380
380
381
381
@staticmethod
382
- def get_need_dependency ():
382
+ def get_need_dependency () -> List [ str ] :
383
383
template_path = Path ('tools/azure-sdk-tools/packaging_tools/templates/setup.py' )
384
+ items = ["msrest>" , "azure-mgmt-core" , "typing_extensions" ]
384
385
with open (template_path , 'r' ) as fr :
385
386
content = fr .readlines ()
386
- for line in content :
387
- if 'msrest>' in line :
388
- target_msrest = line .strip ().strip (',' ).strip ('\' ' )
389
- yield target_msrest
390
- if 'azure-mgmt-core' in line :
391
- target_mgmt_core = line .strip ().strip (',' ).strip ('\' ' )
392
- yield target_mgmt_core
387
+ dependencies = []
388
+ for i in range (len (content )):
389
+ if "install_requires" not in content [i ]:
390
+ continue
391
+ for j in range (i , len (content )):
392
+ for item in items :
393
+ if item in content [j ]:
394
+ dependencies .append (content [j ].strip ().strip (',' ).strip ('\" ' ))
395
+ break
396
+ return dependencies
393
397
394
398
@staticmethod
395
399
def insert_line_num (content : List [str ]) -> int :
@@ -404,24 +408,22 @@ def insert_line_num(content: List[str]) -> int:
404
408
def check_ci_file_proc (self , dependency : str ):
405
409
def edit_ci_file (content : List [str ]):
406
410
new_line = f'#override azure-mgmt-{ self .package_name } { dependency } '
407
- dependency_name = dependency . split ( '>' )[0 ]
411
+ dependency_name = re . compile ( "[a-zA-Z-_]*" ). findall ( dependency )[0 ]
408
412
for i in range (len (content )):
409
413
if new_line in content [i ]:
410
414
return
411
415
if f'azure-mgmt-{ self .package_name } { dependency_name } ' in content [i ]:
412
416
content [i ] = new_line + '\n '
413
417
return
414
- prefix = '' if '\n ' in content [- 1 ] else '\n '
415
- content .insert (self .insert_line_num (content ), prefix + new_line + '\n ' )
418
+ content .insert (self .insert_line_num (content ), new_line + '\n ' )
416
419
417
420
modify_file (str (Path ('shared_requirements.txt' )), edit_ci_file )
418
421
print_exec ('git add shared_requirements.txt' )
419
422
420
423
def check_ci_file (self ):
421
- # eg: target_msrest = 'msrest>=0.6.21', target_mgmt_core = 'azure-mgmt-core>=1.3.0,<2.0.0'
422
- target_msrest , target_mgmt_core = list (self .get_need_dependency ())
423
- self .check_ci_file_proc (target_msrest )
424
- self .check_ci_file_proc (target_mgmt_core )
424
+ # eg: 'msrest>=0.6.21', 'azure-mgmt-core>=1.3.0,<2.0.0'
425
+ for item in self .get_need_dependency ():
426
+ self .check_ci_file_proc (item )
425
427
426
428
def check_dev_requirement (self ):
427
429
file = Path (f'sdk/{ self .sdk_folder } /azure-mgmt-{ self .package_name } /dev_requirements.txt' )
0 commit comments