<s> '''<STR_LIT>''' <EOL> import functools <EOL> import inspect <EOL> import types <EOL> from combi . _python_toolbox . third_party import decorator as michele_decorator_module <EOL> def decorator ( caller , func = None ) : <EOL> '''<STR_LIT>''' <EOL> if func is not None : <EOL> evaldict = func . __globals__ . copy ( ) <EOL> evaldict [ '<STR_LIT>' ] = caller <EOL> evaldict [ '<STR_LIT>' ] = func <EOL> result = michele_decorator_module . FunctionMaker . create ( <EOL> func , "<STR_LIT>" , <EOL> evaldict , undecorated = func ) <EOL> result . __wrapped__ = func <EOL> return result <EOL> else : <EOL> if isinstance ( caller , functools . partial ) : <EOL> return functools . partial ( decorator , caller ) <EOL> first = inspect . getargspec ( caller ) [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> evaldict = caller . __globals__ . copy ( ) <EOL> evaldict [ '<STR_LIT>' ] = caller <EOL> evaldict [ '<STR_LIT>' ] = decorator <EOL> return michele_decorator_module . FunctionMaker . create ( <EOL> '<STR_LIT>' % ( caller . __name__ , first ) , <EOL> '<STR_LIT>' % first , <EOL> evaldict , undecorated = caller , <EOL> doc = caller . __doc__ , module = caller . __module__ ) <EOL> def helpful_decorator_builder ( decorator_builder ) : <EOL> '''<STR_LIT>''' <EOL> assert isinstance ( decorator_builder , types . FunctionType ) <EOL> def inner ( same_decorator_builder , * args , ** kwargs ) : <EOL> if args and isinstance ( args [ <NUM_LIT:0> ] , types . FunctionType ) : <EOL> function = args [ <NUM_LIT:0> ] <EOL> function_name = function . __name__ <EOL> decorator_builder_name = decorator_builder . __name__ <EOL> raise TypeError ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( decorator_builder_name , <EOL> function_name ) ) <EOL> else : <EOL> return decorator_builder ( * args , ** kwargs ) <EOL> return decorator ( inner , decorator_builder ) </s>
