From 8c28be1497a3f64722b7627109b123767afef21f Mon Sep 17 00:00:00 2001 From: Matheus Felipe <50463866+matheusfelipeog@users.noreply.github.com> Date: Thu, 13 Jan 2022 17:49:11 -0300 Subject: [PATCH] Create start_* functions to start checkers --- scripts/validate/links.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/scripts/validate/links.py b/scripts/validate/links.py index efa918ad..d6d47b00 100644 --- a/scripts/validate/links.py +++ b/scripts/validate/links.py @@ -202,14 +202,7 @@ def check_if_list_of_links_are_working(list_of_links: List[str]) -> List[str]: return error_messages -if __name__ == '__main__': - 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]) +def start_duplicate_links_checker(links: List[str]) -> None: print('Checking for duplicate links...') @@ -217,6 +210,7 @@ if __name__ == '__main__': if has_duplicate_link: print(f'Found duplicate links:') + for duplicate_link in duplicates_links: print(duplicate_link) @@ -224,6 +218,9 @@ if __name__ == '__main__': else: print('No duplicate links.') + +def start_links_working_checker(links: List[str]) -> None: + print(f'Checking if {len(links)} links are working...') errors = check_if_list_of_links_are_working(links) @@ -236,3 +233,23 @@ if __name__ == '__main__': print(error_message) 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)