3333# :issue:`45440`
3434BPO_ROLE_REGEX = re .compile (r":issue:`(\d+)`" )
3535
36+ logger = logging .getLogger (__name__ )
37+
3638
3739@cache
3840def redirect (client : httpx .Client , bpo_number : int ) -> str :
3941 redirect_link = f"https://bugs.python.org/issue?@action=redirect&bpo={ bpo_number } "
40- logging .info ("Redirect link:\t %s" , redirect_link )
42+ logger .info ("Redirect link:\t %s" , redirect_link )
4143 r = client .get (redirect_link , follow_redirects = True )
42- logging .info ("GitHub link:\t %s" , r .url )
44+ logger .info ("GitHub link:\t %s" , r .url )
4345 return str (r .url )
4446
4547
@@ -74,15 +76,15 @@ def do_lines(old_lines: list[str], filename: str) -> list[str]:
7476 ms = BPO_URL_REGEX .findall (line .strip ())
7577 new_line = line
7678 for m in ms :
77- logging .info ("Old line:\t %s" , line .rstrip ())
79+ logger .info ("Old line:\t %s" , line .rstrip ())
7880 # bpo_link = f"https://bugs.python.org/issue{m}"
79- # logging .info("BPO link:\t%s", bpo_link)
81+ # logger .info("BPO link:\t%s", bpo_link)
8082 bpo_number = int (m )
81- logging .info ("BPO number:\t %d" , bpo_number )
83+ logger .info ("BPO number:\t %d" , bpo_number )
8284
8385 gh_link = redirect (client , bpo_number )
8486 new_line = BPO_URL_REGEX .sub (gh_link , new_line , count = 1 )
85- logging .info ("New line:\t %s" , new_line .rstrip ())
87+ logger .info ("New line:\t %s" , new_line .rstrip ())
8688
8789 if line != new_line :
8890 changes += 1
@@ -92,18 +94,18 @@ def do_lines(old_lines: list[str], filename: str) -> list[str]:
9294 ms = BPO_ROLE_REGEX .findall (line .strip ())
9395 new_line = line
9496 for m in ms :
95- logging .info ("Old line:\t %s" , line .rstrip ())
97+ logger .info ("Old line:\t %s" , line .rstrip ())
9698 # bpo_role = f":issue:`{m}`"
97- # logging .info("BPO link:\t%s", bpo_role)
99+ # logger .info("BPO link:\t%s", bpo_role)
98100 bpo_number = int (m )
99- logging .info ("BPO number:\t %d" , bpo_number )
101+ logger .info ("BPO number:\t %d" , bpo_number )
100102
101103 gh_link = redirect (client , bpo_number )
102104 gh_number = gh_link .split ("/" )[- 1 ]
103105 new_role = f":gh:`{ gh_number } `"
104- logging .info ("New role:\t %s" , new_role )
106+ logger .info ("New role:\t %s" , new_role )
105107 new_line = BPO_ROLE_REGEX .sub (new_role , new_line , count = 1 )
106- logging .info ("New line:\t %s" , new_line .rstrip ())
108+ logger .info ("New line:\t %s" , new_line .rstrip ())
107109
108110 if line != new_line :
109111 changes += 1
@@ -135,7 +137,7 @@ def do_file_or_path(file_or_path: str, dry_run: bool = False) -> None:
135137 else :
136138 for p in sorted (Path (file_or_path ).rglob ("*" )):
137139 if p .suffix in (".py" , ".rst" , ".txt" ) and p .is_file ():
138- logging .info (p )
140+ logger .info (p )
139141 do_file (str (p ), dry_run )
140142 # print()
141143
@@ -168,7 +170,7 @@ def main() -> None:
168170
169171 do_file_or_path (args .input , args .dry_run )
170172
171- logging .info (redirect .cache_info ())
173+ logger .info (redirect .cache_info ())
172174
173175
174176if __name__ == "__main__" :
0 commit comments