From 1f5447fca3ebf34a5797404dd61f4134ef54f526 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 30 Jun 2002 18:17:18 +0000 Subject: [PATCH] GEDCOM import improvements svn: r1061 --- src/Date.py | 4 +++ src/GedcomInfo.py | 10 ------ src/QuestionDialog.py | 11 ------- src/ReadXML.py | 15 --------- src/latin_utf8.py | 5 ++- src/plugins/ChangeTypes.py | 3 -- src/plugins/ReadGedcom.py | 66 ++++++++++++++++++++------------------ 7 files changed, 43 insertions(+), 71 deletions(-) diff --git a/src/Date.py b/src/Date.py index 2e0372c5d..3aa6421d0 100644 --- a/src/Date.py +++ b/src/Date.py @@ -243,6 +243,10 @@ class Date: self.range = -1 self.text = text + def set_text(self,text): + self.range = -1 + self.text = text + def set_range(self,val): self.range = val diff --git a/src/GedcomInfo.py b/src/GedcomInfo.py index d8ea50b28..bd220ce8f 100644 --- a/src/GedcomInfo.py +++ b/src/GedcomInfo.py @@ -220,13 +220,3 @@ class GedInfoParser: elif tag == "residence": if u2l(attrs['val']) == 'place': self.current.set_resi(RESIDENCE_PLAC) - - -if __name__ == "__main__": - - g = GedcomInfoDB() - - print g.get_name_list() - o = g.get_description("Family Tree Maker") - for key in o.gramps2tag_map.keys(): - print key,o.gramps2tag(key) diff --git a/src/QuestionDialog.py b/src/QuestionDialog.py index c3d9c0ba6..58296a187 100644 --- a/src/QuestionDialog.py +++ b/src/QuestionDialog.py @@ -47,14 +47,3 @@ class QuestionDialog: self.task2() self.top.destroy() - -if __name__ == '__main__': - def task1(obj): - print obj,'1' - - def task2(obj): - print obj,'2' - - QuestionDialog('mytitle','This is my message','Abc',task1,'Def',task2) - - gtk.mainloop() diff --git a/src/ReadXML.py b/src/ReadXML.py index 246438eeb..e2e538c90 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -199,18 +199,3 @@ def loadRevision(database, file, filename, revision, callback=None): file.close() return 1 - - -if __name__ == "__main__": - import profile - import sys - import time - - database = GrampsDB() - t1 = time.time() - if len(sys.argv) > 2: - profile.run('loadData(database, sys.argv[1])') - else: - loadData(database,sys.argv[1]) - t2 = time.time() - print t2-t1 diff --git a/src/latin_utf8.py b/src/latin_utf8.py index 567a6d7c0..66707dc74 100644 --- a/src/latin_utf8.py +++ b/src/latin_utf8.py @@ -36,7 +36,10 @@ else: def utf8_to_latin(s): y = UTF8String(s) - return y.encode("iso-8859-1") + try: + return y.encode("iso-8859-1") + except: + return y.encode("") def latin_to_utf8(s): buff = cStringIO.StringIO() diff --git a/src/plugins/ChangeTypes.py b/src/plugins/ChangeTypes.py index 58efc3006..012c6b672 100644 --- a/src/plugins/ChangeTypes.py +++ b/src/plugins/ChangeTypes.py @@ -66,11 +66,8 @@ class ChangeTypes: original = self.glade.get_widget("original_text").get_text() new = self.glade.get_widget("new_text").get_text() - print original - print new for person in self.db.getPersonMap().values(): for event in person.getEventList(): - print event.getName() if event.getName() == original: event.setName(new) modified = modified + 1 diff --git a/src/plugins/ReadGedcom.py b/src/plugins/ReadGedcom.py index 9ae08cf67..be437fc36 100644 --- a/src/plugins/ReadGedcom.py +++ b/src/plugins/ReadGedcom.py @@ -917,6 +917,7 @@ class GedcomParser: self.family.addPhoto(photo) def parse_residence(self,address,level): + note = "" while 1: matches = self.get_next() @@ -1293,6 +1294,7 @@ class GedcomParser: def parse_name(self,name,level): """Parses the person's name information""" + note = "" while 1: matches = self.get_next() if int(matches[0]) < level: @@ -1538,38 +1540,40 @@ class GedcomParser: def extract_date(self,text): dateobj = Date.Date() - match = fromtoRegexp.match(text) - if match: - (cal1,data1,cal2,data2) = match.groups() - if cal1 != cal2: - pass - - if cal1 == "FRENCH R": - dateobj.set_calendar(Date.FRENCH) - elif cal1 == "JULIAN": - dateobj.set_calendar(Date.JULIAN) - elif cal1 == "HEBREW": - dateobj.set_calendar(Date.HEBREW) - dateobj.get_start_date().set(data1) - dateobj.get_stop_date().set(data2) - dateobj.set_range(1) - return dateobj + try: + match = fromtoRegexp.match(text) + if match: + (cal1,data1,cal2,data2) = match.groups() + if cal1 != cal2: + pass + + if cal1 == "FRENCH R": + dateobj.set_calendar(Date.FRENCH) + elif cal1 == "JULIAN": + dateobj.set_calendar(Date.JULIAN) + elif cal1 == "HEBREW": + dateobj.set_calendar(Date.HEBREW) + dateobj.get_start_date().set(data1) + dateobj.get_stop_date().set(data2) + dateobj.set_range(1) + return dateobj - match = calRegexp.match(text) - if match: - (abt,cal,data) = match.groups() - if cal == "FRENCH R": - dateobj.set_calendar(Date.FRENCH) - elif cal == "JULIAN": - dateobj.set_calendar(Date.JULIAN) - elif cal == "HEBREW": - dateobj.set_calendar(Date.HEBREW) - dateobj.set(data) - if abt: - dateobj.get_start_date().setMode(abt) - else: - dateobj.set(text) - + match = calRegexp.match(text) + if match: + (abt,cal,data) = match.groups() + if cal == "FRENCH R": + dateobj.set_calendar(Date.FRENCH) + elif cal == "JULIAN": + dateobj.set_calendar(Date.JULIAN) + elif cal == "HEBREW": + dateobj.set_calendar(Date.HEBREW) + dateobj.set(data) + if abt: + dateobj.get_start_date().setMode(abt) + else: + dateobj.set(text) + except: + dateobj.set_text(text) return dateobj def handle_source(self,matches,level):