Skip to content

Commit 0c0b65e

Browse files
v0.2.3 initialized
1 parent c96488b commit 0c0b65e

File tree

6 files changed

+85
-26
lines changed

6 files changed

+85
-26
lines changed

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1 align="center">
22
<br>
3-
Random Profile Generator
3+
Random Profile Generator V0.2.3
44
<br>
55
</h1>
66

@@ -30,17 +30,19 @@ default is 1
3030
change the num value according to your needs.
3131
3232
'''
33+
# num can be overwritten in the function
34+
3335
# For first name
34-
rp.first_name()
36+
rp.first_name(num=10)
3537

3638
# For full name
37-
rp.full_name()
39+
rp.full_name(num=8)
3840

39-
# For full profile
40-
rp.full_profile()
41+
# override the num value
42+
rp.full_profile(num=10)
4143

4244
# For last name
43-
rp.last_name()
45+
rp.last_name(num=6)
4446
```
4547

4648
## Usage
@@ -60,6 +62,24 @@ what's new in future update
6062
- More Random data will be added to package.
6163
- Variety of Random-Data will increase.
6264

65+
## Changelog
66+
67+
v0.2.3
68+
- Flask app added
69+
- Date of Birth Added
70+
- Age added
71+
- Height and Weight Added
72+
- Blood Group and hair color added
73+
- Job title added
74+
- More email domains added
75+
- Bugs Fixed
76+
77+
v0.2.1
78+
- More variation added to the data
79+
- Test cases added
80+
- Created a separate file for data loadings
81+
- Fixed some bugs
82+
6383
## Contributing
6484

6585
Before submitting a bug, please do the following:

api/api.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
from flask import Flask, jsonify
3+
from random_profile import RandomProfile
4+
5+
# random_profile==0.2.3 required
6+
rp = RandomProfile()
7+
app = Flask(__name__)
8+
9+
@app.route('/')
10+
def index():
11+
return jsonify({'message': 'api is working'})
12+
13+
@app.route('/api/v1/random_profile')
14+
def single_profile():
15+
profile = rp.full_profile()
16+
return jsonify({'profile': profile})
17+
18+
@app.route('/api/v1/random_profile/<int:num>')
19+
def multiple_profile(num):
20+
if num > 100:
21+
num = 100
22+
profile = rp.full_profile(num)
23+
return jsonify({'profile': profile})
24+
25+
26+
if __name__ == '__main__':
27+
app.run(debug=True)

api/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
random-profile==0.2.3
2+
flask

random_profile/main.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
from random_profile.utils import ipv4_gen
1717
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
18+
from random_profile.utils import generate_dob_age
19+
from random_profile.utils import generate_random_height_weight
2020

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

@@ -50,36 +50,42 @@ def __init__(self, num=1):
5050
'''
5151
self.num = num
5252

53-
def first_name(self):
54-
# print first name
55-
first_name_list = [random.choice(fname) for _ in range(self.num)]
53+
def first_name(self, num=None):
54+
if num is None:
55+
num = self.num
56+
first_name_list = [random.choice(fname) for _ in range(num)]
5657
return first_name_list
5758

58-
def last_name(self):
59-
# print last name
60-
last_name_list = [random.choice(lname) for _ in range(self.num)]
59+
def last_name(self, num=None):
60+
if num is None:
61+
num = self.num
62+
last_name_list = [random.choice(lname) for _ in range(num)]
6163
return last_name_list
6264

63-
def full_name(self):
64-
# print full name
65+
def full_name(self, num=None):
66+
if num is None:
67+
num = self.num
6568
full_name_list = [random.choice(
66-
fname) + ' ' + random.choice(lname) for _ in range(self.num)]
69+
fname) + ' ' + random.choice(lname) for _ in range(num)]
6770
return full_name_list
6871

69-
def full_profile(self):
72+
def full_profile(self, num=None):
73+
if num is None:
74+
num = self.num
7075
profile_list = []
71-
for _ in range(self.num):
76+
for _ in range(num):
7277
first = random.choice(fname)
7378
last = random.choice(lname)
7479
hair_color = random.choice(hair_colors)
7580
blood_type = random.choice(blood_types)
7681
full_name = first + ' ' + last
77-
phone = f'+ +1-{random.randint(300, 500)}-{random.randint(800, 999)}-{random.randint(1000,9999)}'
82+
phone = f'+1-{random.randint(300, 500)}-{random.randint(800, 999)}-{random.randint(1000,9999)}'
7883
job_title = random.choice(job_titles)
7984
ip_address = ipv4_gen()
8085
email_domain = random.choice(email_domains)
81-
dob, age = genrate_dob_age()
82-
height, weight = genrate_random_height_weight()
86+
87+
dob, age = generate_dob_age()
88+
height, weight = generate_random_height_weight()
8389

8490
street_num = random.randint(100, 999)
8591
street = random.choice(street_names)

random_profile/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def load_txt_file(file_name: str) -> list:
1717
def ipv4_gen() -> str:
1818
return f"{random.randint(0,255)}.{random.randint(0,255)}.{random.randint(0,255)}.{random.randint(0,255)}"
1919

20-
def genrate_dob_age():
20+
def generate_dob_age():
2121
month = random.randint(1, 12)
2222
if month == 2: # if month is feb
2323
day = random.randint(1, 28)
@@ -35,7 +35,7 @@ def genrate_dob_age():
3535

3636
return dob, age
3737

38-
def genrate_random_height_weight():
38+
def generate_random_height_weight():
3939
height = random.randint(140, 200)
4040
if height < 150:
4141
weight = random.randint(40, 60)

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import setuptools
2+
from glob import glob
23

34
with open("README.md", "r") as fh:
45
long_description = fh.read()
@@ -7,9 +8,9 @@
78
# Here is the module name.
89
name="random_profile",
910
# version of the module
10-
version="0.2.0",
11+
version="0.2.3",
1112
# Name of Author
12-
author="CodePerfectPlus",
13+
author="Deepak Raj",
1314
# your Email address
1415
author_email="[email protected]",
1516
# Small Description about module
@@ -18,13 +19,16 @@
1819
# Specifying that we are using markdown file for description
1920
long_description_content_type="text/markdown",
2021
# Any link to reach this module, if you have any webpage or github profile
22+
data_files= [( 'assets', glob('random_profile/assets/*'))],
2123
url="https://github.com/codePerfectPlus/Random-Profile-Generator",
2224
packages=setuptools.find_packages(),
2325
# classifiers like program is suitable for python3, just leave as it is.
2426
classifiers=[
2527
"Programming Language :: Python :: 3",
2628
"License :: OSI Approved :: MIT License",
2729
"Operating System :: OS Independent",
30+
"Topic :: Software Development :: Libraries :: Python Modules",
31+
"Topic :: Utilities",
2832
],
2933
entry_points={
3034
"console_scripts": ["random_profile = random_profile.__main__:main"],

0 commit comments

Comments
 (0)