Skip to main content

ReQBodyMan to easily manage body data received with Request

Project description

BrainyTechLogo

Project Description

ReQBodyMan is a package that you can use to manage the validations of body data coming with Request more effectively.

Installation

1 Install to Package

For Windows

pip install ReQBodyMan

For Linux/MacOs

pip3 install ReQBodyMan

2 Dependencies Package

flask

Usage

1 Import The Package

from ReQBodyMan.ReQBodyMan import ReQBodyMan

2 ReQBodyMan Create Object

ReQBodyMans = ReQBodyMan()

3 Get Form Data

If the data comes from the request with a form, you can get the data as follows.

GetData : 
    string, int, float, boolean, list, dict,

Parameters:
    variableName : str, 
    variableType : str, 
    booleanType  : str  > default = "int" NoneRequired

Return: 
    data : str, int, float, bool, list, dict, None

data = ReQBodyMans.form(variableName, variableType, booleanType="int")

data = ReQBodyMans.form("variableName", "str")
data = ReQBodyMans.form("variableName", "int")
data = ReQBodyMans.form("variableName", "float")
data = ReQBodyMans.form("variableName", "bool", booleanType="bool")
data = ReQBodyMans.form("variableName", "bool", booleanType="int" )
data = ReQBodyMans.form("variableName", "list")
data = ReQBodyMans.form("variableName", "dict")

If Variable Type is sent outside the specified format, return None.

4 Get Json Data

GetData: 
    string, int, float, boolean, list, dict,

Parameters: 
    variableName : str, 
    variableType : str, 
    booleanType  : str  > default = "int" NoneRequired

Return:
    data : str, int, float, bool, list, dict, None

data = ReQBodyMans.json(variableName, variableType, booleanType="int")

data = ReQBodyMans.json("variableName", "str")
data = ReQBodyMans.json("variableName", "int")
data = ReQBodyMans.json("variableName", "float")
data = ReQBodyMans.json("variableName", "bool", booleanType="bool")
data = ReQBodyMans.json("variableName", "bool", booleanType="int")
data = ReQBodyMans.json("variableName", "list")
data = ReQBodyMans.json("variableName", "dict")

If Variable Type is sent outside the specified format, return None.

5 Get File

GetData: 
    file, files

Return: 
    data: file or files, None

data = ReQBodyMans.file()

6 Get SpecificFile

GetData: 
    file

Parameters: 
    fileName : str

Return:
    data: file, None

data = ReQBodyMans.specificFile(fileName)

If FileName is not in request.file, the value None is returned.

7 Get Params

Data : 
    string, int, float, boolean, list, dict,

Parameters: 
    variableName : str, 
    variableType : str, 
    booleanType  : str  > default = "int" NoneRequired

Return:
    data : str, int, float, bool, list, dict, None

data = ReQBodyMans.params(variableName, variableType, booleanType="int")

data = ReQBodyMans.params("variableName", "str")
data = ReQBodyMans.params("variableName", "int")
data = ReQBodyMans.params("variableName", "float")
data = ReQBodyMans.params("variableName", "bool", booleanType="bool")
data = ReQBodyMans.params("variableName", "bool", booleanType="int")
data = ReQBodyMans.params("variableName", "list")
data = ReQBodyMans.params("variableName", "dict")

8 GetAllData Function

Data: 
    string, int, float, boolean, list, dict, file

Parameters: 
    bodyJson: dict

variableName: Variable name in body data 

bodyType:  
    form, json, params, file

booleanType:
    int, bool

Return: 
    data: dict or None

data = ReQBodyMans.getAllData(bodyJson)

bodyJson = {

    "variableName" : ["bodyType", "variableType", "booleanType"]
}

# BodyType Json

bodyJson = {
    
    "password"  : ["json", "str"],
    "email"     : ["json", "str"]
}

# Boolean Type Usage 

bodyJson = {
    
    "password"  : ["json", "str"],
    "email"     : ["json", "str"],
    "status"    : ["json", "bool", "int"]
    "status2"   : ["json", "bool", "bool"]
}

# BodyType Form

bodyJson = {
    
    "password"  : ["form", "str"],
    "email"     : ["form", "str"],
    "status"    : ["form", "bool", "int"]
    "status2"   : ["form", "bool", "bool"]
    "fileName"  : ["file"] 
}

# BodyForm Params

