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
8c28be14
Unverified
Commit
8c28be14
authored
Jan 13, 2022
by
Matheus Felipe
Browse files
Create start_* functions to start checkers
parent
8d590690
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/validate/links.py
View file @
8c28be14
...
@@ -202,14 +202,7 @@ def check_if_list_of_links_are_working(list_of_links: List[str]) -> List[str]:
...
@@ -202,14 +202,7 @@ def check_if_list_of_links_are_working(list_of_links: List[str]) -> List[str]:
return
error_messages
return
error_messages
if
__name__
==
'__main__'
:
def
start_duplicate_links_checker
(
links
:
List
[
str
])
->
None
:
num_args
=
len
(
sys
.
argv
)
if
num_args
<
2
:
print
(
'No .md file passed'
)
sys
.
exit
(
1
)
links
=
find_links_in_file
(
sys
.
argv
[
1
])
print
(
'Checking for duplicate links...'
)
print
(
'Checking for duplicate links...'
)
...
@@ -217,6 +210,7 @@ if __name__ == '__main__':
...
@@ -217,6 +210,7 @@ if __name__ == '__main__':
if
has_duplicate_link
:
if
has_duplicate_link
:
print
(
f
'Found duplicate links:'
)
print
(
f
'Found duplicate links:'
)
for
duplicate_link
in
duplicates_links
:
for
duplicate_link
in
duplicates_links
:
print
(
duplicate_link
)
print
(
duplicate_link
)
...
@@ -224,6 +218,9 @@ if __name__ == '__main__':
...
@@ -224,6 +218,9 @@ if __name__ == '__main__':
else
:
else
:
print
(
'No duplicate links.'
)
print
(
'No duplicate links.'
)
def
start_links_working_checker
(
links
:
List
[
str
])
->
None
:
print
(
f
'Checking if
{
len
(
links
)
}
links are working...'
)
print
(
f
'Checking if
{
len
(
links
)
}
links are working...'
)
errors
=
check_if_list_of_links_are_working
(
links
)
errors
=
check_if_list_of_links_are_working
(
links
)
...
@@ -236,3 +233,23 @@ if __name__ == '__main__':
...
@@ -236,3 +233,23 @@ if __name__ == '__main__':
print
(
error_message
)
print
(
error_message
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
main
(
filename
:
str
)
->
None
:
links
=
find_links_in_file
(
filename
)
start_duplicate_links_checker
(
links
)
start_links_working_checker
(
links
)
if
__name__
==
'__main__'
:
num_args
=
len
(
sys
.
argv
)
if
num_args
<
2
:
print
(
'No .md file passed'
)
sys
.
exit
(
1
)
filename
=
sys
.
argv
[
1
]
main
(
filename
)
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