14
14
sys .path .append ('.' )
15
15
16
16
from random_profile .enums .gender import Gender
17
- from random_profile . utils import *
17
+ from random_profile import utils
18
18
19
19
VERSION = '2.0.1'
20
20
21
- lname_txt = os .path .join (ASSETS_DIR , "lnames.txt" )
22
- fname_male_txt = os .path .join (ASSETS_DIR , "fnames_male.txt" )
23
- fname_female_txt = os .path .join (ASSETS_DIR , "fnames_female.txt" )
24
- hair_colors_txt = os .path .join (ASSETS_DIR , "hair_colors.txt" )
25
- blood_types_txt = os .path .join (ASSETS_DIR , "blood_types.txt" )
26
- street_names_txt = os .path .join (ASSETS_DIR , "street_names.txt" )
27
- cities_name_txt = os .path .join (ASSETS_DIR , "cities_name.txt" )
28
- states_names_txt = os .path .join (ASSETS_DIR , "states_names.txt" )
29
- job_titles_txt = os .path .join (ASSETS_DIR , "job_titles.txt" )
30
- job_levels_txt = os .path .join (ASSETS_DIR , "job_levels.txt" )
21
+ lname_txt = os .path .join (utils . ASSETS_DIR , "lnames.txt" )
22
+ fname_male_txt = os .path .join (utils . ASSETS_DIR , "fnames_male.txt" )
23
+ fname_female_txt = os .path .join (utils . ASSETS_DIR , "fnames_female.txt" )
24
+ hair_colors_txt = os .path .join (utils . ASSETS_DIR , "hair_colors.txt" )
25
+ blood_types_txt = os .path .join (utils . ASSETS_DIR , "blood_types.txt" )
26
+ street_names_txt = os .path .join (utils . ASSETS_DIR , "street_names.txt" )
27
+ cities_name_txt = os .path .join (utils . ASSETS_DIR , "cities_name.txt" )
28
+ states_names_txt = os .path .join (utils . ASSETS_DIR , "states_names.txt" )
29
+ job_titles_txt = os .path .join (utils . ASSETS_DIR , "job_titles.txt" )
30
+ job_levels_txt = os .path .join (utils . ASSETS_DIR , "job_levels.txt" )
31
31
32
32
# loading data from txt files
33
- lname = load_txt_file (lname_txt )
34
- fname_male = load_txt_file (fname_male_txt )
35
- fname_female = load_txt_file (fname_female_txt )
36
- hair_colors = load_txt_file (hair_colors_txt )
37
- blood_types = load_txt_file (blood_types_txt )
38
- states_names = load_txt_file (states_names_txt )
39
- cities_name = load_txt_file (cities_name_txt )
40
- street_names = load_txt_file (street_names_txt )
41
- job_titles = load_txt_file (job_titles_txt )
42
- job_levels = load_txt_file (job_levels_txt )
33
+ lname = utils .load_txt_file (lname_txt )
34
+ fname_male = utils .load_txt_file (fname_male_txt )
35
+ fname_female = utils .load_txt_file (fname_female_txt )
36
+ hair_colors = utils .load_txt_file (hair_colors_txt )
37
+ blood_types = utils .load_txt_file (blood_types_txt )
38
+ states_names = utils .load_txt_file (states_names_txt )
39
+ cities_name = utils .load_txt_file (cities_name_txt )
40
+ street_names = utils .load_txt_file (street_names_txt )
41
+ job_titles = utils .load_txt_file (job_titles_txt )
42
+ job_levels = utils .load_txt_file (job_levels_txt )
43
+
43
44
44
45
class RandomProfile (object ):
45
46
def __init__ (self , num : int = 1 , gender : Gender = None ):
@@ -75,8 +76,8 @@ def __getitem__(self, index):
75
76
def ip_address (self , num : int = None ) -> List [str ]:
76
77
num = self .num if num is None else num
77
78
if num == 1 or num is None :
78
- return ipv4_gen ()
79
- return [ipv4_gen () for _ in range (num )]
79
+ return utils . ipv4_gen ()
80
+ return [utils . ipv4_gen () for _ in range (num )]
80
81
81
82
def job_title (self , num : int = None ) -> List [str ]:
82
83
num = self .num if num is None else num
@@ -99,14 +100,14 @@ def hair_color(self, num: int = None) -> List[str]:
99
100
def dob_age (self , num : int = None ) -> List [Tuple [str , int ]]:
100
101
num = self .num if num is None else num
101
102
if num == 1 or num is None :
102
- return generate_dob_age ()
103
- return [generate_dob_age () for _ in range (num )]
103
+ return utils . generate_dob_age ()
104
+ return [utils . generate_dob_age () for _ in range (num )]
104
105
105
106
def height_weight (self , num : int = None ) -> List [Tuple [int , int ]]:
106
107
num = self .num if num is None else num
107
108
if num == 1 or num is None :
108
- return generate_random_height_weight ()
109
- return [generate_random_height_weight () for _ in range (num )]
109
+ return utils . generate_random_height_weight ()
110
+ return [utils . generate_random_height_weight () for _ in range (num )]
110
111
111
112
def generate_address (self , num : int = None ) -> List [str ]:
112
113
num = self .num if num is None else num
@@ -128,7 +129,7 @@ def generate_address(self, num: int = None) -> List[str]:
128
129
address_list .append (address )
129
130
130
131
return address_list
131
-
132
+
132
133
def first_names (self , num : int = None , gender : Gender = None ) -> list :
133
134
num = self .num if num is None else num
134
135
if gender is None :
@@ -139,10 +140,10 @@ def first_names(self, num: int = None, gender: Gender = None) -> list:
139
140
names = fname_male
140
141
else :
141
142
names = fname_female
142
-
143
+
143
144
if num == 1 or num is None :
144
145
return random .choice (names )
145
-
146
+
146
147
return random .choices (names , k = num )
147
148
148
149
def last_names (self , num : int = None ) -> list :
@@ -152,7 +153,7 @@ def last_names(self, num: int = None) -> list:
152
153
if num == 1 or num is None :
153
154
return random .choice (lname )
154
155
return random .choices (lname , k = num )
155
-
156
+
156
157
def full_names (self , num : int = None , gender : Gender = None ) -> list :
157
158
num = self .num if num is None else num
158
159
@@ -165,12 +166,12 @@ def full_names(self, num: int = None, gender: Gender = None) -> list:
165
166
names = fname_male
166
167
else :
167
168
names = fname_female
168
-
169
+
169
170
if num == 1 or num is None :
170
171
return random .choice (names ) + ' ' + random .choice (lname )
171
172
172
173
return [random .choice (names ) + ' ' + random .choice (lname ) for _ in range (num )]
173
-
174
+
174
175
def full_profiles (self , num : int = None , gender : Gender = None ) -> list :
175
176
num = self .num if num is None else num
176
177
@@ -179,28 +180,24 @@ def full_profiles(self, num: int = None, gender: Gender = None) -> list:
179
180
for _ in range (num ):
180
181
181
182
# random gender for every profile in list
182
- this_gender = generate_random_gender () if gender is None else gender
183
+ this_gender = utils . generate_random_gender () if gender is None else gender
183
184
first = random .choice (fname_male if this_gender .value == Gender .MALE .value else fname_female )
184
185
last = random .choice (lname )
185
186
full_name = first + ' ' + last
186
-
187
+
187
188
hair_color = random .choice (hair_colors )
188
189
blood_type = random .choice (blood_types )
189
-
190
- phone_number = f'+1-{ random .randint (300 , 500 )} -{ random .randint (800 , 999 )} -{ random .randint (1000 ,9999 )} '
191
-
192
-
193
190
194
- dob , age = generate_dob_age ()
195
- height , weight = generate_random_height_weight ()
191
+ phone_number = f'+1-{ random .randint (300 , 500 )} -{ random .randint (800 , 999 )} -{ random .randint (1000 ,9999 )} '
196
192
197
- job_title = random .choice (job_titles )
198
- job_experience = generate_random_job_level (age , job_levels )
193
+ dob , age = utils .generate_dob_age ()
194
+ height , weight = utils .generate_random_height_weight ()
195
+ job_experience = utils .generate_random_job_level (age , job_levels )
199
196
200
197
street_num = random .randint (100 , 999 )
201
198
street = random .choice (street_names )
202
- city , coords = generate_random_city_coords (cities_name )
203
- coords_pretty = coords_string (coords )
199
+ city , coords = utils . generate_random_city_coords (cities_name )
200
+ coords_pretty = utils . coords_string (coords )
204
201
state = random .choice (states_names )
205
202
zip_code = random .randint (10000 , 99999 )
206
203
@@ -211,13 +208,13 @@ def full_profiles(self, num: int = None, gender: Gender = None) -> list:
211
208
'state' : state ,
212
209
'zip_code' : zip_code
213
210
}
214
-
211
+
215
212
full_address = f'{ street_num } { street } , { city } , { state } { zip_code } '
216
-
213
+
217
214
mother = self .first_names (1 , Gender .FEMALE )[0 ] + ' ' + last
218
215
father = self .first_names (1 , Gender .MALE )[0 ] + ' ' + last
219
216
220
- card = generate_random_card ()
217
+ card = utils . generate_random_card ()
221
218
222
219
profile = {}
223
220
profile ['id' ] = str (uuid .uuid4 ())
@@ -234,21 +231,20 @@ def full_profiles(self, num: int = None, gender: Gender = None) -> list:
234
231
profile ['age' ] = age
235
232
profile ['phone_number' ] = phone_number
236
233
profile ['email' ] = profile ['first_name' ].lower () + profile ['last_name' ].lower () + '@example.com'
237
-
238
-
234
+
239
235
profile ['blood_type' ] = self .blood_type (num = 1 )
240
236
profile ['height' ] = height
241
237
profile ['weight' ] = weight
242
238
profile ['hair_color' ] = self .hair_color (num = 1 )
243
239
profile ['ip_address' ] = self .ip_address (num = 1 )
244
240
245
-
246
241
profile ['address' ] = address
247
242
profile ['full_address' ] = full_address
248
243
profile ['job_job_experience' ] = job_experience
249
244
profile ['mother' ] = mother
250
245
profile ['father' ] = father
251
246
profile ['payment_card' ] = card
247
+ profile ['coordinates' ] = coords_pretty
252
248
253
249
profile_list .append (profile )
254
250
0 commit comments