Skip to main content

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


Download files

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

Source Distribution

asagg_lib-0.1.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

asagg_lib-0.1.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file asagg_lib-0.1.0.tar.gz.

File metadata

  • Download URL: asagg_lib-0.1.0.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

Hashes for asagg_lib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac8a2003a84c79e2cea108344374f6a360401ba81e5608ea2a6168615e1aa6e7
MD5 81c2cc13c58d14f2f5864eb8f2a8313d
BLAKE2b-256 669cee23fdb49e31ea75bc3d3cebf6ded97ae18703858e57d24f007e3338b30f

See more details on using hashes here.

File details

Details for the file asagg_lib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: asagg_lib-0.1.0-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

Hashes for asagg_lib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c3968ca6d2bc5a50815ae382711e35e81a5ce0602bba8ce207d33b0d2a13445
MD5 c12f35e46cd3a7952e17c4fde8271abc
BLAKE2b-256 3e6306ba208e2af4e39a76233017a8c9f898471723d32997a38223ec6c37909c

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