-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemail_gen.py
More file actions
108 lines (96 loc) · 3.21 KB
/
Copy pathemail_gen.py
File metadata and controls
108 lines (96 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#! /bin python
import random
import json
import requests
import os
def mail(domain):
email = first()+"."+last()+"@"+domain+"\n"
return email
def first():
selected = random.random()*90
with open("first.txt") as names:
for line in names:
name, _,cumm,_ = line.split()
if float(cumm)>selected:
return name.title()
return ""
def last():
selected = random.random()*90
with open("last.txt") as names:
for line in names:
name, _,cumm,_ = line.split()
if float(cumm)>selected:
return name.title()
return ""
def email_value(domain):
given = first()
family = last()
value = str(random.randbetween(0,1000))
email = given+''+family+'@'+domain
return (email,value)
def email_name_value(domain, seperator):
given = first()
family = last()
value = str(int(random.random()*1000))
email = given+seperator+family+'@'+domain
return (email.lower(),given,family,value)
def email_number_name_value(domain,seperator):
given = first()
family = last()
value = str(int(random.random()*1000))
email = given+seperator+family+seperator+value+'@'+domain
return (email.lower(),given,family,value)
def email_from_name(given,family,domain,seperator):
email = given+seperator+family+'@'+domain
return email
def email_from_name_value(given,family,value,domain,seperator):
email = given+seperator+family+seperator+str(value)+'@'+domain
return email
def makeUser(seperator):
given = first()
family = last()
value = int(random.random()*1000)
email = email_from_name(given,family,"gmail.com",seperator)
userdict = dict()
userdict["email"] = email.lower()
userdict["full_name"] = given+' '+family
userdict["first_name"] = given
userdict["last_name"] = family
userdict["attr_value"] = value
return userdict
def makeUser_numbers(seperator):
given = first()
family = last()
value = int(random.random()*1000)
email = email_from_name_value(given,family,value,"gmail.com",seperator)
userdict = dict()
userdict["email"] = email.lower()
userdict["full_name"] = given+' '+family
userdict["first_name"] = given
userdict["last_name"] = family
userdict["attr_value"] = value
return userdict
def main():
data = []
lines = []
#make 100 users, with 50 differnt names and values
for i in range(50):
# creates a user
userDict = makeUser('')
# create a JSON string
userJSON = json.dumps(userdict)
print(userJSON)
lines.append(userJSON)
# generate a new email with the value appended to the email, add as a new user
userdict["email"] = email_from_name_value(userDict["first_name"],userDict["last_name"],userDict["attr_value"],"gmail.com",seperator)
userJSON = json.dumps(userdict)
print(userJSON)
lines.append(userJSON)
# save the users to a JSON lines file
with open("users.JSONL","w") as record:
for line in lines:
record.write(line)
record.write("\n")
# done
if __name__ == "__main__":
main()