#NEWLINE# def boolean( xc , p , contextItem , args ) : #NEWLINE# #INDENT# if ( len ( args ) != 1 ) : #NEWLINE# #INDENT# raise XPathContext . FunctionNumArgs ( ) #NEWLINE# #UNINDENT# inputSequence = p [ 0 ] #NEWLINE# if ( ( inputSequence is None ) or ( len ( inputSequence ) == 0 ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# item = inputSequence [ 0 ] #NEWLINE# if isinstance ( item , ( ModelObject , ModelAttribute , etree . _ElementTree ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( len ( inputSequence ) == 1 ) : #NEWLINE# #INDENT# if isinstance ( item , bool ) : #NEWLINE# #INDENT# return item #NEWLINE# #UNINDENT# if isinstance ( item , _STR_BASE ) : #NEWLINE# #INDENT# return ( len ( item ) > 0 ) #NEWLINE# #UNINDENT# if isinstance ( item , _NUM_TYPES ) : #NEWLINE# #INDENT# return ( ( not math . isnan ( item ) ) and ( item != 0 ) ) #NEWLINE# #UNINDENT# #UNINDENT# raise XPathContext . XPathException ( p , 'err:FORG0006' , _ ( 'Effective boolean value indeterminate' ) )