The Asagg library (Auto Setter And Getter Generator) is a library inspired by another library that is in the Java environment, which is the Lombock library
Project description
Asagg
The Asagg library (Auto Setter And Getter Generator) is a library inspired by another library that is in the Java environment, which is the Lombock library, this library aims to automate the generation of access methods to private attributes, automatically generating Getters and Setters Among other things.
Installation
To install the library use the following command, you can also use another dependency manager of your choice, such as Poetry or Pipenv.
# for pip
> pip install asagg-lib
# for Poetry
> poetry add --group=dev asagg-lib
# for Pipenv
> pipenv install asagg-lib
Usage
Following the same line of operation as Lombock, to be able to use the library, just use a decorator and the magic will happen. The decorators are divided into three functions where each one has a functionality and one has the functionality of the other two, being their combination.
Old way to create properties without Asagg:
class MyClass:
def __init__(self):
self._my_private_attribute = "private"
@property
def my_private_attribute(self):
return self._my_private_attribute
my_class = MyClass()
# method generated automaticly with Asagg
print(my_class.my_private_attribute) # Output: "private"
New way to create properties with Asagg:
from asagg_lib import Asagg
@Asagg.getter
class MyClass:
def __init__(self):
self._my_private_attribute = "private"
my_class = MyClass()
# method generated automaticly with Asagg
print(my_class.my_private_attribute) # Output: "private"
Asagg.getter
This decorator is responsible for generating the getters of the class to which it is applied, it will scan the attributes of the class and take only the private and protected attributes, then a function will be applied to generate a property for each attribute collected and thus making the getters available
Example:
from asagg_lib import Asagg
@Asagg.getter
class MyClass:
def __init__(self):
self._my_private_attribute = "private"
Asagg.setter
This decorator is responsible for generating the setters of the class to which it is applied, it will scan the attributes of the class and take only the private and protected attributes, then a function will be applied to generate a property for each attribute collected and thus making the setters available
Example:
from asagg_lib import Asagg
@Asagg.setter
class MyClass:
def __init__(self):
self._my_private_attribute = "private"
📘 Info
The function used to generate the setters also uses a typing check to prevent a value of a different type from being assigned to the property
Asagg.data
This decorator is responsible for generating the setters and getters of the class to which it is applied, it will scan the attributes of the class and take only the private and protected attributes, then a function will be applied to generate a property for each attribute collected and thus making the setters and getters available
Example:
from asagg_lib import Asagg
@Asagg.data
class MyClass:
def __init__(self):
self._my_private_attribute = "private"
All rights reserved © pedr.augustobarbosa.aparecido@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asagg_lib-0.1.1.tar.gz.
File metadata
- Download URL: asagg_lib-0.1.1.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1feb592c87abcec70b06ae0e50a388110e95f774fa833241746024eb4e71555f
|
|
| MD5 |
d4d64b3d98d9e8b5f21c96ab603b7881
|
|
| BLAKE2b-256 |
4a3df9795894db209b9d191b765d8e91929c790a2d700200fa999ad70b1bd052
|
File details
Details for the file asagg_lib-0.1.1-py3-none-any.whl.
File metadata
- Download URL: asagg_lib-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f13c3c6e605edc918d2ca39cc89a14d0cde1d7374e4e7b9320b2c3730009f10
|
|
| MD5 |
f5d15d0f8e652068256e7ffbc6b0070c
|
|
| BLAKE2b-256 |
47b5b771bd158d265d900c72b9e1c1b2d6c0edf3f2b909d7ab2cc72614521678
|