#NEWLINE# def node( level , heading , todo = None , scheduled = None , deadline = None , closed = None , clock = [ ] , tags = [ ] , datelist = [ ] , rangelist = [ ] ) : #NEWLINE# #INDENT# active_datestr = ( lambda x : x . strftime ( '<%Y-%m-%d %a>' ) ) #NEWLINE# inactive_datestr = ( lambda x : x . strftime ( '[%Y-%m-%d %a %H:%M]' ) ) #NEWLINE# ( yield ( '*' * level ) ) #NEWLINE# ( yield ' ' ) #NEWLINE# if todo : #NEWLINE# #INDENT# ( yield todo ) #NEWLINE# ( yield ' ' ) #NEWLINE# #UNINDENT# ( yield heading ) #NEWLINE# if tags : #NEWLINE# #INDENT# ( yield '  :{0}:' . format ( ':' . join ( tags ) ) ) #NEWLINE# #UNINDENT# ( yield '\n' ) #NEWLINE# if ( scheduled or deadline or closed ) : #NEWLINE# #INDENT# ( yield ( ' ' * level ) ) #NEWLINE# #UNINDENT# for ( name , date , datestr ) in [ ( 'CLOSED' , closed , inactive_datestr ) , ( 'DEADLINE' , deadline , active_datestr ) , ( 'SCHEDULED' , scheduled , active_datestr ) ] : #NEWLINE# #INDENT# if date : #NEWLINE# #INDENT# ( yield ' ' ) #NEWLINE# ( yield name ) #NEWLINE# ( yield ': ' ) #NEWLINE# ( yield datestr ( date ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( scheduled or deadline or closed ) : #NEWLINE# #INDENT# ( yield '\n' ) #NEWLINE# #UNINDENT# for ( clock_start , clock_end ) in clock : #NEWLINE# #INDENT# ( yield ( ' ' * ( level + 1 ) ) ) #NEWLINE# ( yield 'CLOCK: ' ) #NEWLINE# ( yield inactive_datestr ( clock_start ) ) #NEWLINE# ( yield '--' ) #NEWLINE# ( yield inactive_datestr ( clock_end ) ) #NEWLINE# ( yield ' => ' ) #NEWLINE# ( yield timedeltastr ( ( clock_end - clock_start ) ) ) #NEWLINE# ( yield '\n' ) #NEWLINE# #UNINDENT# for date in datelist : #NEWLINE# #INDENT# ( yield inactive_datestr ( date ) ) #NEWLINE# ( yield '\n' ) #NEWLINE# #UNINDENT# for ( start , end ) in start : #NEWLINE# #INDENT# ( yield inactive_datestr ( start ) ) #NEWLINE# ( yield '--' ) #NEWLINE# ( yield inactive_datestr ( end ) ) #NEWLINE# ( yield '\n' )