Beispiel #1
0
class BaseMods(Common):
    ''':class:`~eulxml.xmlmap.XmlObject` with common field declarations for all
    top-level MODS elements; base class for :class:`MODS` and :class:`RelatedItem`.'''
    schema_validate = True

    id = xmlmap.StringField("@ID")
    title = xmlmap.StringField("mods:titleInfo/mods:title")
    title_info = xmlmap.NodeField('mods:titleInfo', TitleInfo)
    title_info_list = xmlmap.NodeListField('mods:titleInfo', TitleInfo)
    resource_type = xmlmap.SchemaField("mods:typeOfResource",
                                       "resourceTypeDefinition")
    name = xmlmap.NodeField('mods:name', Name)  # DEPRECATED: use names instead
    names = xmlmap.NodeListField('mods:name', Name)
    note = xmlmap.NodeField('mods:note', Note)
    notes = xmlmap.NodeListField('mods:note', Note)
    origin_info = xmlmap.NodeField('mods:originInfo', OriginInfo)
    record_info = xmlmap.NodeField('mods:recordInfo', RecordInfo)
    identifiers = xmlmap.NodeListField('mods:identifier', Identifier)
    access_conditions = xmlmap.NodeListField('mods:accessCondition',
                                             AccessCondition)
    genres = xmlmap.NodeListField('mods:genre', Genre)
    languages = xmlmap.NodeListField('mods:language', Language)
    location = xmlmap.StringField('mods:location/mods:physicalLocation',
                                  required=False)
    locations = xmlmap.NodeListField('mods:location', Location)
    subjects = xmlmap.NodeListField('mods:subject', Subject)
    physical_description = xmlmap.NodeField('mods:physicalDescription',
                                            PhysicalDescription)
    abstract = xmlmap.NodeField('mods:abstract', Abstract)
    parts = xmlmap.NodeListField('mods:part', Part)
Beispiel #2
0
class NamePart(Common):
    ':class:`~eulxml.xmlmap.XmlObject` for MODS namePart'
    ROOT_NAME = 'namePart'
    # FIXME: schema required here for schemafields; this should be refactored

    type = xmlmap.SchemaField('@type',
                              'namePartTypeAttributeDefinition',
                              required=False)  # type is optional
    text = xmlmap.StringField('text()')
Beispiel #3
0
class Date(Common):
    ''':class:`~eulxml.xmlmap.XmlObject` for MODS date element (common fields
    for the dates under mods:originInfo).'''
    # this class not meant for direct use; should be extended for specific dates.

    date = xmlmap.StringField('text()')
    key_date = xmlmap.SimpleBooleanField('@keyDate', 'yes', false=None)
    encoding = xmlmap.SchemaField('@encoding',
                                  'dateEncodingAttributeDefinition')
    point = xmlmap.SchemaField('@point', 'datePointAttributeDefinition')
    qualifier = xmlmap.SchemaField('@qualifier',
                                   'dateQualifierAttributeDefinition')

    def is_empty(self):
        '''Returns False if no date value is set; returns True if any date value
        is set.  Attributes are ignored for determining whether or not the
        date should be considered empty, as they are only meaningful in
        reference to a date value.'''
        return not self.node.text

    def __str__(self):
        return self.date
Beispiel #4
0
class TitleInfo(Common):
    ROOT_NAME = 'titleInfo'

    title = xmlmap.StringField('mods:title')
    subtitle = xmlmap.StringField('mods:subTitle')
    part_number = xmlmap.StringField('mods:partNumber')
    part_name = xmlmap.StringField('mods:partName')
    non_sort = xmlmap.StringField('mods:nonSort')
    type = xmlmap.SchemaField('@type', 'titleInfoTypeAttributeDefinition')
    label = xmlmap.StringField('@displayLabel')

    def is_empty(self):
        '''Returns True if all titleInfo subfields are not set or
        empty; returns False if any of the fields are not empty.'''
        return not bool(self.title or self.subtitle or self.part_number \
                        or self.part_name or self.non_sort or self.type)
Beispiel #5
0
class Name(Common):
    ':class:`~eulxml.xmlmap.XmlObject` for MODS name'
    ROOT_NAME = 'name'

    type = xmlmap.SchemaField('@type',
                              'nameTypeAttributeDefinition',
                              required=False)
    authority = xmlmap.StringField('@authority',
                                   choices=['', 'local', 'naf'],
                                   required=False)  # naf = NACO authority file
    id = xmlmap.StringField('@ID', required=False)  # optional
    name_parts = xmlmap.NodeListField('mods:namePart', NamePart)
    display_form = xmlmap.StringField('mods:displayForm')
    affiliation = xmlmap.StringField('mods:affiliation')
    roles = xmlmap.NodeListField('mods:role', Role)

    def __unicode__(self):
        # default text display of a name (excluding roles for now)
        # TODO: improve logic for converting to plain-text name
        # (e.g., for template display, setting as dc:creator, etc)
        return ' '.join([unicode(part) for part in self.name_parts])
Beispiel #6
0
class RelatedItem(BaseMods):
    ''':class:`~eulxml.xmlmap.XmlObject` for MODS relatedItem: contains all the
    top-level MODS fields defined by :class:`BaseMods`, plus a type attribute.'''
    ROOT_NAME = 'relatedItem'
    type = xmlmap.SchemaField("@type", 'relatedItemTypeAttributeDefinition')
    label = xmlmap.StringField('@displayLabel')