1414sys .path .append ('.' )
1515
1616from random_profile .enums .gender import Gender
17- from random_profile . utils import *
17+ from random_profile import utils
1818
1919VERSION = '2.0.1'
2020
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" )
3131
3232# 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+
4344
4445class RandomProfile (object ):
4546 def __init__ (self , num : int = 1 , gender : Gender = None ):
@@ -75,8 +76,8 @@ def __getitem__(self, index):
7576 def ip_address (self , num : int = None ) -> List [str ]:
7677 num = self .num if num is None else num
7778 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 )]
8081
8182 def job_title (self , num : int = None ) -> List [str ]:
8283 num = self .num if num is None else num
@@ -99,14 +100,14 @@ def hair_color(self, num: int = None) -> List[str]:
99100 def dob_age (self , num : int = None ) -> List [Tuple [str , int ]]:
100101 num = self .num if num is None else num
101102 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 )]
104105
105106 def height_weight (self , num : int = None ) -> List [Tuple [int , int ]]:
106107 num = self .num if num is None else num
107108 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 )]
110111
111112 def generate_address (self , num : int = None ) -> List [str ]:
112113 num = self .num if num is None else num
@@ -128,7 +129,7 @@ def generate_address(self, num: int = None) -> List[str]:
128129 address_list .append (address )
129130
130131 return address_list
131-
132+
132133 def first_names (self , num : int = None , gender : Gender = None ) -> list :
133134 num = self .num if num is None else num
134135 if gender is None :
@@ -139,10 +140,10 @@ def first_names(self, num: int = None, gender: Gender = None) -> list:
139140 names = fname_male
140141 else :
141142 names = fname_female
142-
143+
143144 if num == 1 or num is None :
144145 return random .choice (names )
145-
146+
146147 return random .choices (names , k = num )
147148
148149 def last_names (self , num : int = None ) -> list :
@@ -152,7 +153,7 @@ def last_names(self, num: int = None) -> list:
152153 if num == 1 or num is None :
153154 return random .choice (lname )
154155 return random .choices (lname , k = num )
155-
156+
156157 def full_names (self , num : int = None , gender : Gender = None ) -> list :
157158 num = self .num if num is None else num
158159
@@ -165,12 +166,12 @@ def full_names(self, num: int = None, gender: Gender = None) -> list:
165166 names = fname_male
166167 else :
167168 names = fname_female
168-
169+
169170 if num == 1 or num is None :
170171 return random .choice (names ) + ' ' + random .choice (lname )
171172
172173 return [random .choice (names ) + ' ' + random .choice (lname ) for _ in range (num )]
173-
174+
174175 def full_profiles (self , num : int = None , gender : Gender = None ) -> list :
175176 num = self .num if num is None else num
176177
@@ -179,28 +180,24 @@ def full_profiles(self, num: int = None, gender: Gender = None) -> list:
179180 for _ in range (num ):
180181
181182 # 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
183184 first = random .choice (fname_male if this_gender .value == Gender .MALE .value else fname_female )
184185 last = random .choice (lname )
185186 full_name = first + ' ' + last
186-
187+
187188 hair_color = random .choice (hair_colors )
188189 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-
193190
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 )} '
196192
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 )
199196
200197 street_num = random .randint (100 , 999 )
201198 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 )
204201 state = random .choice (states_names )
205202 zip_code = random .randint (10000 , 99999 )
206203
@@ -211,13 +208,13 @@ def full_profiles(self, num: int = None, gender: Gender = None) -> list:
211208 'state' : state ,
212209 'zip_code' : zip_code
213210 }
214-
211+
215212 full_address = f'{ street_num } { street } , { city } , { state } { zip_code } '
216-
213+
217214 mother = self .first_names (1 , Gender .FEMALE )[0 ] + ' ' + last
218215 father = self .first_names (1 , Gender .MALE )[0 ] + ' ' + last
219216
220- card = generate_random_card ()
217+ card = utils . generate_random_card ()
221218
222219 profile = {}
223220 profile ['id' ] = str (uuid .uuid4 ())
@@ -234,21 +231,20 @@ def full_profiles(self, num: int = None, gender: Gender = None) -> list:
234231 profile ['age' ] = age
235232 profile ['phone_number' ] = phone_number
236233 profile ['email' ] = profile ['first_name' ].lower () + profile ['last_name' ].lower () + '@example.com'
237-
238-
234+
239235 profile ['blood_type' ] = self .blood_type (num = 1 )
240236 profile ['height' ] = height
241237 profile ['weight' ] = weight
242238 profile ['hair_color' ] = self .hair_color (num = 1 )
243239 profile ['ip_address' ] = self .ip_address (num = 1 )
244240
245-
246241 profile ['address' ] = address
247242 profile ['full_address' ] = full_address
248243 profile ['job_job_experience' ] = job_experience
249244 profile ['mother' ] = mother
250245 profile ['father' ] = father
251246 profile ['payment_card' ] = card
247+ profile ['coordinates' ] = coords_pretty
252248
253249 profile_list .append (profile )
254250
0 commit comments