This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Gorilla is a Python library that provides a convenient approach to monkey patching.

Monkey patching is the process of modifying module and class attributes at runtime with the purpose of replacing or extending third-party code.

Although not a recommended practice, it is sometimes useful to fix or modify the behaviour of a piece of code from a third-party library, or to extend its public interface while making the additions feel like they are built-in into the library.

The Python language makes monkey patching extremely easy but the advantages of Gorilla are multiple, not only in assuring a consistent behaviour on both Python 2 and Python 3 versions, but also in preventing common source of errors, and making the process both intuitive and convenient even when faced with large numbers of patches to create.

Features

  • intuitive and convenient decorator approach to create patches.
  • can create patches for all class or module members at once.
  • compatible with both Python 2 and Python 3.
  • customizable behaviour.

Usage

Thanks to the dynamic nature of Python that makes monkey patching possible, the process happens at runtime without ever having to directly modify the source code of the third-party library:

>>> import gorilla
>>> import destination
>>> @gorilla.patches(destination.Class)
... class MyClass(object):
...     def method(self):
...         print("Hello")
...     @classmethod
...     def class_method(cls):
...         print("world!")

The code above creates two patches, one for each member of the class MyClass, but does not apply them yet. In other words, they define the information required to carry on the operation but are not yet inserted into the specified destination class destination.Class.

Such patches created with the decorators can then be automatically retrieved by recursively scanning a package or a module, then applied:

>>> import gorilla
>>> import mypackage
>>> patches = gorilla.find_patches([mypackage])
>>> for patch in patches:
...     gorilla.apply(patch)

See the Tutorial section from the documentation for more detailed examples and explanations on how to use Gorilla.

Documentation

Read the documentation online at gorilla.readthedocs.io or check its source in the doc directory.

Out There

Projects using Gorilla include:

Author

Christopher Crouzet <christophercrouzet.com>

Release History

Release History

0.3.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
gorilla-0.3.0-py2.py3-none-any.whl (11.4 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jan 18, 2017
gorilla-0.3.0.tar.gz (26.6 kB) Copy SHA256 Checksum SHA256 Source Jan 18, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting