-
Notifications
You must be signed in to change notification settings - Fork 3
simple email generator #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
513b800
Made simple email generator, modified requirements.txt
b7dff0d
deleted __main__ rubbish, modified success message
d895d18
added a check on username availability
41c60b3
Update __main__.py
Enhisir c3ab9bd
Update __main__.py
Enhisir 5cb7414
modified names of methods and atributes
e9bd37c
Update requirements.txt
Enhisir 9de6229
Merge remote-tracking branch 'origin/develop' into email_generator
ea7eaa3
reduced number of domen names, possible emails; reduced reversing and…
88c8025
fixed bug with command prompt; got rid of json; moved service symbols…
28c75db
some fixes
13063eb
some fixes
aad3c25
Merge remote-tracking branch 'origin/develop' into email_generator
c95589e
Add fixes
manmolecular File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
from pathlib import Path | ||
|
||
__root_dir = Path(__file__).parents[4] | ||
sys.path.append(str(__root_dir)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python3 | ||
from pprint import pprint | ||
from sys import argv | ||
|
||
from src.core.utils.module import run_module | ||
from src.scripts.convert.email_generator.module import Runner | ||
|
||
result = run_module(Runner, args=argv, arg_name="username", arg_default="john.doe") | ||
pprint(result, compact=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from time import time | ||
from pathlib import Path | ||
from string import punctuation as dividers | ||
|
||
from src.core.base.base import BaseRunner | ||
from src.core.utils.response import ScriptResponse | ||
|
||
|
||
class DefaultValues: | ||
binders = ("-", "_", ".", "") | ||
|
||
|
||
class EmailGenerator: | ||
def __init__(self, domain_base: str = "settings/domain_base.txt"): | ||
""" | ||
:param domain_base: base of email domains written in translit as text file | ||
""" | ||
with open(Path(__file__).parent.joinpath(domain_base), "r") as domains: | ||
self.__domains = domains.read().splitlines() | ||
|
||
@staticmethod | ||
def divide(username: str) -> list: | ||
""" | ||
:param username: username to generate email | ||
:return: login's lexemes | ||
""" | ||
for sym in dividers: | ||
username = username.replace(sym, " ") | ||
return username.split() | ||
|
||
def generate(self, username: str) -> list: | ||
""" | ||
:param username: username to generate email | ||
:return: list of person's emails | ||
""" | ||
parts = self.divide(username.lower()) | ||
logins = [] | ||
for i in range(2): | ||
logins.extend([sym.join(parts) for sym in DefaultValues.binders]) | ||
parts.reverse() | ||
emails = set() | ||
for login in logins: | ||
for domain in self.__domains: | ||
emails.add(f"{login}@{domain}") | ||
return list(emails) | ||
|
||
|
||
class Runner(BaseRunner): | ||
def __init__(self, logger: str = __name__): | ||
super(Runner, self).__init__(logger) | ||
|
||
def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error: | ||
""" | ||
Main runner function for the script | ||
:param args: args from core runner | ||
:param kwargs: kwargs from core runner | ||
:return: ScriptResponse message | ||
""" | ||
try: | ||
tm = time() | ||
email_gen = EmailGenerator() | ||
username = kwargs.get("username") | ||
if username is None: | ||
raise KeyError("EmailGenerator can't work without username!") | ||
result = email_gen.generate(username) | ||
except Exception as err: | ||
return ScriptResponse.error(message=str(err)) | ||
else: | ||
return ScriptResponse.success( | ||
result=result, | ||
message=f"Successfully finished! Got {len(result)} logins, script lasted {(time() - tm):.2f} seconds", | ||
) |
17 changes: 17 additions & 0 deletions
17
src/scripts/convert/email_generator/settings/domain_base.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
yandex.ru | ||
yandex.com | ||
gmail.com | ||
rocketmail.com | ||
yahoo.com | ||
outlook.com | ||
example.com | ||
aol.com | ||
love.com | ||
icloud.com | ||
inbox.com | ||
mail.com | ||
ya.ru | ||
inbox.ru | ||
list.ru | ||
bk.ru | ||
mail.ru |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавить: