2323# check file's api_label
2424def check_api_label (rootdir , file ):
2525 real_file = Path (rootdir ) / file
26- with open (real_file , "r" , encoding = "utf-8" ) as f :
26+ with real_file . open ("r" , encoding = "utf-8" ) as f :
2727 first_line = f .readline ().strip ()
2828 return first_line == generate_en_label_by_path (file )
2929
@@ -53,13 +53,13 @@ def find_all_api_labels_in_dir(rootdir):
5353# api_labels in a file
5454def find_api_labels_in_one_file (file_path ):
5555 api_labels_in_one_file = []
56- with open (file_path , "r" , encoding = "utf-8" ) as f :
56+ with file_path . open ("r" , encoding = "utf-8" ) as f :
5757 lines = f .readlines ()
5858 for line in lines :
59- line = re .search (".. _([a-zA-Z0-9_]+)" , line )
60- if not line :
59+ match = re .search (".. _([a-zA-Z0-9_]+)" , line )
60+ if not match :
6161 continue
62- api_labels_in_one_file .append (line .group (1 ))
62+ api_labels_in_one_file .append (match .group (1 ))
6363 return api_labels_in_one_file
6464
6565
@@ -84,7 +84,7 @@ def run_cn_api_label_checking(rootdir, files):
8484 for file in files :
8585 if not file .endswith (".rst" ):
8686 continue
87- with open (Path (rootdir ) / file , "r" , encoding = "utf-8" ) as f :
87+ with (Path (rootdir ) / file ). open ( "r" , encoding = "utf-8" ) as f :
8888 pattern = f .read ()
8989 matches = re .findall (r":ref:`([^`]+)`" , pattern )
9090 for match in matches :
0 commit comments