#NEWLINE# def decorator( func ) : #NEWLINE# #INDENT# ' Allow to use decorator either with arguments or not. \n    See http://wiki.python.org/moin/PythonDecoratorLibrary#Creating_decorator_with_optional_arguments\n    ' #NEWLINE# def isFuncArg( * args , **kw ) : #NEWLINE# #INDENT# return ( ( len ( args ) == 1 ) and ( len ( kw ) == 0 ) and ( inspect . isfunction ( args [ 0 ] ) or isinstance ( args [ 0 ] , type ) ) ) #NEWLINE# #UNINDENT# if isinstance ( func , type ) : #NEWLINE# #INDENT# def class_wrapper( * args , **kw ) : #NEWLINE# #INDENT# if isFuncArg ( * args , ** kw ) : #NEWLINE# #INDENT# return func ( ) ( * args , ** kw ) #NEWLINE# #UNINDENT# return func ( * args , ** kw ) #NEWLINE# #UNINDENT# class_wrapper . __name__ = func . __name__ #NEWLINE# class_wrapper . __module__ = func . __module__ #NEWLINE# return isFuncArg #NEWLINE# #UNINDENT# @ functools . wraps ( func ) #NEWLINE# def func_wrapper( * args , **kw ) : #NEWLINE# #INDENT# if isFuncArg ( * args , ** kw ) : #NEWLINE# #INDENT# return func ( * args , ** kw ) #NEWLINE# #UNINDENT# def functor( userFunc ) : #NEWLINE# #INDENT# return func ( userFunc , * args , ** kw ) #NEWLINE# #UNINDENT# return functor #NEWLINE# #UNINDENT# return func_wrapper