Fix pep8 issues, move hostname declaration out of loop
This commit is contained in:
parent
e2ada2684b
commit
b5370aef70
|
@ -73,16 +73,14 @@ def get_site_alt(link: str) -> str:
|
||||||
str: An updated (or ignored) result link
|
str: An updated (or ignored) result link
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for site_key in SITE_ALTS.keys():
|
|
||||||
if site_key not in link:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Need to replace full hostname with alternative to encapsulate
|
# Need to replace full hostname with alternative to encapsulate
|
||||||
# subdomains as well
|
# subdomains as well
|
||||||
|
|
||||||
hostname = urlparse.urlparse(link).hostname
|
hostname = urlparse.urlparse(link).hostname
|
||||||
|
|
||||||
|
for site_key in SITE_ALTS.keys():
|
||||||
|
if not hostname or site_key not in hostname:
|
||||||
|
continue
|
||||||
|
|
||||||
link = link.replace(hostname, SITE_ALTS[site_key])
|
link = link.replace(hostname, SITE_ALTS[site_key])
|
||||||
for prefix in SKIP_PREFIX:
|
for prefix in SKIP_PREFIX:
|
||||||
link = link.replace(prefix, '//')
|
link = link.replace(prefix, '//')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user