aspectlib


Nameaspectlib JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/ionelmc/python-aspectlib
Summary``aspectlib`` is an aspect-oriented programming, monkey-patch and decorators library. It is useful when changing
upload_time2022-10-20 16:23:13
maintainer
docs_urlNone
authorIonel Cristian Mărieș
requires_python>=3.7
licenseBSD-2-Clause
keywords aop aspects aspect oriented programming decorators patch monkeypatch weave debug log tests mock capture replay capture-replay debugging patching monkeypatching record recording mocking logger
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ========
Overview
========



``aspectlib`` is an aspect-oriented programming, monkey-patch and decorators library. It is useful when changing
behavior in existing code is desired. It includes tools for debugging and testing: simple mock/record and a complete
capture/replay framework.

* Free software: BSD 2-Clause License

Installation
============

::

    pip install aspectlib

You can also install the in-development version with::

    pip install https://github.com/ionelmc/python-aspectlib/archive/main.zip


Documentation
=============

Docs are hosted at readthedocs.org: `python-aspectlib docs <http://python-aspectlib.readthedocs.org/en/latest/>`_.

Implementation status
=====================

Weaving functions, methods, instances and classes is completed.

Pending:

* *"Concerns"* (see `docs/todo.rst`)

If ``aspectlib.weave`` doesn't work for your scenario please report a bug!

Requirements
============

:OS: Any
:Runtime: Python 2.6, 2.7, 3.3, 3.4 or PyPy

Python 3.2, 3.1 and 3.0 are *NOT* supported (some objects are too crippled).

Similar projects
================

* `function_trace <https://github.com/RedHatQE/function_trace>`_ - extremely simple


Changelog
=========

2.0.0 (2022-10-20)
------------------

* Drop support for legacy Pythons (2.7, 3.6 or older).
* Remove Travis/Appveyor CI and switch to GitHub Actions.
* Added support for Tornado 6 (in the test suite).

1.5.2 (2020-11-15)
------------------

* Fixed broken import on Python 3.9.
  Contributed by Felix Yan in `#19 <https://github.com/ionelmc/python-aspectlib/pull/19>`_.

1.5.1 (2020-06-11)
------------------

* Remove some debug leftover prints from `v1.5.0`.

1.5.0 (2020-04-05)
------------------

* Fixed ``weave`` to stop reading attributes that don't match the method selector.
  Contributed by Jonas Maurus in `#14 <https://github.com/ionelmc/python-aspectlib/pull/14>`_.
* Added support for Python 3.7 and 3.8 (``async def`` functions and generators).

1.4.2 (2016-05-10)
------------------

* Fix forgotten debug prints.

1.4.1 (2016-05-06)
------------------

* Fixed weaving of objects that don't live on root-level modules.

1.4.0 (2016-04-09)
------------------

* Corrected weaving of methods, the weaved function should be unbound.
* Rolling back only applies undos once.
* Added a convenience ``weave`` fixture for pytest.

1.3.3 (2015-10-02)
------------------

* Fixed typo in ``ABSOLUTELLY_ALL_METHODS`` name (now ``ABSOLUTELY_ALL_METHODS``). Old name is still there for
  backwards compatibility.

1.3.2 (2015-09-22)
------------------

* Fixed another tricky bug in the generator advising wrappers - result was not returned if only `Proceed` was yielded.

1.3.1 (2015-09-12)
------------------

* Corrected result handling when using Aspects on generators.

1.3.0 (2015-06-06)
------------------

