#NEWLINE# def get_duration( self ) : #NEWLINE# #INDENT# '\n        Calculates duration or track\n\n        Returns\n        -------\n        duration: float\n            Duration in seconds or None if any time data is missing\n        ' #NEWLINE# if ( not self . segments ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# result = 0 #NEWLINE# for track_segment in self . segments : #NEWLINE# #INDENT# duration = track_segment . get_duration ( ) #NEWLINE# if ( track_segment or ( duration == 0 ) ) : #NEWLINE# #INDENT# result += duration #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( duration is None ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return result