bodyJson = {
    
    "password"  : ["params", "str"],
    "email"     : ["params", "str"],
    "status"    : ["params", "bool", "int"]
    "status2"   : ["params", "bool", "bool"] 
}

data = ReQBodyMans.getAllData(bodyJson)

Return data content 

{
    "email" : "test@test.com",
    "password":"test2",
    "status" : "1" or "0",
    "status2" : True or False,
    "fileName" : file
}

9 GetAllDataHero Function

Data : 
    string, int, float, boolean, list, dict, file, files

Parameters: 
    bodyJson: dict

type: 
    form, json, params

variableName: 
    Variable name in body data

variableType:
    string, int, float, boolean, list, dict, file, files

booleanType: 
    int, bool

Return: 
    data:dict, None

data = ReQBodyMans.getAllDataHero(bodyJson)

bodyJson = {

    "type"=type, # required Key
    "variableName" : ["variableType", "booleanType"]
}

# BodyType Json

bodyJson = {
    
    "type":"json",
    "password"  : ["str"],
    "email"     : ["str"]
}

# Boolean Type Usage 

bodyJson = {
    
    "type":"json",
    "password"  : ["str"],
    "email"     : ["str"],
    "status"    : ["bool", "int"]
    "status2"   : ["bool", "bool"]
}

# BodyType Form

bodyJson = {
    
    "type":"form",
    "password"  : ["str"],
    "email"     : ["str"],
    "status"    : ["bool", "int"]
    "status2"   : ["bool", "bool"]
    "fileName"  : ["file"] # get all file in request.files
    "fileName2" : ["files"] # Fetches only the file named file from request.files
}

# BodyType Params

bodyJson = {

    "type":"params",
    "password"  : ["str"],
    "email"     : ["str"],
    "status"    : ["bool", "int"]
    "status2"   : ["bool", "bool"] 
}

data = ReQBodyMans.getAllDataHero(bodyJson)

Return data content 

{
    "email" : "test@test.com",
    "password":"test2",
    "status" : "1" or "0",
    "status2" : True or False,
    "fileName" : files,
    "fileName2" : file
}

If Variable Type is sent outside the specified format, return None.

Release Note

v.1.4.1

  1. ReadMe Updated

v.1.4.0

  1. Major BugFix

    • file and specificFile Function
  2. ReadMe Updated

    • Instructions for use have been updated.

v.1.3.0

  1. getAllDataHero Function Added

    • Allows you to send all data at once more easily than v1 and receive data as a dictionary
  2. specificFile Function Added

    • The feature of getting what we want from more than 1 file sent in the request.files has been added.
  3. file Function Updated

    • File function has been updated to receive all incoming files in request.files.
    • file function name updated to files

v.1.2.2

  1. ReadMe file updated

v.1.2.1

  1. ReadMe file updated

v1.2.0

  1. getAllData Function Added
    • Allows you to send all the data at once and receive the data as a dictionary

v.1.1.0

  1. Added dict property to Params.
  2. Added dict property to Json
  3. The return value for bool type has been added to return int or bool type according to the value to be given with booleanType.
  4. Code refactor.

v.1.0.1

  1. ReadMe file updated

v.1.0.0

  1. Project published.

ReQBodyMan is a BrainyTech Product.

Developer : Murat Bilginer

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ReQBodyMan-1.4.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ReQBodyMan-1.4.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file ReQBodyMan-1.4.1.tar.gz.

File metadata

  • Download URL: ReQBodyMan-1.4.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ReQBodyMan-1.4.1.tar.gz
Algorithm Hash digest
SHA256 522b78a9e2819e444e20cf587f0e50b165dd894b02c03edf5a2570be672b05c6
MD5 bd8bb8dfaedaea50636237452ab746d1
BLAKE2b-256 d1e471cb47764d0c5e2450321fc6070bbfdb3a32a3f9e98eea7f98a5ba088e50

See more details on using hashes here.

File details

Details for the file ReQBodyMan-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: ReQBodyMan-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ReQBodyMan-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 760236a87a3da718757d75cdcf6121c39b22cfe1d3b742bb49593290dbd5afb8
MD5 bb7bb789012d5a1eed3300d08079b4f1
BLAKE2b-256 308dece58e6320ab2ee7dd1bf9d07f56a1f42d256ee8a2bb8b3b6bedad97aba2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page