Skip to content

Commit

Permalink
warn msg
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDokuchaev committed Mar 3, 2024
1 parent 0dbc25b commit 736199c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion md_dead_link_check/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __getattr__(self, attr: str) -> str:
def enable(self) -> None:
self.data["blue"] = "\033[1;94m"
self.data["green"] = "\033[1;92m"
self.data["yellow"] = "\033[1;93m"
self.data["red"] = "\033[1;91m"
self.data["clean"] = "\033[0m"

Expand All @@ -42,7 +43,10 @@ def summary(status: List[StatusInfo], verbose: bool, no_color: bool) -> int:
print(f"{link_msg}{color.red}Error{color.clean}: {x.err_msg}")
err_nums += 1
elif verbose:
print(f"{link_msg}{color.green}OK{color.clean}")
if x.warn_msg is None:
print(f"{link_msg}{color.green}OK{color.clean}")
else:
print(f"{link_msg}{color.yellow}Warn{color.clean}: {x.warn_msg}")

if err_nums:
cat_repeat = 0 if no_color else max(min(err_nums // 10, 5), 1)
Expand Down
4 changes: 3 additions & 1 deletion md_dead_link_check/link_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
class StatusInfo:
link_info: LinkInfo
err_msg: Optional[str] = None
warn_msg: Optional[str] = None

def __lt__(self, other: StatusInfo) -> bool:
return self.link_info < other.link_info
Expand All @@ -42,12 +43,13 @@ async def process_link(link_info: LinkInfo, session: ClientSession, timeout: int
except ClientResponseError as e:
if e.status in CATCH_RESPONSE_STATUS:
return StatusInfo(link_info, f"{e.status}: {e.message}")
return StatusInfo(link_info, warn_msg=f"{e.status}: {e.message}")
except asyncio.CancelledError as e:
return StatusInfo(link_info, str(e))
except ClientConnectorError as e:
return StatusInfo(link_info, str(e))
except asyncio.TimeoutError:
pass
return StatusInfo(link_info, warn_msg="TimeoutError")

return StatusInfo(link_info)

Expand Down

0 comments on commit 736199c

Please # to comment.