Arrotechtools Library
Installation
Install the latest version:
pip install arrotechtools
To install a specific version:
pip install arrotechtools==1.6
Getting Started
After installation, you can immediately start using the library.
Importing a class, an object, or a method is straight forward.
Let simulate an import.
from arrotechtools import Serializer, Validate, ErrorHandler, admin_required
Validation
Supported validation inputs include:
- Password
- Integer
- Name
- Phone:
phone, airtel, safaricom, orange, equitel
| method | input type | sample |
|---|---|---|
| String | test@gmail.com | |
| password | String | HeuliaI!djvb24628 |
| integer | Integer | 23 + or - are also accepted i.e +25 or -22 |
| name | String | John doe |
| phone, airtel, safaricom, orange, equitel | String | +254712345678 |
Email validation Example
Lets begin with validating an email provided by a user.
from arrotechtools import Validate, Serializer, ErrorHandler
email = "your@gmail.com"
if not Validate.email(email):
return ErrorHandler.raise_error("invalid email format", 400)
else:
...
Here, we are checking if the input is a valid email.
Serializing data output
Seriale data.
from arrotechtools import Serializer
#Fetching data from a database or a data structure i.e list
response = Users().get_users()
...
if response:
return Serializer.serialize(response, "Success", 200)
else:
...
Here, we get records from the database and storing the data in a variable. Then we serialize the data into json object or an array.
The serialize object can serialize any different types data into json object(s). That includes lists, dictionaries, or arrays.
Error Handling
Serialize errored responses:
from arrotechtools import ErrorHandler, Validate
name = "jane doe"
...
if not Validate().name(name):
return ErrorHandler.raise_error("Name is invalid", 400)
else:
...
Example 2
Lets a look at how we can capture errors at the entry point of a flask application.
from flask import Flask
from arrotechtools import Serializer
app = Flask(__name__)
...
#register error handlers
app.register_error_handler(400, Serializer.bad_request)
app.register_error_handler(404, Serializer.page_not_found)
app.register_error_handler(405, Serializer.method_not_allowed)
app.register_error_handler(500, Serializer.internal_server_error)
This is a straight forward way of handling errors in flask.
Admin Protected Route
This is a function that takes an array of users as an argument and checks if the role is an admin. If that isn't the case, the function returns an unauthorized status code and message. Otherwise, the user is permitted to use the function.
How to use the decorator to protect routes
from arrotechtools import admin_required
@jwt_required
@admin_required(users)
def signup():
...
The decorator takes a list of users as an argument.
Support Team
Email: arrotechdesign@gmail.com
Phone: +254 711 371 265
Author
Harun Gachanja G.
Metadata
Release files for arrotechtools 1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arrotechtools-1.9.tar.gz | 5.1 kB | Without provenance | Details for arrotechtools-1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arrotechtools-1.9-py3-none-any.whl | Python 3 | none | any | Details for arrotechtools-1.9-py3-none-any.whl |
Total release size: 10.8 kB
Release files / arrotechtools-1.9.tar.gz
| Download URL | arrotechtools-1.9.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b670a252cc56148978a84a4b87218ce7f7847119bba576f40e52952f6df75e5
|
|
BLAKE2b-256 checksum How to use checksums |
f3b4a3ad93e76b868e326d17cf0a1c1476f72499c782f1ac0792c081c87a1eb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2
|
Release files / arrotechtools-1.9-py3-none-any.whl
| Download URL | arrotechtools-1.9-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
487d0eeedcced510784d43e06812c11aded201baf0795f1cad4fd83387de4818
|
|
BLAKE2b-256 checksum How to use checksums |
b99e363eccc1e77f16a0d8262f8f76acb3e704992de647413ced31106ef9f673
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2
|
Security for arrotechtools 1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.