[PATCH 2 of 3 eac] [dataimport] Add a special message when date is not properly set

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Apr 14 15:31:07 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1492176169 -7200
#      Fri Apr 14 15:22:49 2017 +0200
# Node ID 75de74eba67906a6c75e9021858e52bdc2d86c04
# Parent  a07698e9d41359c8cb9b9b38e1dc0d75bcffc6e7
[dataimport] Add a special message when date is not properly set

instead of 'unexpected parse error' because date is None / empty.

diff --git a/cubicweb_eac/dataimport.py b/cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py
+++ b/cubicweb_eac/dataimport.py
@@ -696,10 +696,13 @@ class EACCPFImporter(object):
                 if elem.attrib.get(attr):
                     record_warning(self._('found an unsupported %s attribute in date '
                                           'element %%(e)s') % attr)
             # Using element's text.
             date = elem.text
+            if not date:
+                record_warning(self._('no date specified'))
+                return None
         # Set a default value for month and day; the year should always be
         # given.
         default = datetime.datetime(9999, 1, 1)
         try:
             pdate = parse_date(date, default=default)
diff --git a/cubicweb_eac/i18n/en.po b/cubicweb_eac/i18n/en.po
--- a/cubicweb_eac/i18n/en.po
+++ b/cubicweb_eac/i18n/en.po
@@ -1090,10 +1090,13 @@ msgstr "name entries"
 
 msgctxt "AuthorityRecord"
 msgid "name_entry_for_object"
 msgstr ""
 
+msgid "no date specified"
+msgstr ""
+
 msgid "note"
 msgstr ""
 
 msgctxt "Citation"
 msgid "note"
diff --git a/cubicweb_eac/i18n/fr.po b/cubicweb_eac/i18n/fr.po
--- a/cubicweb_eac/i18n/fr.po
+++ b/cubicweb_eac/i18n/fr.po
@@ -1108,10 +1108,13 @@ msgstr "formes du nom"
 
 msgctxt "AuthorityRecord"
 msgid "name_entry_for_object"
 msgstr ""
 
+msgid "no date specified"
+msgstr "pas de valeur spécifiée pour la date"
+
 msgid "note"
 msgstr ""
 
 msgctxt "Citation"
 msgid "note"


More information about the saem-devel mailing list