File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -160,23 +160,27 @@ def process_result(self, result: CheckResult) -> None:
160160 )
161161 self .broken_hyperlinks += 1
162162 case _Status .REDIRECTED :
163- try :
164- text , color = {
165- 301 : ('permanently' , purple ),
166- 302 : ('with Found' , purple ),
167- 303 : ('with See Other' , purple ),
168- 307 : ('temporarily' , turquoise ),
169- 308 : ('permanently' , purple ),
170- }[result .code ]
171- except KeyError :
172- text , color = ('with unknown code' , purple )
163+ match result .code :
164+ case 301 :
165+ text = 'permanently'
166+ case 302 :
167+ text = 'with Found'
168+ case 303 :
169+ text = 'with See Other'
170+ case 307 :
171+ text = 'temporarily'
172+ case 308 :
173+ text = 'permanently'
174+ case _:
175+ text = 'with unknown code'
173176 linkstat ['text' ] = text
174177 redirection = f'{ text } to { result .message } '
175178 if self .config .linkcheck_allowed_redirects :
176179 msg = f'redirect { result .uri } - { redirection } '
177180 logger .warning (msg , location = (result .docname , result .lineno ))
178181 else :
179- msg = color ('redirect ' ) + result .uri + color (' - ' + redirection )
182+ colour = turquoise if result .code == 307 else purple
183+ msg = colour ('redirect ' ) + result .uri + colour (' - ' + redirection )
180184 logger .info (msg )
181185 self .write_entry (
182186 f'redirected { text } ' ,
You can’t perform that action at this time.
0 commit comments