Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
public-apis
Commits
95ee7981
Unverified
Commit
95ee7981
authored
Jan 12, 2022
by
Matheus Felipe
Browse files
Remove whitespaces
parent
7be0512b
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/validate/links.py
View file @
95ee7981
...
@@ -90,7 +90,7 @@ def get_host_from_link(link: str) -> str:
...
@@ -90,7 +90,7 @@ def get_host_from_link(link: str) -> str:
def
check_if_link_is_working
(
link
:
str
)
->
Tuple
[
bool
,
str
]:
def
check_if_link_is_working
(
link
:
str
)
->
Tuple
[
bool
,
str
]:
"""Checks if a link is working.
"""Checks if a link is working.
If an error is identified when the request for the link occurs,
If an error is identified when the request for the link occurs,
the return will be a tuple with the first value True and the second
the return will be a tuple with the first value True and the second
value a string containing the error message.
value a string containing the error message.
...
@@ -116,11 +116,11 @@ def check_if_link_is_working(link: str) -> Tuple[bool, str]:
...
@@ -116,11 +116,11 @@ def check_if_link_is_working(link: str) -> Tuple[bool, str]:
except
(
TimeoutError
,
requests
.
exceptions
.
ConnectTimeout
):
except
(
TimeoutError
,
requests
.
exceptions
.
ConnectTimeout
):
has_error
=
True
has_error
=
True
error_message
=
f
'ERR:TMO:
{
link
}
'
error_message
=
f
'ERR:TMO:
{
link
}
'
except
requests
.
exceptions
.
SSLError
as
error
:
except
requests
.
exceptions
.
SSLError
as
error
:
has_error
=
True
has_error
=
True
error_message
=
f
'ERR:SSL:
{
error
}
:
{
link
}
'
error_message
=
f
'ERR:SSL:
{
error
}
:
{
link
}
'
except
requests
.
exceptions
.
TooManyRedirects
as
error
:
except
requests
.
exceptions
.
TooManyRedirects
as
error
:
has_error
=
True
has_error
=
True
error_message
=
f
'ERR:TMR:
{
error
}
:
{
link
}
'
error_message
=
f
'ERR:TMR:
{
error
}
:
{
link
}
'
...
@@ -128,7 +128,7 @@ def check_if_link_is_working(link: str) -> Tuple[bool, str]:
...
@@ -128,7 +128,7 @@ def check_if_link_is_working(link: str) -> Tuple[bool, str]:
except
Exception
as
error
:
except
Exception
as
error
:
has_error
=
True
has_error
=
True
error_message
=
f
'ERR:UKN:
{
error
}
:
{
link
}
'
error_message
=
f
'ERR:UKN:
{
error
}
:
{
link
}
'
return
(
has_error
,
error_message
)
return
(
has_error
,
error_message
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment