Beispiel #1
0
def marc21_to_description(self, key, value):
    """Get extent, otherMaterialCharacteristics, formats.

    extent: 300$a (the first one if many)
    otherMaterialCharacteristics: 300$b (the first one if many)
    formats: 300 [$c repetitive]
    """
    if value.get('a'):
        if not self.get('extent'):
            self['extent'] = remove_trailing_punctuation(
                overdo.not_repetitive(value, 'a'))

    if value.get('b'):
        if self.get('otherMaterialCharacteristics', []) == []:
            self['otherMaterialCharacteristics'] = remove_trailing_punctuation(
                overdo.not_repetitive(value, 'b'))

    if value.get('c'):
        formats = self.get('formats')

        if not formats:
            data = value.get('c')
            formats = list(utils.force_list(data))

        return formats

    return None
Beispiel #2
0
def publication_statement_text(provision_activity):
    """Create publication statement from place, agent and date values."""
    # Only if provision activity is imported from field 269 (no statement,
    # but start date)
    if 'statement' not in provision_activity:
        return format_date(provision_activity['startDate'])

    punctuation = {'bf:Place': ' ; ', 'bf:Agent': ', '}

    statement_with_language = {'default': ''}
    statement_type = None

    for statement in provision_activity['statement']:
        labels = statement['label']

        for label in labels:
            language = label.get('language', 'default')

            if not statement_with_language.get(language):
                statement_with_language[language] = ''

            if statement_with_language[language]:
                if statement_type == statement['type']:
                    statement_with_language[language] += punctuation[
                        statement_type]
                else:
                    if statement['type'] == 'bf:Place':
                        statement_with_language[language] += ' ; '
                    elif statement['type'] == 'Date':
                        statement_with_language[language] += ', '
                    else:
                        statement_with_language[language] += ' : '

            statement_with_language[language] += label['value']
        statement_type = statement['type']

    # date field: remove ';' and append
    for key, value in statement_with_language.items():
        value = remove_trailing_punctuation(value)
        statement_with_language[key] = value
    return statement_with_language
Beispiel #3
0
def marc21_to_provision_activity_field_260(self, key, value):
    """Get provision activity data from field 260."""
    provision_activity = self.get('provisionActivity', [])

    # Only if there is a date
    if value.get('c'):
        publication = {'type': 'bf:Publication', 'statement': []}

        # Place
        if value.get('a'):
            publication['statement'].append({
                'type':
                'bf:Place',
                'label': [{
                    'value': value.get('a')
                }]
            })

        # Agent
        if value.get('b'):
            publication['statement'].append({
                'type':
                'bf:Agent',
                'label': [{
                    'value': remove_trailing_punctuation(value.get('b'))
                }]
            })

        years = value.get('c').split('-')

        # Start date
        if years:
            publication['startDate'] = years[0]

            publication['statement'].append({
                'type':
                'Date',
                'label': [{
                    'value': value.get('c')
                }]
            })

        # End date
        if len(years) > 1:
            publication['endDate'] = years[1]

        provision_activity.append(publication)

    # Manufacture
    if value.get('e') or value.get('f'):
        manufacture = {'type': 'bf:Manufacture', 'statement': []}

        if value.get('e'):
            manufacture['statement'].append({
                'type':
                'bf:Place',
                'label': [{
                    'value': remove_trailing_punctuation(value.get('e'))
                }]
            })

        if value.get('f'):
            manufacture['statement'].append({
                'type':
                'bf:Agent',
                'label': [{
                    'value': value.get('f')
                }]
            })

        provision_activity.append(manufacture)

    # Re-assign provision activity
    if provision_activity:
        self['provisionActivity'] = provision_activity

    return None