* Added ``messages`` property to ``aspectlib.test.LogCapture``. Change ``call`` to have level name instead of number.
* Fixed a bogus warning from ``aspectlib.patch_module``` when patching methods on old style classes.

1.2.2 (2014-11-25)
------------------

* Added support for weakrefs in the ``__logged__`` wrapper from ``aspectlib.debug.log`` decorator.

1.2.1 (2014-10-15)
------------------

* Don't raise exceptions from ``Replay.__exit__`` if there would be an error (makes original cause hard to debug).

1.2.0 (2014-06-24)
------------------

* Fixed weaving methods that were defined in some baseclass (and not on the target class).
* Fixed wrong qualname beeing used in the Story/Replay recording. Now used the alias given to the weaver instead of
  whatever is the realname on the current platform.

1.1.1 (2014-06-14)
------------------

* Use ``ASPECTLIB_DEBUG`` for every logger in ``aspectlib``.

1.1.0 (2014-06-13)
------------------

* Added a `bind` option to ``aspectlib.Aspect`` so you can access the cutpoint from the advisor.
* Replaced automatic importing in ``aspectlib.test.Replay`` with extraction of context variables (locals and globals
  from the calling ``aspectlib.test.Story``). Works better than the previous inference of module from AST of the
  result.
* All the methods on the replay are now properties: ``aspectlib.test.Story.diff``,
  ``aspectlib.test.Story.unexpected`` and ``aspectlib.test.Story.missing``.
* Added ``aspectlib.test.Story.actual`` and ``aspectlib.test.Story.expected``.
* Added an ``ASPECTLIB_DEBUG`` environment variable option to switch on debug logging in ``aspectlib``'s internals.

1.0.0 (2014-05-03)
------------------

* Reworked the internals ``aspectlib.test.Story`` to keep call ordering, to allow dependencies and improved the
  serialization (used in the diffs and the missing/unexpected lists).


0.9.0 (2014-04-16)
------------------

* Changed ``aspectlib.test.record``:

    * Renamed `history` option to `calls`.
    * Renamed `call` option to `iscalled`.
    * Added `callback` option.
    * Added `extended` option.

* Changed ``aspectlib.weave``:

    * Allow weaving everything in a module.
    * Allow weaving instances of new-style classes.

* Added ``aspectlib.test.Story`` class for capture-replay and stub/mock testing.

0.8.1 (2014-04-01)
------------------

* Use simpler import for the py3support.

0.8.0 (2014-03-31)
------------------

* Change ``aspectlib.debug.log`` to use ``aspectlib.Aspect`` and work as expected with coroutines or generators.
* Fixed ``aspectlib.debug.log`` to work on Python 3.4.
* Remove the undocumented ``aspectlib.Yield`` advice. It was only usable when decorating generators.

0.7.0 (2014-03-28)
------------------

* Add support for decorating generators and coroutines in ``aspectlib.Aspect``.
* Made aspectlib raise better exceptions.

0.6.1 (2014-03-22)
------------------

* Fix checks inside ``aspectlib.debug.log`` that would inadvertently call ``__bool__``/``__nonzero``.

0.6.0 (2014-03-17)
------------------

* Don't include __getattribute__ in ALL_METHODS - it's too dangerous dangerous dangerous dangerous dangerous dangerous
  ... ;)
* Do a more reliable check for old-style classes in debug.log
* When weaving a class don't weave attributes that are callable but are not actually routines (functions, methods etc)

0.5.0 (2014-03-16)
------------------

* Changed ``aspectlib.debug.log``:

    * Renamed `arguments` to `call_args`.
    * Renamed `arguments_repr` to `call_args_repr`.
    * Added `call` option.
    * Fixed issue with logging from old-style methods (object name was a generic "instance").

* Fixed issues with weaving some types of builtin methods.
* Allow to apply multiple aspects at the same time.
* Validate string targets before weaving. ``aspectlib.weave('mod.invalid name', aspect)`` now gives a clear error
  (``invalid name`` is not a valid identifier)
* Various documentation improvements and examples.

0.4.1 (2014-03-08)
------------------

* Remove junk from 0.4.0's source distribution.

0.4.0 (2014-03-08)
------------------

* Changed ``aspectlib.weave``:

    * Replaced `only_methods`, `skip_methods`, `skip_magicmethods` options with `methods`.
    * Renamed `on_init` option to `lazy`.
    * Added `aliases` option.
    * Replaced `skip_subclasses` option with `subclasses`.

* Fixed weaving methods from a string target.

0.3.1 (2014-03-05)
------------------

* `???`

0.3.0 (2014-03-05)
------------------

* First public release.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ionelmc/python-aspectlib",
    "name": "aspectlib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "aop,aspects,aspect oriented programming,decorators,patch,monkeypatch,weave,debug,log,tests,mock,capture,replay,capture-replay,debugging,patching,monkeypatching,record,recording,mocking,logger",
    "author": "Ionel Cristian M\u0103rie\u0219",
    "author_email": "contact@ionelmc.ro",
    "download_url": "https://files.pythonhosted.org/packages/fe/a0/d87a5c6a78634a7136fd7c1686f66b65bd7111517503b883408dca872131/aspectlib-2.0.0.tar.gz",
    "platform": null,
    "description": "========\nOverview\n========\n\n\n\n``aspectlib`` is an aspect-oriented programming, monkey-patch and decorators library. It is useful when changing\nbehavior in existing code is desired. It includes tools for debugging and testing: simple mock/record and a complete\ncapture/replay framework.\n\n* Free software: BSD 2-Clause License\n\nInstallation\n============\n\n::\n\n    pip install aspectlib\n\nYou can also install the in-development version with::\n\n    pip install https://github.com/ionelmc/python-aspectlib/archive/main.zip\n\n\nDocumentation\n=============\n\nDocs are hosted at readthedocs.org: `python-aspectlib docs <http://python-aspectlib.readthedocs.org/en/latest/>`_.\n\nImplementation status\n=====================\n\nWeaving functions, methods, instances and classes is completed.\n\nPending:\n\n* *\"Concerns\"* (see `docs/todo.rst`)\n\nIf ``aspectlib.weave`` doesn't work for your scenario please report a bug!\n\nRequirements\n============\n\n:OS: Any\n:Runtime: Python 2.6, 2.7, 3.3, 3.4 or PyPy\n\nPython 3.2, 3.1 and 3.0 are *NOT* supported (some objects are too crippled).\n\nSimilar projects\n================\n\n* `function_trace <https://github.com/RedHatQE/function_trace>`_ - extremely simple\n\n\nChangelog\n=========\n\n2.0.0 (2022-10-20)\n------------------\n\n* Drop support for legacy Pythons (2.7, 3.6 or older).\n* Remove Travis/Appveyor CI and switch to GitHub Actions.\n* Added support for Tornado 6 (in the test suite).\n\n1.5.2 (2020-11-15)\n------------------\n\n* Fixed broken import on Python 3.9.\n  Contributed by Felix Yan in `#19 <https://github.com/ionelmc/python-aspectlib/pull/19>`_.\n\n1.5.1 (2020-06-11)\n------------------\n\n* Remove some debug leftover prints from `v1.5.0`.\n\n1.5.0 (2020-04-05)\n------------------\n\n* Fixed ``weave`` to stop reading attributes that don't match the method selector.\n  Contributed by Jonas Maurus in `#14 <https://github.com/ionelmc/python-aspectlib/pull/14>`_.\n* Added support for Python 3.7 and 3.8 (``async def`` functions and generators).\n\n1.4.2 (2016-05-10)\n------------------\n\n* Fix forgotten debug prints.\n\n1.4.1 (2016-05-06)\n------------------\n\n* Fixed weaving of objects that don't live on root-level modules.\n\n1.4.0 (2016-04-09)\n------------------\n\n* Corrected weaving of methods, the weaved function should be unbound.\n* Rolling back only applies undos once.\n* Added a convenience ``weave`` fixture for pytest.\n\n1.3.3 (2015-10-02)\n------------------\n\n* Fixed typo in ``ABSOLUTELLY_ALL_METHODS`` name (now ``ABSOLUTELY_ALL_METHODS``). Old name is still there for\n  backwards compatibility.\n\n1.3.2 (2015-09-22)\n------------------\n\n* Fixed another tricky bug in the generator advising wrappers - result was not returned if only `Proceed` was yielded.\n\n1.3.1 (2015-09-12)\n------------------\n\n* Corrected result handling when using Aspects on generators.\n\n1.3.0 (2015-06-06)\n------------------\n\n* Added ``messages`` property to ``aspectlib.test.LogCapture``. Change ``call`` to have level name instead of number.\n* Fixed a bogus warning from ``aspectlib.patch_module``` when patching methods on old style classes.\n\n1.2.2 (2014-11-25)\n------------------\n\n* Added support for weakrefs in the ``__logged__`` wrapper from ``aspectlib.debug.log`` decorator.\n\n1.2.1 (2014-10-15)\n------------------\n\n* Don't raise exceptions from ``Replay.__exit__`` if there would be an error (makes original cause hard to debug).\n\n1.2.0 (2014-06-24)\n------------------\n\n* Fixed weaving methods that were defined in some baseclass (and not on the target class).\n* Fixed wrong qualname beeing used in the Story/Replay recording. Now used the alias given to the weaver instead of\n  whatever is the realname on the current platform.\n\n1.1.1 (2014-06-14)\n------------------\n\n* Use ``ASPECTLIB_DEBUG`` for every logger in ``aspectlib``.\n\n1.1.0 (2014-06-13)\n------------------\n\n* Added a `bind` option to ``aspectlib.Aspect`` so you can access the cutpoint from the advisor.\n* Replaced automatic importing in ``aspectlib.test.Replay`` with extraction of context variables (locals and globals\n  from the calling ``aspectlib.test.Story``). Works better than the previous inference of module from AST of the\n  result.\n* All the methods on the replay are now properties: ``aspectlib.test.Story.diff``,\n  ``aspectlib.test.Story.unexpected`` and ``aspectlib.test.Story.missing``.\n* Added ``aspectlib.test.Story.actual`` and ``aspectlib.test.Story.expected``.\n* Added an ``ASPECTLIB_DEBUG`` environment variable option to switch on debug logging in ``aspectlib``'s internals.\n\n1.0.0 (2014-05-03)\n------------------\n\n* Reworked the internals ``aspectlib.test.Story`` to keep call ordering, to allow dependencies and improved the\n  serialization (used in the diffs and the missing/unexpected lists).\n\n\n0.9.0 (2014-04-16)\n------------------\n\n* Changed ``aspectlib.test.record``:\n\n    * Renamed `history` option to `calls`.\n    * Renamed `call` option to `iscalled`.\n    * Added `callback` option.\n    * Added `extended` option.\n\n* Changed ``aspectlib.weave``:\n\n    * Allow weaving everything in a module.\n    * Allow weaving instances of new-style classes.\n\n* Added ``aspectlib.test.Story`` class for capture-replay and stub/mock testing.\n\n0.8.1 (2014-04-01)\n------------------\n\n* Use simpler import for the py3support.\n\n0.8.0 (2014-03-31)\n------------------\n\n* Change ``aspectlib.debug.log`` to use ``aspectlib.Aspect`` and work as expected with coroutines or generators.\n* Fixed ``aspectlib.debug.log`` to work on Python 3.4.\n* Remove the undocumented ``aspectlib.Yield`` advice. It was only usable when decorating generators.\n\n0.7.0 (2014-03-28)\n------------------\n\n* Add support for decorating generators and coroutines in ``aspectlib.Aspect``.\n* Made aspectlib raise better exceptions.\n\n0.6.1 (2014-03-22)\n------------------\n\n* Fix checks inside ``aspectlib.debug.log`` that would inadvertently call ``__bool__``/``__nonzero``.\n\n0.6.0 (2014-03-17)\n------------------\n\n* Don't include __getattribute__ in ALL_METHODS - it's too dangerous dangerous dangerous dangerous dangerous dangerous\n  ... ;)\n* Do a more reliable check for old-style classes in debug.log\n* When weaving a class don't weave attributes that are callable but are not actually routines (functions, methods etc)\n\n0.5.0 (2014-03-16)\n------------------\n\n* Changed ``aspectlib.debug.log``:\n\n    * Renamed `arguments` to `call_args`.\n    * Renamed `arguments_repr` to `call_args_repr`.\n    * Added `call` option.\n    * Fixed issue with logging from old-style methods (object name was a generic \"instance\").\n\n* Fixed issues with weaving some types of builtin methods.\n* Allow to apply multiple aspects at the same time.\n* Validate string targets before weaving. ``aspectlib.weave('mod.invalid name', aspect)`` now gives a clear error\n  (``invalid name`` is not a valid identifier)\n* Various documentation improvements and examples.\n\n0.4.1 (2014-03-08)\n------------------\n\n* Remove junk from 0.4.0's source distribution.\n\n0.4.0 (2014-03-08)\n------------------\n\n* Changed ``aspectlib.weave``:\n\n    * Replaced `only_methods`, `skip_methods`, `skip_magicmethods` options with `methods`.\n    * Renamed `on_init` option to `lazy`.\n    * Added `aliases` option.\n    * Replaced `skip_subclasses` option with `subclasses`.\n\n* Fixed weaving methods from a string target.\n\n0.3.1 (2014-03-05)\n------------------\n\n* `???`\n\n0.3.0 (2014-03-05)\n------------------\n\n* First public release.\n\n\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause",
    "summary": "``aspectlib`` is an aspect-oriented programming, monkey-patch and decorators library. It is useful when changing",
    "version": "2.0.0",
    "project_urls": {
        "Changelog": "https://python-aspectlib.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://python-aspectlib.readthedocs.io/",
        "Homepage": "https://github.com/ionelmc/python-aspectlib",
        "Issue Tracker": "https://github.com/ionelmc/python-aspectlib/issues"
    },
    "split_keywords": [
        "aop",
        "aspects",
        "aspect oriented programming",
        "decorators",
        "patch",
        "monkeypatch",
        "weave",
        "debug",
        "log",
        "tests",
        "mock",
        "capture",
        "replay",
        "capture-replay",
        "debugging",
        "patching",
        "monkeypatching",
        "record",
        "recording",
        "mocking",
        "logger"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af27146806fa5c4823b61b30bbdf3f06a2adb9e475ea790539e7a00b6b6fa620",
                "md5": "6a2e3bac29a53697d2c8bf9237043535",
                "sha256": "d549c64e9b0791449d2bafeb1aaf9db090af414b0a38967d313b77d2bf266628"
            },
            "downloads": -1,
            "filename": "aspectlib-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6a2e3bac29a53697d2c8bf9237043535",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 24231,
            "upload_time": "2022-10-20T16:23:10",
            "upload_time_iso_8601": "2022-10-20T16:23:10.882476Z",
            "url": "https://files.pythonhosted.org/packages/af/27/146806fa5c4823b61b30bbdf3f06a2adb9e475ea790539e7a00b6b6fa620/aspectlib-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fea0d87a5c6a78634a7136fd7c1686f66b65bd7111517503b883408dca872131",
                "md5": "427f325a4a9a5dc85563cbb08569bcd9",
                "sha256": "a4b461b9da0b531aebcb93efcde3de808a72c60226dd8d902c467d13faf7ce92"
            },
            "downloads": -1,
            "filename": "aspectlib-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "427f325a4a9a5dc85563cbb08569bcd9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 156591,
            "upload_time": "2022-10-20T16:23:13",
            "upload_time_iso_8601": "2022-10-20T16:23:13.590447Z",
            "url": "https://files.pythonhosted.org/packages/fe/a0/d87a5c6a78634a7136fd7c1686f66b65bd7111517503b883408dca872131/aspectlib-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-20 16:23:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ionelmc",
    "github_project": "python-aspectlib",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "aspectlib"
}
        
Elapsed time: 0.24457s