Skip to content

Commit

Permalink
adding dob, age, blood type
Browse files Browse the repository at this point in the history
  • Loading branch information
codeperfectplus committed Oct 12, 2022
1 parent 1802519 commit c96488b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
8 changes: 8 additions & 0 deletions random_profile/assets/blood_types.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(A+)
(A-)
(B+)
(B-)
(O+)
(O-)
(AB+)
(AB-)
6 changes: 6 additions & 0 deletions random_profile/assets/hair_colors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
black
brown
white
yellow
red
blue
20 changes: 19 additions & 1 deletion random_profile/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@
'''
import os
import random
from random_profile.utils import ipv4_gen, load_txt_file

from random_profile.utils import ipv4_gen
from random_profile.utils import load_txt_file
from random_profile.utils import genrate_dob_age
from random_profile.utils import genrate_random_height_weight

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

fname_txt = os.path.join(ROOT_DIR, "random_profile/assets/fnames.txt")
lname_txt = os.path.join(ROOT_DIR, "random_profile/assets/lnames.txt")
hair_colors_txt = os.path.join(ROOT_DIR, "random_profile/assets/hair_colors.txt")
blood_types_txt = os.path.join(ROOT_DIR, "random_profile/assets/blood_types.txt")
street_names_txt = os.path.join(ROOT_DIR, "random_profile/assets/street_names.txt")
cities_name_txt = os.path.join(ROOT_DIR, "random_profile/assets/cities_name.txt")
states_names_txt = os.path.join(ROOT_DIR, "random_profile/assets/states_names.txt")
Expand All @@ -27,6 +33,8 @@
# loading data from txt files
fname = load_txt_file(fname_txt)
lname = load_txt_file(lname_txt)
hair_colors = load_txt_file(hair_colors_txt)
blood_types = load_txt_file(blood_types_txt)
states_names = load_txt_file(states_names_txt)
cities_name = load_txt_file(cities_name_txt)
street_names = load_txt_file(street_names_txt)
Expand Down Expand Up @@ -63,11 +71,15 @@ def full_profile(self):
for _ in range(self.num):
first = random.choice(fname)
last = random.choice(lname)
hair_color = random.choice(hair_colors)
blood_type = random.choice(blood_types)
full_name = first + ' ' + last
phone = f'+ +1-{random.randint(300, 500)}-{random.randint(800, 999)}-{random.randint(1000,9999)}'
job_title = random.choice(job_titles)
ip_address = ipv4_gen()
email_domain = random.choice(email_domains)
dob, age = genrate_dob_age()
height, weight = genrate_random_height_weight()

street_num = random.randint(100, 999)
street = random.choice(street_names)
Expand All @@ -81,7 +93,13 @@ def full_profile(self):
profile_dict = {}
profile_dict['first_name'] = first
profile_dict['last_name'] = last
profile_dict['hair_color'] = hair_color
profile_dict['blood_type'] = blood_type
profile_dict['full_name'] = full_name
profile_dict['DOB'] = dob
profile_dict['age'] = age
profile_dict['height'] = height
profile_dict['weight'] = weight
profile_dict['phone'] = phone
profile_dict['address'] = address
profile_dict['email'] = email
Expand Down
34 changes: 34 additions & 0 deletions random_profile/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
import random

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

def genrate_dob_age():
month = random.randint(1, 12)
if month == 2: # if month is feb
day = random.randint(1, 28)
elif month in [4, 6, 9, 11]: # if month has 30 days
day = random.randint(1, 30)
elif month in [1, 3, 5, 7, 8, 10, 12]: # if month has 31 days
day = random.randint(1, 31)

current_year = datetime.now().year
year = random.randint(current_year-80, current_year-18)

dob = datetime(day=day, month=month, year=year)
age = (datetime.now() - dob).days // 365
dob = dob.strftime("%d/%m/%Y")

return dob, age

def genrate_random_height_weight():
height = random.randint(140, 200)
if height < 150:
weight = random.randint(40, 60)
elif height < 160:
weight = random.randint(50, 70)
elif height < 170:
weight = random.randint(60, 80)
elif height < 180:
weight = random.randint(70, 90)
elif height < 190:
weight = random.randint(80, 100)
elif height <= 200:
weight = random.randint(90, 110)
return height, weight

0 comments on commit c96488b

Please sign in to comment.