From 0c0b65eef2331d29a32b6e9db22883f0bb195556 Mon Sep 17 00:00:00 2001 From: Deepak Raj <54245038+codePerfectPlus@users.noreply.github.com> Date: Thu, 13 Oct 2022 01:36:01 +0530 Subject: [PATCH] v0.2.3 initialized --- README.md | 32 ++++++++++++++++++++++++++------ api/api.py | 27 +++++++++++++++++++++++++++ api/requirements.txt | 2 ++ random_profile/main.py | 38 ++++++++++++++++++++++---------------- random_profile/utils.py | 4 ++-- setup.py | 8 ++++++-- 6 files changed, 85 insertions(+), 26 deletions(-) create mode 100644 api/api.py create mode 100644 api/requirements.txt diff --git a/README.md b/README.md index 6a825ab..b1af68c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@


- Random Profile Generator + Random Profile Generator V0.2.3

@@ -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 @@ -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: diff --git a/api/api.py b/api/api.py new file mode 100644 index 0000000..72187db --- /dev/null +++ b/api/api.py @@ -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/') +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) \ No newline at end of file diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 0000000..a71d178 --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,2 @@ +random-profile==0.2.3 +flask \ No newline at end of file diff --git a/random_profile/main.py b/random_profile/main.py index 1eb4b8a..8cfe53e 100644 --- a/random_profile/main.py +++ b/random_profile/main.py @@ -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__))) @@ -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) diff --git a/random_profile/utils.py b/random_profile/utils.py index 4338fd5..49e9b35 100644 --- a/random_profile/utils.py +++ b/random_profile/utils.py @@ -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) @@ -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) diff --git a/setup.py b/setup.py index e9dbb73..4536e3a 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import setuptools +from glob import glob with open("README.md", "r") as fh: long_description = fh.read() @@ -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 @@ -18,6 +19,7 @@ # 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. @@ -25,6 +27,8 @@ "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"],