- def __repr__(self):
- return 'XMLNamespace(%r)' % self.uri
-
- def __str__(self):
- return '%s' % self.uri
-
-
-class BookInfo(object):
- 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),
- }
+ class_dict['FIELDS'] = tuple(fields)
+ return super(DCInfo, meta).__new__(meta, classname, bases, class_dict)
+
+
+class WorkInfo(object):
+ __metaclass__ = DCInfo
+
+ FIELDS = (
+ Field( DCNS('creator'), 'authors', as_person, salias='author', multiple=True),
+ Field( DCNS('title'), 'title'),
+ Field( DCNS('type'), 'type', required=False, multiple=True),
+
+ Field( DCNS('contributor.editor'), 'editors', \
+ as_person, salias='editor', multiple=True, default=[]),
+ Field( DCNS('contributor.technical_editor'), 'technical_editors',
+ as_person, salias='technical_editor', multiple=True, default=[]),
+ Field( DCNS('contributor.funding'), 'funders',
+ salias='funder', multiple=True, default=[]),
+ Field( DCNS('contributor.thanks'), 'thanks', required=False),
+
+ Field( DCNS('date'), 'created_at', as_date),
+ Field( DCNS('date.pd'), 'released_to_public_domain_at', as_date, required=False),
+ Field( DCNS('publisher'), 'publisher'),
+
+ Field( DCNS('language'), 'language'),
+ Field( DCNS('description'), 'description', required=False),
+
+ Field( DCNS('source'), 'source_name', required=False),
+ Field( DCNS('source.URL'), 'source_url', required=False),
+ Field( DCNS('identifier.url'), 'url', WLURI, strict=as_wluri_strict),
+ Field( DCNS('rights.license'), 'license', required=False),
+ Field( DCNS('rights'), 'license_description'),
+ )