Transformation maps

Maps define how data exposed through manatus.scenarios are manipulated to build Source Resource objects.

manatus.cli.transform reads the configuration file manatus_scenarios.cfg to determine which map to apply for which source. Configuration options are covered in Configuring manatus.

Note

You’ll probably want to write custom maps as detailed in Writing custom maps

Standard maps

Default maps bundled in manatus.

manatus.maps.dc_standard_map(record)
def dc_standard_map(record):
    logger.debug(f'Loaded {__name__}.dc_standard_map map')
    sr = SourceResource()
    if record.contributor:
        sr.contributor = [{'name': name} for name in record.contributor]
    sr.creator = [{'name': name} for name in record.creator if record.creator]
    sr.date = record.date
    sr.description = record.description
    sr.format = record.format
    sr.identifier = record.harvest_id
    sr.language = record.language
    if record.place:
        sr.spatial = [{'name': place} for place in record.place]
    sr.publisher = record.publisher
    sr.rights = record.rights
    if record.subject:
        sr.subject = [{'name': subject} for subject in record.subject]
    sr.title = record.title
    sr.type = record.type
    tn = None
    yield sr, tn
manatus.maps.qdc_standard_map(record)
def qdc_standard_map(record):
    logger.debug(f'Loaded {__name__}.qdc_standard_map map')
    for dc_rec, _ in dc_standard_map(record):
        sr = dc_rec
    sr.alternative = record.alternative
    sr.abstract = record.abstract
    sr.collection = record.is_part_of
    sr.extent = record.extent
    tn = None
    yield sr, tn
manatus.maps.mods_standard_map(record)
def mods_standard_map(record):
    logger.debug(f'Loaded {__name__}.mods_standard_map map')
    sr = SourceResource()
    sr.alternative = record.alternative
    try:
        sr.collection = record.collection.title
    except AttributeError:
        logger.info(f"No collection title - {record.harvest_id}")
        pass
    sr.contributor = record.contributor
    sr.creator = record.creator
    sr.date = record.date
    sr.description = record.description
    sr.extent = record.extent
    sr.format = record.format
    sr.identifier = record.harvest_id
    sr.language = record.language
    sr.spatial = record.place
    sr.publisher = record.publisher
    sr.rights = record.rights
    sr.subject = record.subject
    sr.title = record.title
    sr.type = record.type
    tn = None
    yield sr, tn