#NEWLINE# def seconds_from_duration( xc , p , contextItem , args ) : #NEWLINE# #INDENT# if ( len ( args ) != 1 ) : #NEWLINE# #INDENT# raise XPathContext . FunctionNumArgs ( ) #NEWLINE# #UNINDENT# d = anytypeArg ( xc , args , 0 , 'duration' , missingArgFallback = ( ) ) #NEWLINE# if ( d == ( ) ) : #NEWLINE# #INDENT# return d #NEWLINE# #UNINDENT# if isinstance ( d , DayTimeDuration ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# if isinstance ( contextItem , YearMonthDuration ) : #NEWLINE# #INDENT# return d . dayHrsMinsSecs [ 2 ] #NEWLINE# #UNINDENT# raise XPathContext . FunctionArgType ( 1 , 'xs:duration' )