23
23
# check file's api_label
24
24
def check_api_label (rootdir , file ):
25
25
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 :
27
27
first_line = f .readline ().strip ()
28
28
return first_line == generate_en_label_by_path (file )
29
29
@@ -53,13 +53,13 @@ def find_all_api_labels_in_dir(rootdir):
53
53
# api_labels in a file
54
54
def find_api_labels_in_one_file (file_path ):
55
55
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 :
57
57
lines = f .readlines ()
58
58
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 :
61
61
continue
62
- api_labels_in_one_file .append (line .group (1 ))
62
+ api_labels_in_one_file .append (match .group (1 ))
63
63
return api_labels_in_one_file
64
64
65
65
@@ -84,7 +84,7 @@ def run_cn_api_label_checking(rootdir, files):
84
84
for file in files :
85
85
if not file .endswith (".rst" ):
86
86
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 :
88
88
pattern = f .read ()
89
89
matches = re .findall (r":ref:`([^`]+)`" , pattern )
90
90
for match in matches :
0 commit comments