Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Detailed report #69

Merged
merged 3 commits into from
Sep 15, 2022
Merged

feat: Detailed report #69

merged 3 commits into from
Sep 15, 2022

Conversation

pythonbrad
Copy link
Member

@pythonbrad pythonbrad commented Sep 15, 2022

Change

  • Added URL information on the report
  • Added a short checking stats

Linked to

Preview

a

Added URL information on the report
Added a short checking stats
@pythonbrad pythonbrad self-assigned this Sep 15, 2022
Copy link
Member

@Sanix-Darker Sanix-Darker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, overwhall, looks good to me, I left some comments and suggestions !
prioritize accessing a value from key in a dictionary with the .get() method, this will allow you to specify a default value if the value is not present and prevent the app crashing for a KeyError exception !

Thanks for tests !

blc/__main__.py Outdated
f"URL: {url}\n"\
f"Parent URL: {info['parent']}\n"\
f"Real URL: {info['url']}\n"\
f"Check time: {info['check_time']} seconds\n"\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to reduce the floating point to 4:

Suggested change
f"Check time: {info['check_time']} seconds\n"\
f"Check time: {round(info['check_time'], 4)} seconds\n"\

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

blc/checker.py Outdated
@@ -101,33 +103,31 @@ def check(self, url: str) -> requests.Response:
:url represent the URL to check
"""
# We verify the URL is already checked
if url in self.checked_url:
if [u for u in self.urls if self.urls[u]['result'] and url == u]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [u for u in self.urls if self.urls[u]['result'] and url == u]:
if url in self.urls.keys() and self.urls[url].get('result', False):

What do you think about this instead of looping?

'url': origin_url,
'result': None,
'check_time': None

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

self.update_list(response)
time.sleep(self.delay)
while 1:
url_to_check = [u for u in self.urls if not self.urls[u]['result']]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url_to_check = [u for u in self.urls if not self.urls[u]['result']]
url_to_check = [u for u in self.urls if not self.urls[u].get('result', False)]

to prevent a KeyError raising here !

blc/checker.py Outdated
Comment on lines 238 to 241
if url_to_check:
pass
else:
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if url_to_check:
pass
else:
break
if not url_to_check:
break

blc/checker.py Outdated
else:
break

while (url_to_check):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
while (url_to_check):
while url_to_check:

@pythonbrad pythonbrad merged commit d783542 into main Sep 15, 2022
@pythonbrad pythonbrad deleted the patchz branch September 15, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants