import copy


def db_entry_trim_empty_fields(entry):
    """ Remove empty fields from an internal-format entry dict """
    entry_trim = copy.deepcopy(entry)  # Make a copy to modify as needed
    for field in [ 'url', 'title', 'extended' ]:
        if field in entry:
            if (entry[field] is None) or \
               (type(entry[field]) is str and len(entry[field]) == 0):
                del entry_trim[field]
    return entry_trim