diff --git a/src/plugins/import/ImportGeneWeb.py b/src/plugins/import/ImportGeneWeb.py index 40405c7b8..19a052fab 100644 --- a/src/plugins/import/ImportGeneWeb.py +++ b/src/plugins/import/ImportGeneWeb.py @@ -424,68 +424,67 @@ class GeneWebParser(object): #while idx < len(fields) and not fields[idx][0] == "+": while idx < len(fields) and not (fields[idx] and fields[idx][0] == "+"): if fields[idx]: - print "parse_marriage(): Unknown field: '%s' in line %d!" %(fields[idx],self.lineno) - idx = idx + 1 + print "parse_marriage(): Unknown field:", \ + "'%s' in line %d!" % (fields[idx], self.lineno) + idx += 1 while idx < len(fields) and mariageDataRe.match(fields[idx]): - if fields[idx][0] == "+": - mar_date = self.parse_date(self.decode(fields[idx])) - self.debug(" Married at: %s" % fields[idx]) - idx = idx + 1 - elif fields[idx][0] == "-": - div_date = self.parse_date(self.decode(fields[idx])) - self.debug(" Div at: %s" % fields[idx]) - idx = idx + 1 - elif fields[idx] == "#mp": - idx = idx + 1 + field = fields[idx] + idx += 1 + if field.startswith("+"): + mar_date = self.parse_date(self.decode(field)) + self.debug(" Married at: %s" % field) + elif field.startswith("-"): + div_date = self.parse_date(self.decode(field)) + self.debug(" Div at: %s" % field) + elif field == "#mp" and idx < len(fields): mar_place = self.get_or_create_place(self.decode(fields[idx])) self.debug(" Marriage place: %s" % fields[idx]) - idx = idx + 1 - elif fields[idx] == "#ms": - idx = idx + 1 + idx += 1 + elif field == "#ms" and idx < len(fields): mar_source = self.get_or_create_source(self.decode(fields[idx])) self.debug(" Marriage source: %s" % fields[idx]) - idx = idx + 1 - elif fields[idx] == "#sep": - idx = idx + 1 + idx += 1 + elif field == "#sep" and idx < len(fields): sep_date = self.parse_date(self.decode(fields[idx])) self.debug(" Seperated since: %s" % fields[idx]) - idx = idx + 1 - elif fields[idx] == "#nm": + idx += 1 + elif field == "#nm": self.debug(" Are not married.") married = 0 - idx = idx + 1 - elif fields[idx] == "#noment": + elif field == "#noment": self.debug(" Not mentioned.") - idx = idx + 1 - elif fields[idx] == "#eng": + elif field == "#eng": self.debug(" Are engaged.") engaged = 1 - idx = idx + 1 else: - print "parse_marriage(): Unknown field '%s'for mariage in line %d!" % (fields[idx],self.lineno) - idx = idx + 1 + print "parse_marriage(): Unknown field", \ + "'%s'for mariage in line %d!" % (field, self.lineno) if mar_date or mar_place or mar_source: - mar = self.create_event(gen.lib.EventType.MARRIAGE, None, mar_date, mar_place, mar_source) + mar = self.create_event( + gen.lib.EventType.MARRIAGE, None, mar_date, mar_place, mar_source) mar_ref = gen.lib.EventRef() mar_ref.set_reference_handle(mar.get_handle()) self.current_family.add_event_ref(mar_ref) if div_date: - div = self.create_event(gen.lib.EventType.DIVORCE, None, div_date, None, None) + div = self.create_event( + gen.lib.EventType.DIVORCE, None, div_date, None, None) div_ref = gen.lib.EventRef() div_ref.set_reference_handle(div.get_handle()) self.current_family.add_event_ref(div_ref) if sep_date or engaged: - sep = self.create_event(gen.lib.EventType.ENGAGEMENT, None, sep_date, None, None) + sep = self.create_event( + gen.lib.EventType.ENGAGEMENT, None, sep_date, None, None) sep_ref = gen.lib.EventRef() sep_ref.set_reference_handle(sep.get_handle()) self.current_family.add_event_ref(sep_ref) if not married: - self.current_family.set_relationship(gen.lib.FamilyRelType(gen.lib.FamilyRelType.UNMARRIED)) + self.current_family.set_relationship( + gen.lib.FamilyRelType(gen.lib.FamilyRelType.UNMARRIED)) self.db.commit_family(self.current_family,self.trans) return idx @@ -498,7 +497,7 @@ class GeneWebParser(object): surname ="" else: surname = self.decode(fields[idx]) - idx = idx + 1 + idx += 1 else: surname = father_surname @@ -507,12 +506,12 @@ class GeneWebParser(object): firstname = "" else: firstname = self.decode(fields[idx]) - idx = idx + 1 + idx += 1 if idx < len(fields) and father_surname: noSurnameRe = re.compile("^[({\[~>