Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
attribution checker for python implemented as a decorator
Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
README
setup.py

README

attrcheck: attribution checker for Python

Copyright (c) 2011, Jun Namikawa <jnamika@gmail.com>
License: ISC License (ISCL)


This is a simple attribution checker implemented as a decorator for Python.
All functionality are provided as keyword arguments of the decorator.


=== Example ===

    from attrcheck import attrcheck
    @attrcheck(x=['real'], y=['index', 'strip'], z=dir(list))
    def foo(x, y, z=[]): pass

The code above means the following:

    def foo(x, y, z=[]):
        if not hasattr(x, 'real'):
            raise AttributeError
        if not hasattr(y, 'index'):
            raise AttributeError
        if not hasattr(y, 'strip'):
            raise AttributeError
        for name in dir(list):
            if not hasattr(z, name):
                raise AttributeError

In addition, attrcheck can check default argument values.
Thus, the following code throws AttributeError.

    @attrcheck(y=dir(str))
    def bar(x, y=[]): pass

Something went wrong with that request. Please try again.