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

Added generate random email feature #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ names
.. image:: https://pypip.in/d/names/badge.png
:target: https://crate.io/packages/names

Random name generator
Random name/email generator


Installation
Expand Down Expand Up @@ -52,6 +52,10 @@ Here are examples of all current features:
'Christina'
>>> names.get_last_name()
'Szczepanek'
>>> names.get_email(get_full_name())
'[email protected]'
>>> names.get_email(get_first_name())
'[email protected]'


License
Expand All @@ -65,5 +69,10 @@ Data in the following files are public domain (derived from 1990 Census data):
- dist.female.first
- dist.male.first

Data in the following files are public domain

- dist.companies
- dist.tlds

.. _mit license: http://th.mit-license.org/2013
.. _available on PyPI: http://pypi.python.org/pypi/names/
31 changes: 30 additions & 1 deletion names/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,31 @@
'first:male': full_path('dist.male.first'),
'first:female': full_path('dist.female.first'),
'last': full_path('dist.all.last'),
'tlds': full_path('dist.tlds'),
'companies': full_path('dist.companies'),
}

def get_tld(filename):
selected = random.random() * 83
with open(filename) as tld_file:
for line in tld_file:
tld, cummulative = line.split()
if float(cummulative) > selected:
return tld
return ""

def get_company(filename):
selected = random.random() * 60
with open(filename) as company_file:
for line in company_file:
cc = line.split()
cummulative = cc[-1]
if float(cummulative) > selected:
return ' '.join(cc[:-1])
return ""

def get_name(filename):
selected = random.random() * 90
selected = random.random() * 91
with open(filename) as name_file:
for line in name_file:
name, _, cummulative, _ = line.split()
Expand All @@ -43,3 +63,12 @@ def get_last_name():

def get_full_name(gender=None):
return "{0} {1}".format(get_first_name(gender), get_last_name())

def get_email(name, company=None, tld=None):
if company is None:
company = get_company(FILES['companies'])
if tld is None:
tld = get_tld(FILES['tlds'])
email = '{0}@{1}.{2}'.format(name, company, tld)
return email.replace(' ', '').lower()

99 changes: 99 additions & 0 deletions names/dist.companies
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
Orci Lobortis 3.318
Luctus Vulputate 6.589
Sociis 9.732
Urna Nec 12.361
Eleifend 14.812
Molestie Inc 17.176
Magna Cras 18.878
Tellus Consulting 20.401
Pellentesque 21.805
Est Ac 23.185
Sed Limited 24.220
Dolor Incorporated 25.194
Quam Dignissim 26.142
Ipsum Suspendisse 27.081
Lacinia Ltd 28.012
Tincidunt Orci 28.939
Posuere Velit 29.766
Dolor Tempus 30.546
Tristique Consulting 31.325
Luctus Corp 32.061
Mus Aenean 32.787
Vel Incorporated 33.508
Aliquet LLC 34.179
Id Inc 34.839
Tellus Lorem 35.496
Nulla Interdum 36.147
Curabitur 36.786
Auctor 37.399
Nunc Nulla 37.997
Mollis Ltd 38.588
Nunc Industries 39.169
Nibh Dolor 39.715
Cras Nisi Corp 40.259
Sit Amet 40.799
Tristique Ltd 41.335
Velit Semper 41.824
Aliquam Inc 42.265
Egestas Corp 42.700
Augue Inc 43.132
Nunc Corporation 43.547
Risus Libero Limited 43.946
Quisque 44.335
Malesuada Augue Inc 44.716
Lectus Nullam Suscipit 45.087
Quisque LLC 45.454
Aptent Taciti 45.819
Mi Felis Limited 46.165
Eu Neque Industries 46.500
Parturient Foundation 46.828
Commodo Auctor Inc 47.150
Dolor Fusce Ltd 47.471
Orci LLP 47.786
Dapibus Institute 48.102
Ligula Aliquam Corp 48.415
Arcu Imperdiet 48.729
Et Corp 49.040
Ut Aliquam Ltd 49.351
Orci Ut Limited 49.660
Nam Corporation 49.968
Duis Incorporated 50.274
Turpis LLP 50.576
Praesent 50.859
Euismod Corp 51.141
Aenean LLC 51.415
Interdum Incorporated 51.688
Sed Sem Egestas Limited 51.958
Quisque Libero Corp 52.221
Quis Turpis Incorporated 52.480
Semper Tellus LLP 52.740
Blandit Foundation 52.991
Aptent Institute 53.241
Nam Consequat 53.490
Posuere Limited 53.738
Dictum 53.984
Eu Corporation 54.227
Diam Nunc 54.469
Odio Sagittis LLP 54.710
Litora Torquent Inc 54.942
Sed Leo Inc 55.172
Ultricies LLC 55.402
Id Mollis 55.630
Congue Industries 55.854
Montes Foundation 56.077
Nascetur 56.299
Elit Pharetra Corp 56.515
Cras Vehicula 56.730
Tempor Corporation 56.942
Aliquam Erat LLC 57.155
Facilisis 57.364
Vulputate Mauris 57.570
Nunc Limited 57.774
Nulla Semper 57.973
Odio Auctor 58.170
Ante Corporation 58.368
Dapibus Quam Inc 58.565
Ipsum LLC 58.761
Ante Ipsum Foundation 58.957
Consectetuer Corp 59.149
Adipiscing LLC 59.340
Loading