def convert_datetimes_to_timestamps(data, datetime_attrs):
if not data:<EOL><INDENT>return data<EOL><DEDENT>new_data = {}<EOL>for key, value in data.items():<EOL><INDENT>if key in datetime_attrs and isinstance(value, datetime):<EOL><INDENT>new_key = datetime_attrs[key]<EOL>new_data[new_key] = timestamp_from_dt(value)<EOL><DEDENT>else:<EOL><INDENT>new_data[key] = value<EOL><DEDENT><DEDENT>return new_data<EOL>
Given a dictionary of data, and a dictionary of datetime attributes,
return a new dictionary that converts any datetime attributes that may
be present to their timestamped equivalent.