Skip to content

Commit

Permalink
refacoting code and changelog update
Browse files Browse the repository at this point in the history
  • Loading branch information
codeperfectplus committed Nov 7, 2022
1 parent 8126dee commit bb2dd9a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
23 changes: 19 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ All notable changes to this project will be documented in this file. The format

## Changelog

## [Unreleased]
## [V3.0.0] - Major Release

- Moved test files to random_profile to avoid flake8:402 error
- Following proper changelog format, added changelog file
- Added config for readthedocs
- [x] Function names changed
- [x] Gender can be passed as a parameter
- [x] Credit/Debit information will be generate
- [x]

## [v2.0.0] Major Release - 07-11-2022

- server can be start from cli
- More Endpoints exposed to the API/CLI
- Code refactored

## [V1.0.0] Major Release - 05-11-2022

Beautiful command line output
Moved test files to random_profile to avoid flake8:402 error
Following proper changelog format, added changelog file
Docs: Added documentation for the project
Bug fixed: Fixed a bug with random_profile import

## [v0.2.3] - 13-10-2022

Expand Down
4 changes: 4 additions & 0 deletions random_profile/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import sys
import random
import argparse
from pprint import pprint

Expand All @@ -12,6 +13,7 @@

parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version', action='version', version=VERSION)
parser.add_argument('--repeat', help='Repeat the output', action='store_true')
parser.add_argument('--server', help='Start server', action='store_true')
parser.add_argument('--port', help='Port number', type=int, default=8000)
parser.add_argument('-n', '--number', help='Number of random profiles', type=int, default=1)
Expand All @@ -31,6 +33,8 @@
output_form_arg_group.add_argument('-a', '--address', help='Get address', action='store_true')
args = parser.parse_args()

if args.repeat:
random.seed(0)

def main():
gender = None
Expand Down
41 changes: 27 additions & 14 deletions random_profile/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from random_profile.enums.gender import Gender
from random_profile import utils

VERSION = '2.0.1'
VERSION = '3.0.0'

lname_txt = os.path.join(utils.ASSETS_DIR, "lnames.txt")
fname_male_txt = os.path.join(utils.ASSETS_DIR, "fnames_male.txt")
Expand All @@ -43,12 +43,28 @@


class RandomProfile(object):
""" Random Profile Generator
Args:
num (int, optional): Total No. of Name You Want To Print. Defaults to 1.
gender(str, optional): default is None. if you want to generate define gender then pass
Methods:
full_profiles: Generate Full Profile
first_names: Generate First Name
last_names: Generate Last Name
full_names: Generate Full Name
email: Generate Email
phone_number: Generate Phone Number
dob_age: Generate Date of Birth and Age
height_weight: Generate Height and Weight
address: Generate Address
ip_address: Generate IP Address
hair_color: Generate Hair Color
blood_type: Generate Blood Type
job_title: Generate Job Title
"""
def __init__(self, num: int = 1, gender: Gender = None):
"""
num = Total No. of Name You Want To Print
default is 1
To Print More Than one Name Change value of num
"""
self.num = num
self.gender = gender

Expand Down Expand Up @@ -132,8 +148,9 @@ def generate_address(self, num: int = None) -> List[str]:

def first_names(self, num: int = None, gender: Gender = None) -> list:
num = self.num if num is None else num
if gender is None:
gender = self.gender
gender = self.gender if gender is None else gender

# DRY CODE
if gender is None:
names = fname_female + fname_male
elif gender.value == Gender.MALE.value:
Expand All @@ -148,17 +165,14 @@ def first_names(self, num: int = None, gender: Gender = None) -> list:

def last_names(self, num: int = None) -> list:
num = self.num if num is None else num
if num is None:
num = self.num
if num == 1 or num is None:
return random.choice(lname)

return random.choices(lname, k=num)

def full_names(self, num: int = None, gender: Gender = None) -> list:
num = self.num if num is None else num

if gender is None:
gender = self.gender
gender = self.gender if gender is None else gender

if gender is None:
names = fname_female + fname_male
Expand All @@ -178,7 +192,6 @@ def full_profiles(self, num: int = None, gender: Gender = None) -> list:
profile_list = []

for _ in range(num):

# random gender for every profile in list
this_gender = utils.generate_random_gender() if gender is None else gender
first = random.choice(fname_male if this_gender.value == Gender.MALE.value else fname_female)
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pytest
fastapi
uvicorn
codecov
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
with open("README.md", "r") as fh:
long_description = fh.read()

with open("requirements.txt", "r") as fh:
requirements = fh.read().splitlines()

setuptools.setup(
name="random_profile",
version="2.0.0",
Expand All @@ -12,9 +15,13 @@
description="Generate Random Profile",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=requirements,
data_files=[('assets', glob('random_profile/assets/*'))],
url="https://github.com/codePerfectPlus/Random-Profile-Generator",
packages=setuptools.find_packages(),
project_urls={"Documentation": "https://pycontributors.readthedocs.io/projects/randomprofilegenerator/en/latest/",
"Source": "https://github.com/Py-Contributors/RandomProfileGenerator",
"Tracker": "https://github.com/Py-Contributors/RandomProfileGenerator/issues"},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
Expand All @@ -25,6 +32,8 @@
"Topic :: Utilities",
"Environment :: Plugins"],
entry_points={
"console_scripts": ["random_profile = random_profile.__main__:main"],
"console_scripts": ['rp = random_profile.cli:main',
"random_profile = random_profile.cli:main"],

},
)
)

0 comments on commit bb2dd9a

Please sign in to comment.