#NEWLINE# def returns_typeclass( method ) : #NEWLINE# #INDENT# '\n    Decorator: Returns a single typeclass match or None.\n\n    ' #NEWLINE# def func( self , * args , **kwargs ) : #NEWLINE# #INDENT# self . __doc__ = method . __doc__ #NEWLINE# query = method ( self , * args , ** kwargs ) #NEWLINE# if hasattr ( query , '__iter__' ) : #NEWLINE# #INDENT# result = list ( query ) #NEWLINE# return ( result [ 0 ] if result else None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return query #NEWLINE# #UNINDENT# #UNINDENT# return update_wrapper ( method , method )