Code Monkey home page Code Monkey logo

regd's Introduction

Description

RegD is a small library for Python which adds ability to trace decorators and decorated functions in Python with meta-information. It work well with both - Python 2.x and Python 3.x.

Nevertheless it was designed under Python 3, so it uses __annotations__ functions attribute specially introduced to store function meta.

It allows to trace your own and third-party decorators as well. All is required is just to register any existing decorator with DecoratorRegistry, like

from regd import DecoratorRegistry

# create simple decorator which does nothing
def mydecorator( fn) :
    # do your decorator stuff here...
    def wrapper( *args, **kwargs)
        # ... and here ... all you need
        return fn( *args, **kwargs)
    return wrapper

# register the decorator
mydecorator = DecoratorRegistry.decorator( mydecorator)

than just continue to use the decorator as usual:

@mydecorator
def mydecoratedfunction() :
    pass

Now any time you can easily track if function is decorated with decorator or not, like:

print(DecoratorRegistry.is_decorated_with(mydecoratedfunction, mydecorator))

Installation

This module is availabe via Python Package Index (PyPI). Installation is possible with pip or easy_install, like

> pip install regd

or

> easy_install regd

It's also available manual installation from git repository, like

> git clone git://github.com/Mikhus/regd.git
> cd regd
> python setup.py install

Documentation

RegD package documentation is available at http://packages.python.org/regd/

License

This package is subject to MIT License. To get more info, please, see LICENSE.txt file

Copyright (c) 2012

Author: Mykhailo Stadnyk [email protected] Home page: https://github.com/Mikhus/regd

regd's People

Contributors

mikhus avatar

Stargazers

Valko Volodya avatar Pantelis Koukousoulas avatar Denis Tokarev avatar Victor Kovtun avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.