Skip to content

Improved emails from url#4181

Closed
AyushSehrawat wants to merge 16 commits intoTheAlgorithms:masterfrom
AyushSehrawat:master
Closed

Improved emails from url#4181
AyushSehrawat wants to merge 16 commits intoTheAlgorithms:masterfrom
AyushSehrawat:master

Conversation

@AyushSehrawat
Copy link
Copy Markdown

Describe your change:

This version finds more email from the url and also find the urls from the given url and also find emails from them. It all depends on the range given by the user.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@ghost ghost added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed tests are failing Do not merge until tests pass labels Feb 6, 2021
@ghost ghost removed the tests are failing Do not merge until tests pass label Feb 6, 2021
@AyushSehrawat
Copy link
Copy Markdown
Author

Finally solved all the issues 👍

Comment thread web_programming/emails_from_url.py
Comment thread web_programming/emails_from_url.py Outdated
Comment thread web_programming/emails_from_url.py Outdated
Comment thread web_programming/emails_from_url.py Outdated
Comment thread web_programming/emails_from_url.py Outdated
Comment thread web_programming/emails_from_url.py Outdated
Comment thread web_programming/emails_from_url.py Outdated
@ghost ghost added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Feb 6, 2021
@AyushSehrawat
Copy link
Copy Markdown
Author

I will consider your changes 😊.

@ghost ghost added the require tests Tests [doctest/unittest/pytest] are required label Feb 7, 2021
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread web_programming/emails_from_url_alt.py Outdated
Comment thread web_programming/emails_from_url_alt.py Outdated
@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Feb 7, 2021
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread web_programming/emails_from_url_alt.py Outdated
"""


def getmails(num: int) -> None:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file web_programming/emails_from_url_alt.py, please provide doctest for the function getmails

Comment thread web_programming/emails_from_url_alt.py Outdated
@AyushSehrawat AyushSehrawat requested a review from cclauss February 7, 2021 04:50
@AyushSehrawat
Copy link
Copy Markdown
Author

getmails function returns nothing. Instead it adds things to the sets. So, ig there will be no doctest for it.

@AyushSehrawat
Copy link
Copy Markdown
Author

Waiting for review :)

Comment thread web_programming/emails_from_url.py
Comment thread web_programming/emails_from_url_alt.py Outdated
"""


def getmails(num: int) -> None:
Copy link
Copy Markdown
Member

@cclauss cclauss Feb 10, 2021

Choose a reason for hiding this comment

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

Suggested change
def getmails(num: int) -> None:
def get_mails(url: str, max_emails: int = 5000) -> list:

Callers are going to assume that a get_ function returns what it gets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should the list be ordered by first found or alphabetically?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

max_emails can be a wrong variable , since the int value is a loop , which runs to find the links and emails.
We can't tell the max emails.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

while urls and len(emails) < max_emails:

Copy link
Copy Markdown
Member

@cclauss cclauss Feb 12, 2021

Choose a reason for hiding this comment

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

Now that I see how this works, I think we need to change the function signature:
def get_mails(urls: list, max_emails: int = 5000) -> list:

Comment thread web_programming/emails_from_url_alt.py Outdated
Comment thread web_programming/emails_from_url_alt.py Outdated
Comment thread web_programming/emails_from_url_alt.py Outdated

if __name__ == "__main__":
user_url = "https://google.com" # Example Url
urls = deque([user_url])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not need a deque if get_emails() returns a list of emails.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this get_emails() function doesn't return anything. It just add them to set ( to prevent same emails )

Comment thread web_programming/emails_from_url_alt.py Outdated
Comment thread web_programming/emails_from_url_alt.py
@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Feb 10, 2021
Co-authored-by: Christian Clauss <cclauss@me.com>
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread web_programming/emails_from_url_alt.py Outdated
@ghost ghost added the tests are failing Do not merge until tests pass label Feb 12, 2021
@ghost ghost added the require tests Tests [doctest/unittest/pytest] are required label Feb 12, 2021
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread web_programming/emails_from_url_alt.py Outdated
"""


def getmails(num: int) -> None:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file web_programming/emails_from_url_alt.py, please provide doctest for the function getmails

@ghost ghost removed the tests are failing Do not merge until tests pass label Feb 12, 2021
@ghost ghost added tests are failing Do not merge until tests pass and removed require tests Tests [doctest/unittest/pytest] are required labels Feb 12, 2021
@ghost ghost added the require tests Tests [doctest/unittest/pytest] are required label Feb 12, 2021
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread web_programming/emails_from_url_alt.py Outdated
"""


def getmails(num: int) -> None:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file web_programming/emails_from_url_alt.py, please provide doctest for the function getmails

@AyushSehrawat
Copy link
Copy Markdown
Author

I tried to make code as much simple as possible. I can also return the set ( to add doctest )

@ghost ghost removed the tests are failing Do not merge until tests pass label Feb 12, 2021
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread web_programming/emails_from_url_alt.py Outdated
"""


def getmails(num: int) -> set:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file web_programming/emails_from_url_alt.py, please provide doctest for the function getmails

@AyushSehrawat
Copy link
Copy Markdown
Author

AyushSehrawat commented Feb 12, 2021

@cclauss I tried to create a doctest for it, but my code is dependant on sets which are declared in

if __name__ == "__main__":

Also, now the getmails function now returns set of emails

Comment on lines 93 to 94
if __name__ == "__main__":
user_url = "https://google.com" # Example Url
Copy link
Copy Markdown
Member

@cclauss cclauss Feb 12, 2021

Choose a reason for hiding this comment

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

Let's just replace all of __main__ with:

Suggested change
if __name__ == "__main__":
user_url = "https://google.com" # Example Url
if __name__ == "__main__":
print("\n".join(get_emails(["https://google.com"])))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It takes num as argument. I tried to add url too , but didn't work the way i want, and also popleft is faster then pop(0) (if using list). So set would be faster.

Comment thread web_programming/emails_from_url_alt.py Outdated
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

"""


def getmails(num: int) -> list:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file web_programming/emails_from_url_alt.py, please provide doctest for the function getmails

@AyushSehrawat
Copy link
Copy Markdown
Author

@cclauss Been 8 days since i asked for review. Adding doctest is like changing the whole code. Also this is an alternative to the original code. Please look into it :)

@AyushSehrawat
Copy link
Copy Markdown
Author

@cclauss Shall i close the pull request ? Since no action is being taken. I fulfilled most of the needs except doctest :(

@cclauss
Copy link
Copy Markdown
Member

cclauss commented Mar 7, 2021

No. Please leave it open.

@stale
Copy link
Copy Markdown

stale bot commented Jun 4, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Jun 4, 2021
@stale
Copy link
Copy Markdown

stale bot commented Jun 16, 2021

Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

@stale stale bot closed this Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files require tests Tests [doctest/unittest/pytest] are required stale Used to mark an issue or pull request stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants