Skip to main content

Aspect-Oriented Programming toolkit.

Project description

Build Status Coverage Status PYPI Package PYPI Package

aspectlib is an aspect-oriented programming, monkey-patch and decorators library. It is useful when changing behavior in existing code is desired.

Documentation

Docs are hosted at readthedocs.org: python-aspectlib docs.

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

Changelog

Version 1.1

  • Add 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.

Version 1.0

  • 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).

Version 0.9.0

  • 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.

Version 0.8.1

  • Use simpler import for the py3support.

Version 0.8.0

  • 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.

Version 0.7.0

  • Add support for decorating generators and coroutines in aspectlib.Aspect.

  • Made aspectlib raise better exceptions.

Version 0.6.1

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

Version 0.6.0

  • 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)

Version 0.5.0

  • 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.

Version 0.4.1

  • Remove junk from 0.4.0’s source distribution.

Version 0.4.0

  • 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.

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

aspectlib-1.1.0.tar.gz (382.6 kB view details)

Uploaded Source

Built Distribution

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

aspectlib-1.1.0-py2.py3-none-any.whl (26.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file aspectlib-1.1.0.tar.gz.

File metadata

  • Download URL: aspectlib-1.1.0.tar.gz
  • Upload date:
  • Size: 382.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aspectlib-1.1.0.tar.gz
Algorithm Hash digest
SHA256 45372b4a75782dc6dd677dc257991df72054b987d48dda19d312279e3478453a
MD5 7ab293e41d4f9502838bf47bec848c94
BLAKE2b-256 220e2993ebb74f641a821fa18cc777a04b1ef20cc3e1ae1a3c08788f55e68312

See more details on using hashes here.

File details

Details for the file aspectlib-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aspectlib-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ec5553f93271e6851b8eb2ae31e76ca910fd82e5a9dc6ddc94d03a3e57aa9d47
MD5 1d000dc5e8ed029ba76dee69bccbcf3f
BLAKE2b-256 a9a8ef431922f0f116882b75e134fca1b2d6f20dad46cba1ef10a6395f7f0b4f

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