Metadata-Version: 2.1
Name: aspectify
Version: 0.0.4
Summary: Apply Aspect Oriented Programming to your Python code
Home-page: https://github.com/ruescog/aspectify
Author: ruescog
Author-email: ruescog@unirioja.es
License: Apache Software License 2.0
Description: aspectify
        ================
        
        <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
        
        Aspect Oriented Programming is a programming paradigm that allows the
        user to separate some cross-cutting content from the main code, such as
        the logging or a database connection.
        
        As it may be known, other programming languages has some functionallity
        (implemented or plugged in) to use this paradigm as an additional
        abstract layer to the core application.
        [AspectJ](https://www.eclipse.org/aspectj/) (used in Java), can sound
        familiar to the reader.
        
        In order to bring this amazing and powerful functionality to Python
        (which, in addition, will allow us to add it dynamically instead of
        using a weaver –as it is done in Java–), we have defined `Aspectify`, a
        Python library to manage AOP.
        
        ## Background concepts
        
        Before introducing the library, it is important to define some concepts
        used in AOP. Those are: -
        [`Aspect`](https://ruescog.github.io/aspectify/aop.html#aspect)
        (*what*): a cross-cutting concept. In fact, an
        [`Aspect`](https://ruescog.github.io/aspectify/aop.html#aspect) will
        group some functionalies. These, which will modify the natural behaviour
        of a method, are called `Advice`s. - `PointCut` (*when*): a fragment of
        code where the
        [`Aspect`](https://ruescog.github.io/aspectify/aop.html#aspect) is
        defined. Can be multiple `PointCut`s for each
        [`Aspect`](https://ruescog.github.io/aspectify/aop.html#aspect) (indeed,
        it will). - `Advice` (*when and what to do*): The code fragment to
        execute when the `PointCut` occurs and the moment when the new behaviuor
        must occur. Originally, only three moments were defined (`before`,
        `around` –instead of– and `after`), but nowadays new moments are
        defined, such as “after throwing an exception” (`after_throwing`) or
        “after NOT throwing an exception” (`after_returning`).
        
        ## Installation
        
        In order to install the library, it is only needed to execute the pypi
        comand that follows:
        
        ``` sh
        pip install aspectify
        ```
        
        > **ADVICE**: You should use a virtual environment to install the
        > packages associated with your proyect.
        
        ## Why do we need Aspectify
        
        Once the background is defined and the library is installed, we can
        start to create the AOP layer to our projects.
        
        ### The core project
        
        In order to use the library, we need a project. For example, we will use
        the `random` library for Python.
        
        ``` python
        from random import Random
        ```
        
        Now, we can use it to generate some integers.
        
        ``` python
        r = Random()
        r.randint(5, 10)
        ```
        
            9
        
        As you can see in its documentation, `randint` (called with parameters
        `a` and `b`) can generate the `b` value itself (it is a closed range
        \[5, 10\]).
        
        If we want to change this behaviour to the normal random functions
        behaviour (the range is closed-opened \[5, 10)), you will need to
        redefine it. Furthermore, if other functions or library use this method,
        they will not use yours.
        
        How can we solve it? Using AOP.
        
        During this introduction, we have seen the background concepts and how
        to install the `Aspectify` library. In the next section we will explain
        how to use it with a simple example.
        
Keywords: nbdev jupyter notebook python
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: dev
