7212: convert invalid date to text on .gw import
Implement the feature.
This commit is contained in:
parent
1ac0e2a0bc
commit
8299866f3c
@ -50,7 +50,10 @@ LOG = logging.getLogger(".ImportGeneWeb")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gramps.gen.errors import GedcomError
|
from gramps.gen.errors import GedcomError
|
||||||
from gramps.gen.lib import Attribute, AttributeType, ChildRef, Citation, Date, Event, EventRef, EventRoleType, EventType, Family, FamilyRelType, Name, NameType, Note, Person, PersonRef, Place, Source
|
from gramps.gen.lib import (Attribute, AttributeType, ChildRef, Citation,
|
||||||
|
Date, DateError, Event, EventRef, EventRoleType, EventType,
|
||||||
|
Family, FamilyRelType, Name, NameType, Note, Person, PersonRef,
|
||||||
|
Place, Source)
|
||||||
from gramps.gen.db import DbTxn
|
from gramps.gen.db import DbTxn
|
||||||
from gramps.gen.constfunc import STRTYPE, cuni, conv_to_unicode
|
from gramps.gen.constfunc import STRTYPE, cuni, conv_to_unicode
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
@ -816,8 +819,17 @@ class GeneWebParser(object):
|
|||||||
sub2 = (0,0,0)
|
sub2 = (0,0,0)
|
||||||
cal1 = _cal_map.get(groups[2],Date.CAL_GREGORIAN)
|
cal1 = _cal_map.get(groups[2],Date.CAL_GREGORIAN)
|
||||||
sub1 = self.sub_date(groups[1])
|
sub1 = self.sub_date(groups[1])
|
||||||
date.set(Date.QUAL_NONE,mod, cal1,
|
try:
|
||||||
(sub1[0],sub1[1],sub1[2],0,sub2[0],sub2[1],sub2[2],0))
|
date.set(Date.QUAL_NONE,mod, cal1,
|
||||||
|
(sub1[0],sub1[1],sub1[2],0,sub2[0],sub2[1],sub2[2],0))
|
||||||
|
except DateError as e:
|
||||||
|
# TRANSLATORS: leave the {date} and {gw_snippet} untranslated
|
||||||
|
# in the format string, but you may re-order them if needed.
|
||||||
|
LOG.warning(_(
|
||||||
|
"Invalid date {date} in {gw_snippet}, "
|
||||||
|
"preserving date as text."
|
||||||
|
).format(date=e.date.to_struct(), gw_snippet=field))
|
||||||
|
date.set(modifier=Date.MOD_TEXTONLY, text=field)
|
||||||
return date
|
return date
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user