fix
[librarian.git] / src / librarian / dcparser.py
index 2072695..80c095f 100644 (file)
@@ -153,6 +153,9 @@ def as_unicode(text):
     else:
         return TextPlus(text.decode('utf-8'))
 
+def as_bool(text):
+    return text == 'true'
+as_bool.no_lang = True
 
 def as_wluri_strict(text):
     return WLURI.strict(text)
@@ -203,13 +206,13 @@ class Field(object):
                 if validator is None or val[0] is None:
                     return val[0]
                 nv = validator(val[0])
-                if hasattr(val[0], 'lang'):
+                if hasattr(val[0], 'lang') and not hasattr(validator, 'no_lang'):
                     setattr(nv, 'lang', val[0].lang)
                 return nv
         except ValueError as e:
             raise ValidationError(
                 "Field '%s' - invald value: %s"
-                % (self.uri, e.message)
+                % (self.uri, str(e))
             )
 
     def validate(self, fdict, fallbacks=None, strict=False, validate_required=True):
@@ -292,6 +295,8 @@ class WorkInfo(six.with_metaclass(DCInfo, object)):
         Field(PLMETNS('digitisationSponsor'), 'sponsors', multiple=True,
               required=False),
         Field(WLNS('digitisationSponsorNote'), 'sponsor_note', required=False),
+        Field(WLNS('contentWarning'), 'content_warnings', multiple=True,
+              required=False),
         Field(WLNS('developmentStage'), 'stage', required=False),
     )
 
@@ -504,6 +509,7 @@ class BookInfo(WorkInfo):
               required=False),
         Field(DCNS('subject.genre'), 'genres', salias='genre', multiple=True,
               required=False),
+        Field(WLNS('category.legimi'), 'legimi', required=False),
 
         Field(DCNS('subject.location'), 'location', required=False),
 
@@ -525,6 +531,8 @@ class BookInfo(WorkInfo):
         Field(WLNS('coverClass'), 'cover_class', default=['default']),
         Field(WLNS('coverLogoUrl'), 'cover_logo_urls', multiple=True,
               required=False),
+        Field(WLNS('endnotes'), 'endnotes', as_bool,
+              required=False),
 
         Field('pdf-id',  'isbn_pdf',  required=False),
         Field('epub-id', 'isbn_epub', required=False),