<s> from datetime import datetime <EOL> def transform_datetime ( dt ) : <EOL> """<STR_LIT>""" <EOL> if dt is None : <EOL> dt = '<STR_LIT>' <EOL> else : <EOL> assert isinstance ( dt , datetime ) <EOL> dt = dt . strftime ( '<STR_LIT>' ) <EOL> return dt <EOL> def flatten ( params , key = None ) : <EOL> """<STR_LIT>""" <EOL> flat = { } <EOL> for name , val in params . items ( ) : <EOL> if key is not None and not isinstance ( key , int ) : <EOL> name = "<STR_LIT>" % ( key , name ) <EOL> if isinstance ( val , dict ) : <EOL> flat . update ( flatten ( val , name ) ) <EOL> elif isinstance ( val , list ) : <EOL> flat . update ( flatten ( dict ( enumerate ( val ) ) , name ) ) <EOL> elif val is not None : <EOL> flat [ name ] = val <EOL> return flat </s>
