#NEWLINE# def wrap( resource_class ) : #NEWLINE# #INDENT# 'A decorator wraps dict returned by a given function into a Resource.' #NEWLINE# def decorator( func ) : #NEWLINE# #INDENT# def handle( * args , **kwargs ) : #NEWLINE# #INDENT# ret = func ( * args , ** kwargs ) #NEWLINE# if isinstance ( ret , list ) : #NEWLINE# #INDENT# return [ resource_class ( el ) for el in ret ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ret : #NEWLINE# #INDENT# return resource_class ( ret ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return handle #NEWLINE# #UNINDENT# return decorator