Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #44 #52

Merged
merged 15 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github : [codeperfectplus]
custom: ["https://www.buymeacoffee.com/codeperfectplus"]
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: >-
python setup.py sdist
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: flake8 . --isolated --exclude=.cache,.venv,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,**/migrations/** --ignore=E501,E402
run: flake8 . --isolated --exclude=.cache,.venv,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,**/migrations/** --ignore=E203,W503,E501,F401
13 changes: 2 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@ All notable changes to this project will be documented in this file. The format

## Changelog

## [2.0.0] - 07-11-2022
## [Unreleased]

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


## [1.0.0] - 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
- Added config for readthedocs

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

Expand Down
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ We love your input! We want to make contributing to this project as easy and tra

- Create a PR from our repo on Github.

### Run Flake8

```sh
flake8 . --isolated --ignore=E501,E402
```

### Additional Notes

- Any changes should be made in the `dev` branch.
Expand Down
25 changes: 7 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a href="https://pypi.org/project/random-profile/">
Random Profile Generator
</a>
V2.0.0
V0.2.3
</h1>

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

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

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

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

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


[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/)

```sh
pip install random-profile
```

## Documentation

Full Documentation is available at [ReadTheDocs](https://randomprofilegenerator.readthedocs.io/en/latest/)
Documentation is available at [ReadTheDocs](https://randomprofilegenerator.readthedocs.io/en/latest/)

## Upcoming Features

- More Data Fields
- More Data Types
- Make it more user friendly and easy to use
- Make it more efficient and faster
- Cython Support
- Support for more languages

## Changelog

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

## License

The project is licensed under the <a href="/LICENSE">MIT</a> license.
The project is licensed under the <a href="/LICENSE">MIT</a> license.

## Contributors

<a href="https://github.com/codePerfectPlus/awesomeScripts/graphs/contributors">
<img src="https://contrib.rocks/image?repo=codePerfectPlus/randomprofilegenerator" />
</a>

## Sponsor

Email: [Pycontributors](mailto:deepak008@live.com) for sponsorship details.
118 changes: 118 additions & 0 deletions api/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import uvicorn
from fastapi import FastAPI, Depends
from fastapi.openapi.utils import get_openapi

from pydantic import create_model
from random_profile import RandomProfile

# random_profile==0.2.3 required
rp = RandomProfile()
app = FastAPI()

query_model = create_model("num", num=(int, ...))
api_version = "0.2.3"


@app.get("/")
def index():
return {"status": "200",
"message": "Welcome to Random Profile Generator API",
"version": api_version}


@app.get('/api/v1/random_profile/full_profile')
async def multiple_profile(params: query_model = Depends()):
""" Get multiple profile with all details

args:
num (int): number of profiles to generate
"""
params_as_dict = params.dict()
if params_as_dict['num'] > 100:
return {"status": "400",
"message": "Number of profiles should be less than 100",
"version": api_version}

num = params_as_dict['num']
profile = rp.full_profile(num)
return profile


@app.get('/api/v1/random_profile/first_name')
async def multiple_first_name(params: query_model = Depends()):
""" Get multiple first names

args:
num (int): number of first names to generate

"""
params_as_dict = params.dict()
if params_as_dict['num'] > 100:
return {"status": "400",
"message": "Number of profiles should be less than 100",
"version": api_version}

num = params_as_dict['num']
first_names = rp.first_name(num)
return first_names


@app.get('/api/v1/random_profile/last_name')
async def multiple_last_name(params: query_model = Depends()):
""" Get multiple last names

args:
num (int): number of last names to generate

"""
params_as_dict = params.dict()
if params_as_dict['num'] > 100:
return {"status": "400",
"message": "Number of profiles should be less than 100",
"version": api_version}

num = params_as_dict['num']
last_names = rp.last_name(num)
return last_names


@app.get('/api/v1/random_profile/full_name')
async def multiple_full_name(params: query_model = Depends()):
""" Get multiple full names

args:
num (int): number of full names to generate

"""
params_as_dict = params.dict()
if params_as_dict['num'] > 100:
return {"status": "400",
"message": "Number of profiles should be less than 100",
"version": api_version}

num = params_as_dict['num']

full_names = rp.full_name(num)
return full_names


def custom_openapi():
if app.openapi_schema:
return app.openapi_schema
openapi_schema = get_openapi(
title="Random Profile Generator API",
version=api_version,
description="Python Module To Generate Random Profile Data",
routes=app.routes,
)
openapi_schema["info"]["x-logo"] = {
"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"
}
app.openapi_schema = openapi_schema
return app.openapi_schema


app.openapi = custom_openapi

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
3 changes: 3 additions & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
random-profile==0.2.3
fastapi
uvicorn
Binary file removed docs/assets/sample.png
Binary file not shown.
69 changes: 28 additions & 41 deletions docs/command_line_usage.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Command line usages
===================
=========

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

.. code-block:: bash

rp --help or random_profile -h
Usage: rp [OPTIONS]
random-profile --help
Usage: random-profile [OPTIONS]

rp -n 10 -p
random-profile -n 10 -p

optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--server Start server
--port PORT Port number
-n N Number of random profiles
-p, --profile Get full profile
-f, --firstname Get first name
-l, --lastname Get last name instead of first name
--fullname Get full name instead of first name
--ip Get an ipv4 IP address
--job Get job title
--address Get address

-h, --help show this help message and exit
-n N Number of random profiles

-f, --fullname Get full name instead of first name
-p, --profile Get full profile instead of first name
-l, --lastname Get last name instead of first name
-ip, --ipv4 Get an ipv4 IP address
-j, --jobtitle Get job title

Get Random Profile:
-------------------
------------

.. code-block:: bash

# n = number of random profiles, p = profile
rp -n 10 -p
random_profile -n 10 -p

Get First Name:
---------------
------------

.. code-block:: bash

# n = number of random profiles, f = first name
rp -n 10 -f
random_profile -n 10 -f

Get Last Name:
--------------
------------

.. code-block:: bash

# n = number of random profiles, l = last name
rp -n 10 -l
random_profile -n 10 -l

Get Job Title:
--------------
------------

.. code-block:: bash

# n = number of random profiles, j = job title
rp -n 10 -j
random_profile -n 10 -j

Get IPv4 Address:
-----------------
------------

.. code-block:: bash

# n = number of random profiles, ip = ipv4
rp -n 10 -ip

random_profile -n 10 -ip

Get Random Profile and Save to File:
------------------------------------

.. code-block:: bash

# n = number of random profiles, p = profile
rp -n 10 -p > rps.txt
------------

.. code-block:: bash

# save to a file
# n = number of random profiles, p = profile
rp -n 10 -p >> rps.txt

random_profile -n 10 -p > random_profiles.txt

Get Random Profile version:
---------------------------
------------

.. code-block:: bash

rp --version

rp 0.2.3
random_profile --version

random-profile 0.2.3
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
project = 'Random Profile Generator'
description = 'A random profile generator for testing purposes.'
author = 'Deeapk Raj'
release = '1.0.1'
release = '0.2.3'
year = datetime.now().year
copyright = "{} Deepak Raj".format(year)
source_suffix = ".rst"
Expand Down
2 changes: 1 addition & 1 deletion docs/import_as_module.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import as module
----------------
------------

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

Expand Down