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
978147ca
Unverified
Commit
978147ca
authored
Jan 12, 2022
by
Matheus Felipe
Browse files
Check if a list of links are working
parent
a707c4b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/validate/links.py
View file @
978147ca
...
...
@@ -132,6 +132,17 @@ def check_if_link_is_working(link: str) -> Tuple[bool, str]:
return
(
has_error
,
error_message
)
def
check_if_list_of_links_are_working
(
list_of_links
:
List
[
str
])
->
List
[
str
]:
error_messages
=
[]
for
link
in
list_of_links
:
has_error
,
error_message
=
check_if_link_is_working
(
link
)
if
has_error
:
error_messages
.
append
(
error_message
)
return
error_messages
if
__name__
==
'__main__'
:
num_args
=
len
(
sys
.
argv
)
...
...
@@ -147,5 +158,14 @@ if __name__ == '__main__':
if
has_duplicate_link
:
print
(
f
'Found duplicate links:
{
duplicates_links
}
'
)
sys
.
exit
(
1
)
else
:
print
(
'No duplicate links.'
)
print
(
f
'Checking if
{
len
(
links
)
}
links are working...'
)
errors
=
check_if_list_of_links_are_working
(
links
)
if
errors
:
for
error_message
in
errors
:
print
(
error_message
)
sys
.
exit
(
1
)
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