Skip to content

Commit

Permalink
v0.2.3 initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
codeperfectplus committed Oct 12, 2022
1 parent c96488b commit 0c0b65e
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 26 deletions.
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">
<br>
Random Profile Generator
Random Profile Generator V0.2.3
<br>
</h1>

Expand Down Expand Up @@ -30,17 +30,19 @@ default is 1
change the num value according to your needs.
'''
# num can be overwritten in the function

# For first name
rp.first_name()
rp.first_name(num=10)

# For full name
rp.full_name()
rp.full_name(num=8)

# For full profile
rp.full_profile()
# override the num value
rp.full_profile(num=10)

# For last name
rp.last_name()
rp.last_name(num=6)
```

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

## Changelog

v0.2.3
- Flask app added
- Date of Birth Added
- Age added
- Height and Weight Added
- Blood Group and hair color added
- Job title added
- More email domains added
- Bugs Fixed

v0.2.1
- More variation added to the data
- Test cases added
- Created a separate file for data loadings
- Fixed some bugs

## Contributing

Before submitting a bug, please do the following:
Expand Down
27 changes: 27 additions & 0 deletions api/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from flask import Flask, jsonify
from random_profile import RandomProfile

# random_profile==0.2.3 required
rp = RandomProfile()
app = Flask(__name__)

@app.route('/')
def index():
return jsonify({'message': 'api is working'})

@app.route('/api/v1/random_profile')
def single_profile():
profile = rp.full_profile()
return jsonify({'profile': profile})

@app.route('/api/v1/random_profile/<int:num>')
def multiple_profile(num):
if num > 100:
num = 100
profile = rp.full_profile(num)
return jsonify({'profile': profile})


if __name__ == '__main__':
app.run(debug=True)
2 changes: 2 additions & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
random-profile==0.2.3
flask
38 changes: 22 additions & 16 deletions random_profile/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

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
from random_profile.utils import generate_dob_age
from random_profile.utils import generate_random_height_weight

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

Expand Down Expand Up @@ -50,36 +50,42 @@ def __init__(self, num=1):
'''
self.num = num

def first_name(self):
# print first name
first_name_list = [random.choice(fname) for _ in range(self.num)]
def first_name(self, num=None):
if num is None:
num = self.num
first_name_list = [random.choice(fname) for _ in range(num)]
return first_name_list

def last_name(self):
# print last name
last_name_list = [random.choice(lname) for _ in range(self.num)]
def last_name(self, num=None):
if num is None:
num = self.num
last_name_list = [random.choice(lname) for _ in range(num)]
return last_name_list

def full_name(self):
# print full name
def full_name(self, num=None):
if num is None:
num = self.num
full_name_list = [random.choice(
fname) + ' ' + random.choice(lname) for _ in range(self.num)]
fname) + ' ' + random.choice(lname) for _ in range(num)]
return full_name_list

def full_profile(self):
def full_profile(self, num=None):
if num is None:
num = self.num
profile_list = []
for _ in range(self.num):
for _ in range(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)}'
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()

dob, age = generate_dob_age()
height, weight = generate_random_height_weight()

street_num = random.randint(100, 999)
street = random.choice(street_names)
Expand Down
4 changes: 2 additions & 2 deletions random_profile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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():
def generate_dob_age():
month = random.randint(1, 12)
if month == 2: # if month is feb
day = random.randint(1, 28)
Expand All @@ -35,7 +35,7 @@ def genrate_dob_age():

return dob, age

def genrate_random_height_weight():
def generate_random_height_weight():
height = random.randint(140, 200)
if height < 150:
weight = random.randint(40, 60)
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import setuptools
from glob import glob

with open("README.md", "r") as fh:
long_description = fh.read()
Expand All @@ -7,9 +8,9 @@
# Here is the module name.
name="random_profile",
# version of the module
version="0.2.0",
version="0.2.3",
# Name of Author
author="CodePerfectPlus",
author="Deepak Raj",
# your Email address
author_email="deepak008@live.com",
# Small Description about module
Expand All @@ -18,13 +19,16 @@
# Specifying that we are using markdown file for description
long_description_content_type="text/markdown",
# Any link to reach this module, if you have any webpage or github profile
data_files= [( 'assets', glob('random_profile/assets/*'))],
url="https://github.com/codePerfectPlus/Random-Profile-Generator",
packages=setuptools.find_packages(),
# classifiers like program is suitable for python3, just leave as it is.
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
],
entry_points={
"console_scripts": ["random_profile = random_profile.__main__:main"],
Expand Down

0 comments on commit 0c0b65e

Please sign in to comment.