From 9ea0bf04235c89d6b50c4180e091793d30547bd3 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 3 Jun 2001 23:18:07 +0000 Subject: [PATCH] Better date range parsing, and handling of adopted children on GEDCOM import svn: r84 --- src/Date.py | 6 +++--- src/plugins/ReadGedcom.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/Date.py b/src/Date.py index 4109bbff0..89eb5b005 100644 --- a/src/Date.py +++ b/src/Date.py @@ -41,12 +41,12 @@ class Date: normal = 0 from_str = _("(from|between|bet)") - to_str = _("(and|to)") + to_str = _("(and|to|-)") - efmt = re.compile(r"\s*(from|between|bet)\s+(.+)\s+(and|to)\s+(.+)\s*$", + efmt = re.compile(r"\s*(from|between|bet)\.?\s+(.+)\s+(and|to)\s+(.+)\s*$", re.IGNORECASE) - fmt = re.compile(r"\s*" + from_str + r"\s+(.+)\s+" + to_str + r"\s+(.+)\s*$", + fmt = re.compile(r"\s*" + from_str + r"\.?\s+(.+)\s+" + to_str + r"\s+(.+)\s*$", re.IGNORECASE) def __init__(self): diff --git a/src/plugins/ReadGedcom.py b/src/plugins/ReadGedcom.py index f4717635d..3990f18a6 100644 --- a/src/plugins/ReadGedcom.py +++ b/src/plugins/ReadGedcom.py @@ -408,6 +408,28 @@ class GedcomParser: pass else: self.barf(level+1) + + #--------------------------------------------------------------------- + # + # + # + #--------------------------------------------------------------------- + def parse_ftw_relations(self,level): + retval = "" + + while 1: + matches = self.get_next() + if int(matches[0]) < level: + self.backup() + return retval + elif matches[1] == "_FREL": + if string.lower(matches[2]) != "natural": + retval = matches[2] + elif matches[1] == "_MREL": + if string.lower(matches[2]) != "natural": + retval = matches[2] + else: + self.barf(level+1) #--------------------------------------------------------------------- # @@ -428,8 +450,13 @@ class GedcomParser: self.family.setMother(self.db.findPerson(matches[2],self.pmap)) self.ignore_sub_junk(2) elif matches[1] == "CHIL": - self.family.addChild(self.db.findPerson(matches[2],self.pmap)) - self.ignore_sub_junk(2) + type = self.parse_ftw_relations(2) + child = self.db.findPerson(matches[2],self.pmap) + self.family.addChild(child) + if type != "": + if child.getMainFamily() == self.family: + child.setMainFamily(None) + child.addAltFamily(self.family,type) elif matches[1] == "NCHI" or matches[1] == "RIN" or matches[1] == "SUBM": pass elif matches[1] == "REFN" or matches[1] == "CHAN":