33
33
# :issue:`45440`
34
34
BPO_ROLE_REGEX = re .compile (r":issue:`(\d+)`" )
35
35
36
+ logger = logging .getLogger (__name__ )
37
+
36
38
37
39
@cache
38
40
def redirect (client : httpx .Client , bpo_number : int ) -> str :
39
41
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 )
41
43
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 )
43
45
return str (r .url )
44
46
45
47
@@ -74,15 +76,15 @@ def do_lines(old_lines: list[str], filename: str) -> list[str]:
74
76
ms = BPO_URL_REGEX .findall (line .strip ())
75
77
new_line = line
76
78
for m in ms :
77
- logging .info ("Old line:\t %s" , line .rstrip ())
79
+ logger .info ("Old line:\t %s" , line .rstrip ())
78
80
# 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)
80
82
bpo_number = int (m )
81
- logging .info ("BPO number:\t %d" , bpo_number )
83
+ logger .info ("BPO number:\t %d" , bpo_number )
82
84
83
85
gh_link = redirect (client , bpo_number )
84
86
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 ())
86
88
87
89
if line != new_line :
88
90
changes += 1
@@ -92,18 +94,18 @@ def do_lines(old_lines: list[str], filename: str) -> list[str]:
92
94
ms = BPO_ROLE_REGEX .findall (line .strip ())
93
95
new_line = line
94
96
for m in ms :
95
- logging .info ("Old line:\t %s" , line .rstrip ())
97
+ logger .info ("Old line:\t %s" , line .rstrip ())
96
98
# bpo_role = f":issue:`{m}`"
97
- # logging .info("BPO link:\t%s", bpo_role)
99
+ # logger .info("BPO link:\t%s", bpo_role)
98
100
bpo_number = int (m )
99
- logging .info ("BPO number:\t %d" , bpo_number )
101
+ logger .info ("BPO number:\t %d" , bpo_number )
100
102
101
103
gh_link = redirect (client , bpo_number )
102
104
gh_number = gh_link .split ("/" )[- 1 ]
103
105
new_role = f":gh:`{ gh_number } `"
104
- logging .info ("New role:\t %s" , new_role )
106
+ logger .info ("New role:\t %s" , new_role )
105
107
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 ())
107
109
108
110
if line != new_line :
109
111
changes += 1
@@ -135,7 +137,7 @@ def do_file_or_path(file_or_path: str, dry_run: bool = False) -> None:
135
137
else :
136
138
for p in sorted (Path (file_or_path ).rglob ("*" )):
137
139
if p .suffix in (".py" , ".rst" , ".txt" ) and p .is_file ():
138
- logging .info (p )
140
+ logger .info (p )
139
141
do_file (str (p ), dry_run )
140
142
# print()
141
143
@@ -168,7 +170,7 @@ def main() -> None:
168
170
169
171
do_file_or_path (args .input , args .dry_run )
170
172
171
- logging .info (redirect .cache_info ())
173
+ logger .info (redirect .cache_info ())
172
174
173
175
174
176
if __name__ == "__main__" :
0 commit comments