Skip to content

Commit c96488b

Browse files
adding dob, age, blood type
1 parent 1802519 commit c96488b

4 files changed

Lines changed: 67 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(A+)
2+
(A-)
3+
(B+)
4+
(B-)
5+
(O+)
6+
(O-)
7+
(AB+)
8+
(AB-)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
black
2+
brown
3+
white
4+
yellow
5+
red
6+
blue

random_profile/main.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@
1212
'''
1313
import os
1414
import random
15-
from random_profile.utils import ipv4_gen, load_txt_file
15+
16+
from random_profile.utils import ipv4_gen
17+
from random_profile.utils import load_txt_file
18+
from random_profile.utils import genrate_dob_age
19+
from random_profile.utils import genrate_random_height_weight
1620

1721
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1822

1923
fname_txt = os.path.join(ROOT_DIR, "random_profile/assets/fnames.txt")
2024
lname_txt = os.path.join(ROOT_DIR, "random_profile/assets/lnames.txt")
25+
hair_colors_txt = os.path.join(ROOT_DIR, "random_profile/assets/hair_colors.txt")
26+
blood_types_txt = os.path.join(ROOT_DIR, "random_profile/assets/blood_types.txt")
2127
street_names_txt = os.path.join(ROOT_DIR, "random_profile/assets/street_names.txt")
2228
cities_name_txt = os.path.join(ROOT_DIR, "random_profile/assets/cities_name.txt")
2329
states_names_txt = os.path.join(ROOT_DIR, "random_profile/assets/states_names.txt")
@@ -27,6 +33,8 @@
2733
# loading data from txt files
2834
fname = load_txt_file(fname_txt)
2935
lname = load_txt_file(lname_txt)
36+
hair_colors = load_txt_file(hair_colors_txt)
37+
blood_types = load_txt_file(blood_types_txt)
3038
states_names = load_txt_file(states_names_txt)
3139
cities_name = load_txt_file(cities_name_txt)
3240
street_names = load_txt_file(street_names_txt)
@@ -63,11 +71,15 @@ def full_profile(self):
6371
for _ in range(self.num):
6472
first = random.choice(fname)
6573
last = random.choice(lname)
74+
hair_color = random.choice(hair_colors)
75+
blood_type = random.choice(blood_types)
6676
full_name = first + ' ' + last
6777
phone = f'+ +1-{random.randint(300, 500)}-{random.randint(800, 999)}-{random.randint(1000,9999)}'
6878
job_title = random.choice(job_titles)
6979
ip_address = ipv4_gen()
7080
email_domain = random.choice(email_domains)
81+
dob, age = genrate_dob_age()
82+
height, weight = genrate_random_height_weight()
7183

7284
street_num = random.randint(100, 999)
7385
street = random.choice(street_names)
@@ -81,7 +93,13 @@ def full_profile(self):
8193
profile_dict = {}
8294
profile_dict['first_name'] = first
8395
profile_dict['last_name'] = last
96+
profile_dict['hair_color'] = hair_color
97+
profile_dict['blood_type'] = blood_type
8498
profile_dict['full_name'] = full_name
99+
profile_dict['DOB'] = dob
100+
profile_dict['age'] = age
101+
profile_dict['height'] = height
102+
profile_dict['weight'] = weight
85103
profile_dict['phone'] = phone
86104
profile_dict['address'] = address
87105
profile_dict['email'] = email

random_profile/utils.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime
12
import random
23

34
def load_txt_file(file_name: str) -> list:
@@ -16,3 +17,36 @@ def load_txt_file(file_name: str) -> list:
1617
def ipv4_gen() -> str:
1718
return f"{random.randint(0,255)}.{random.randint(0,255)}.{random.randint(0,255)}.{random.randint(0,255)}"
1819

20+
def genrate_dob_age():
21+
month = random.randint(1, 12)
22+
if month == 2: # if month is feb
23+
day = random.randint(1, 28)
24+
elif month in [4, 6, 9, 11]: # if month has 30 days
25+
day = random.randint(1, 30)
26+
elif month in [1, 3, 5, 7, 8, 10, 12]: # if month has 31 days
27+
day = random.randint(1, 31)
28+
29+
current_year = datetime.now().year
30+
year = random.randint(current_year-80, current_year-18)
31+
32+
dob = datetime(day=day, month=month, year=year)
33+
age = (datetime.now() - dob).days // 365
34+
dob = dob.strftime("%d/%m/%Y")
35+
36+
return dob, age
37+
38+
def genrate_random_height_weight():
39+
height = random.randint(140, 200)
40+
if height < 150:
41+
weight = random.randint(40, 60)
42+
elif height < 160:
43+
weight = random.randint(50, 70)
44+
elif height < 170:
45+
weight = random.randint(60, 80)
46+
elif height < 180:
47+
weight = random.randint(70, 90)
48+
elif height < 190:
49+
weight = random.randint(80, 100)
50+
elif height <= 200:
51+
weight = random.randint(90, 110)
52+
return height, weight

0 commit comments

Comments
 (0)