- RDF = XMLNamespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
- DC = XMLNamespace('http://purl.org/dc/elements/1.1/')
-
- mapping = {
- DC('creator') : ('author', str_to_person),
- DC('title') : ('title', str_to_unicode),
- DC('subject.period') : ('epoch', str_to_unicode),
- DC('subject.type') : ('kind', str_to_unicode),
- DC('subject.genre') : ('genre', str_to_unicode),
- DC('date') : ('created_at', str_to_date),
- DC('date.pd') : ('released_to_public_domain_at', str_to_date),
- DC('contributor.translator') : ('translator', str_to_person),
- DC('contributor.technical_editor') : ('technical_editor', str_to_person),
- DC('publisher') : ('publisher', str_to_unicode),
- DC('source') : ('source_name', str_to_unicode),
- DC('source.URL') : ('source_url', str_to_unicode),
- DC('identifier.url') : ('url', str_to_unicode),
- DC('relation.hasPart') : ('parts', str_to_unicode_list),
- DC('rights.license') : ('license', str_to_unicode),
- DC('rights') : ('license_description', str_to_unicode),
- }
+ FIELDS = (
+ Field( DCNS('creator'), 'author', as_person),
+ Field( DCNS('title'), 'title'),
+ Field( DCNS('subject.period'), 'epochs', salias='epoch', multiple=True),
+ Field( DCNS('subject.type'), 'kinds', salias='kind', multiple=True),
+ Field( DCNS('subject.genre'), 'genres', salias='genre', multiple=True),
+ Field( DCNS('date'), 'created_at', as_date),
+ Field( DCNS('date.pd'), 'released_to_public_domain_at', as_date, required=False),
+ Field( DCNS('contributor.editor'), 'editors', \
+ as_person, salias='editor', multiple=True, default=[]),
+ Field( DCNS('contributor.translator'), 'translators', \
+ as_person, salias='translator', multiple=True, default=[]),
+ Field( DCNS('contributor.technical_editor'), 'technical_editors',
+ as_person, salias='technical_editor', multiple=True, default=[]),
+ Field( DCNS('publisher'), 'publisher'),
+ Field( DCNS('source'), 'source_name', required=False),
+ Field( DCNS('source.URL'), 'source_url', required=False),
+ Field( DCNS('identifier.url'), 'url'),
+ Field( DCNS('relation.hasPart'), 'parts', multiple=True, required=False),
+ Field( DCNS('rights.license'), 'license', required=False),
+ Field( DCNS('rights'), 'license_description'),
+ )
+
+ @property
+ def slug(self):
+ return self.url.rsplit('/', 1)[1]