Save them to the to_export list as a list of tuples/dictionaries of the digital object ID and the output filename
For a given output field call the given processor function, and pass it the extracted_data structure
mapping = { title: { # The name of the field as will appear in the template context transform_function: 'title', # The name of the function that will generate the field contents required: True # If the field doesn't exist, the record can't be made }, subjects_topic: { transform_function: 'subject_topic', } subjects_genre: { transform_function: 'subject_genre', } subjects_geographic: { transform_function: 'subject_geographic', }
}
def title(extracted_data, do_id): digital_object = extracted_data['digital_objects']['do_id']
title = html_escape(digital_object['title']) return title
def get_subjects_by_type(extracted_data, do_id, type): digital_object = extracted_data['digital_objects']['do_id'] parent_component = get_linked_instance(digital_object['linked instance'], extracted_data) aspace_subjects = parent_component['subjects'] subjects = [] for subject in aspace_subjects: if subject['term_type'] == type: subjects.append(subject) return subjects
def subject_topic(extracted_data, do_id): return get_subjects_by_type(extracted_data, do_id, 'topic')
def subject_genre(extracted_data, do_id): return get_subjects_by_type(extracted_data, do_id, 'genre/form')
def subject_genre(extracted_data, do_id): return get_subjects_by_type(extracted_data, do_id, 'geographic')
{% if context.subjects_topic|length > 0 %} {% for subject_topical in context.subjects_topic%} {{subject_topical.title}} {% endfor %} {% endif %}