#NEWLINE# def get_month_range_from_dict( source ) : #NEWLINE# #INDENT# "\n    :param source: dictionary with keys 'start' and 'end\n    :return: a tuple of datatime objects in the form (start, end)\n    " #NEWLINE# now = timezone . now ( ) #NEWLINE# start = source . get ( 'start' ) #NEWLINE# end = source . get ( 'end' , datetime . datetime ( now . year , now . month , calendar . monthrange ( now . year , now . month ) [ 1 ] ) ) #NEWLINE# if ( not start ) : #NEWLINE# #INDENT# start = ( datetime . datetime ( ( end . year - 1 ) , ( end . month + 1 ) , 1 ) if ( end . month != 12 ) else datetime . datetime ( end . year , 1 , 1 ) ) #NEWLINE# #UNINDENT# return ( start , end )