Skip to content

Commit 7040dc5

Browse files
authored
Issue #44 (#52)
* add gender options for first names * add gender options for first names, random card * add job experience according to years of age * add parameter option for logging (not implemented yet) * add handpicked locations to cities in list * add float coords generation * add coordinates string formatting * fix ages in job level generation * start of unit tests * add more tests * add assertregex ussage in tests * fix missing imports * lint fixes * two lines padding before class
1 parent c960b59 commit 7040dc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1768
-865
lines changed

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github : [codeperfectplus]
1+
custom: ["https://www.buymeacoffee.com/codeperfectplus"]

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run: >-
1616
python setup.py sdist
1717
- name: Publish distribution to PyPI
18-
uses: pypa/gh-action-pypi-publish@release/v1
18+
uses: pypa/gh-action-pypi-publish@master
1919
with:
2020
user: __token__
2121
password: ${{ secrets.pypi_password }}

.github/workflows/python-app.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
python -m pip install --upgrade pip
1515
pip install flake8
1616
- name: Lint with flake8
17-
run: flake8 . --isolated --exclude=.cache,.venv,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,**/migrations/** --ignore=E501,E402
17+
run: flake8 . --isolated --exclude=.cache,.venv,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,**/migrations/** --ignore=E203,W503,E501,F401

CHANGELOG.md

+2-11
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,11 @@ All notable changes to this project will be documented in this file. The format
44

55
## Changelog
66

7-
## [2.0.0] - 07-11-2022
7+
## [Unreleased]
88

9-
- server can be start from cli
10-
- More Endpoints exposed to the API/CLI
11-
- Code refactored
12-
13-
14-
## [1.0.0] - 05-11-2022
15-
16-
- Beautiful command line output
179
- Moved test files to random_profile to avoid flake8:402 error
1810
- Following proper changelog format, added changelog file
19-
- Docs: Added documentation for the project
20-
- Bug fixed: Fixed a bug with random_profile import
11+
- Added config for readthedocs
2112

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

CONTRIBUTING.md

-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ We love your input! We want to make contributing to this project as easy and tra
5050

5151
- Create a PR from our repo on Github.
5252

53-
### Run Flake8
54-
55-
```sh
56-
flake8 . --isolated --ignore=E501,E402
57-
```
58-
5953
### Additional Notes
6054

6155
- Any changes should be made in the `dev` branch.

README.md

+7-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<a href="https://pypi.org/project/random-profile/">
44
Random Profile Generator
55
</a>
6-
V2.0.0
6+
V0.2.3
77
</h1>
88

99
<h4 align="center">Python Module To Generate Random Profile Data</h4>
@@ -19,34 +19,27 @@
1919
<img src="https://img.shields.io/pypi/dw/random-profile.svg">
2020
<img src="https://img.shields.io/pypi/dm/random-profile.svg">
2121
</p>
22-
<p align="center">
22+
<p align="center">
2323

2424
<img alt="GitHub pull-requests" src="https://img.shields.io/github/issues-pr/Py-Contributors/RandomProfileGenerator">
2525

26-
<img alt="GitHub forks" src="https://img.shields.io/github/forks/Py-Contributors/RandomProfileGenerator">
26+
<img alt="GitHub forks" src="https://img.shields.io/github/forks/Py-Contributors/RandomProfileGenerator">
2727

28-
<img alt="contributors" src="https://img.shields.io/github/contributors/Py-Contributors/RandomProfileGenerator">
28+
<img alt="contributors" src="https://img.shields.io/github/contributors/Py-Contributors/RandomProfileGenerator">
2929

3030
<img alt="GitHub stars" src="https://img.shields.io/github/stars/Py-Contributors/RandomProfileGenerator"> </p>
3131

3232

3333
[RandomProfile](https://pypi.org/project/random-profile/) is a powerful and simple tool to generate fake data. You can use it to mock classes, populate databases and much more. You can check the full documentation here. Check on [Pypi](https://pypi.org/project/random-profile/)
3434

35-
```sh
36-
pip install random-profile
37-
```
3835

3936
## Documentation
4037

41-
Full Documentation is available at [ReadTheDocs](https://randomprofilegenerator.readthedocs.io/en/latest/)
38+
Documentation is available at [ReadTheDocs](https://randomprofilegenerator.readthedocs.io/en/latest/)
4239

4340
## Upcoming Features
4441

45-
- More Data Fields
46-
- More Data Types
47-
- Make it more user friendly and easy to use
48-
- Make it more efficient and faster
49-
- Cython Support
42+
- Support for more languages
5043

5144
## Changelog
5245

@@ -58,14 +51,10 @@ Check the [Contributing](/CONTRIBUTING.md) for the contribution guidelines.
5851

5952
## License
6053

61-
The project is licensed under the <a href="/LICENSE">MIT</a> license.
54+
The project is licensed under the <a href="/LICENSE">MIT</a> license.
6255

6356
## Contributors
6457

6558
<a href="https://github.com/codePerfectPlus/awesomeScripts/graphs/contributors">
6659
<img src="https://contrib.rocks/image?repo=codePerfectPlus/randomprofilegenerator" />
6760
</a>
68-
69-
## Sponsor
70-
71-
Email: [Pycontributors](mailto:deepak008@live.com) for sponsorship details.

api/api.py

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import uvicorn
2+
from fastapi import FastAPI, Depends
3+
from fastapi.openapi.utils import get_openapi
4+
5+
from pydantic import create_model
6+
from random_profile import RandomProfile
7+
8+
# random_profile==0.2.3 required
9+
rp = RandomProfile()
10+
app = FastAPI()
11+
12+
query_model = create_model("num", num=(int, ...))
13+
api_version = "0.2.3"
14+
15+
16+
@app.get("/")
17+
def index():
18+
return {"status": "200",
19+
"message": "Welcome to Random Profile Generator API",
20+
"version": api_version}
21+
22+
23+
@app.get('/api/v1/random_profile/full_profile')
24+
async def multiple_profile(params: query_model = Depends()):
25+
""" Get multiple profile with all details
26+
27+
args:
28+
num (int): number of profiles to generate
29+
"""
30+
params_as_dict = params.dict()
31+
if params_as_dict['num'] > 100:
32+
return {"status": "400",
33+
"message": "Number of profiles should be less than 100",
34+
"version": api_version}
35+
36+
num = params_as_dict['num']
37+
profile = rp.full_profile(num)
38+
return profile
39+
40+
41+
@app.get('/api/v1/random_profile/first_name')
42+
async def multiple_first_name(params: query_model = Depends()):
43+
""" Get multiple first names
44+
45+
args:
46+
num (int): number of first names to generate
47+
48+
"""
49+
params_as_dict = params.dict()
50+
if params_as_dict['num'] > 100:
51+
return {"status": "400",
52+
"message": "Number of profiles should be less than 100",
53+
"version": api_version}
54+
55+
num = params_as_dict['num']
56+
first_names = rp.first_name(num)
57+
return first_names
58+
59+
60+
@app.get('/api/v1/random_profile/last_name')
61+
async def multiple_last_name(params: query_model = Depends()):
62+
""" Get multiple last names
63+
64+
args:
65+
num (int): number of last names to generate
66+
67+
"""
68+
params_as_dict = params.dict()
69+
if params_as_dict['num'] > 100:
70+
return {"status": "400",
71+
"message": "Number of profiles should be less than 100",
72+
"version": api_version}
73+
74+
num = params_as_dict['num']
75+
last_names = rp.last_name(num)
76+
return last_names
77+
78+
79+
@app.get('/api/v1/random_profile/full_name')
80+
async def multiple_full_name(params: query_model = Depends()):
81+
""" Get multiple full names
82+
83+
args:
84+
num (int): number of full names to generate
85+
86+
"""
87+
params_as_dict = params.dict()
88+
if params_as_dict['num'] > 100:
89+
return {"status": "400",
90+
"message": "Number of profiles should be less than 100",
91+
"version": api_version}
92+
93+
num = params_as_dict['num']
94+
95+
full_names = rp.full_name(num)
96+
return full_names
97+
98+
99+
def custom_openapi():
100+
if app.openapi_schema:
101+
return app.openapi_schema
102+
openapi_schema = get_openapi(
103+
title="Random Profile Generator API",
104+
version=api_version,
105+
description="Python Module To Generate Random Profile Data",
106+
routes=app.routes,
107+
)
108+
openapi_schema["info"]["x-logo"] = {
109+
"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"
110+
}
111+
app.openapi_schema = openapi_schema
112+
return app.openapi_schema
113+
114+
115+
app.openapi = custom_openapi
116+
117+
if __name__ == "__main__":
118+
uvicorn.run(app, host="0.0.0.0", port=8000)

api/requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
random-profile==0.2.3
2+
fastapi
3+
uvicorn

docs/assets/sample.png

-120 KB
Binary file not shown.

docs/command_line_usage.rst

+28-41
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Command line usages
2-
===================
2+
=========
33

44
`Random Profile Generator` can be used as a command line tool.
55
It can be used to generate a random profile and save it to a file.
@@ -9,87 +9,74 @@ Usages:
99

1010
.. code-block:: bash
1111
12-
rp --help or random_profile -h
13-
Usage: rp [OPTIONS]
12+
random-profile --help
13+
Usage: random-profile [OPTIONS]
1414
15-
rp -n 10 -p
15+
random-profile -n 10 -p
1616
1717
optional arguments:
18-
-h, --help show this help message and exit
19-
-v, --version show program's version number and exit
20-
--server Start server
21-
--port PORT Port number
22-
-n N Number of random profiles
23-
-p, --profile Get full profile
24-
-f, --firstname Get first name
25-
-l, --lastname Get last name instead of first name
26-
--fullname Get full name instead of first name
27-
--ip Get an ipv4 IP address
28-
--job Get job title
29-
--address Get address
30-
18+
-h, --help show this help message and exit
19+
-n N Number of random profiles
20+
21+
-f, --fullname Get full name instead of first name
22+
-p, --profile Get full profile instead of first name
23+
-l, --lastname Get last name instead of first name
24+
-ip, --ipv4 Get an ipv4 IP address
25+
-j, --jobtitle Get job title
26+
3127
Get Random Profile:
32-
-------------------
28+
------------
3329

3430
.. code-block:: bash
3531
3632
# n = number of random profiles, p = profile
37-
rp -n 10 -p
33+
random_profile -n 10 -p
3834
3935
Get First Name:
40-
---------------
36+
------------
4137

4238
.. code-block:: bash
4339
4440
# n = number of random profiles, f = first name
45-
rp -n 10 -f
41+
random_profile -n 10 -f
4642
4743
Get Last Name:
48-
--------------
44+
------------
4945

5046
.. code-block:: bash
5147
5248
# n = number of random profiles, l = last name
53-
rp -n 10 -l
49+
random_profile -n 10 -l
5450
5551
Get Job Title:
56-
--------------
52+
------------
5753

5854
.. code-block:: bash
5955
6056
# n = number of random profiles, j = job title
61-
rp -n 10 -j
57+
random_profile -n 10 -j
6258
6359
Get IPv4 Address:
64-
-----------------
60+
------------
6561

6662
.. code-block:: bash
6763
6864
# n = number of random profiles, ip = ipv4
69-
rp -n 10 -ip
70-
65+
random_profile -n 10 -ip
7166
7267
Get Random Profile and Save to File:
73-
------------------------------------
74-
75-
.. code-block:: bash
76-
77-
# n = number of random profiles, p = profile
78-
rp -n 10 -p > rps.txt
68+
------------
7969

8070
.. code-block:: bash
8171
82-
# save to a file
8372
# n = number of random profiles, p = profile
84-
rp -n 10 -p >> rps.txt
85-
73+
random_profile -n 10 -p > random_profiles.txt
8674
8775
Get Random Profile version:
88-
---------------------------
76+
------------
8977

9078
.. code-block:: bash
9179
92-
rp --version
93-
94-
rp 0.2.3
80+
random_profile --version
9581
82+
random-profile 0.2.3

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
project = 'Random Profile Generator'
55
description = 'A random profile generator for testing purposes.'
66
author = 'Deeapk Raj'
7-
release = '1.0.1'
7+
release = '0.2.3'
88
year = datetime.now().year
99
copyright = "{} Deepak Raj".format(year)
1010
source_suffix = ".rst"

docs/import_as_module.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Import as module
2-
----------------
2+
------------
33

44
You can import the module and use it in your own scripts.
55

0 commit comments

Comments
 (0)