From 3a54eb7edd3818e4567f7ffedb147ce3f2093b08 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 19 Feb 2006 04:45:54 +0000 Subject: [PATCH] * src/DisplayModels.py: display date properly * src/DisplayTabs.py: fix create_buttons default value * src/GrampsDb/_ReadGedcom.py: handle the "FORM" value for PLAC definition svn: r5956 --- ChangeLog | 6 ++++++ src/DisplayModels.py | 4 +++- src/DisplayTabs.py | 3 ++- src/GrampsDb/_ReadGedcom.py | 34 ++++++++++++++++++++++++++++++++-- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94fc0e47c..732d6dae1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-02-18 Don Allingham + * src/DisplayModels.py: display date properly + * src/DisplayTabs.py: fix create_buttons default value + * src/GrampsDb/_ReadGedcom.py: handle the "FORM" value for + PLAC definition + 2006-02-17 Don Allingham * src/GrampsDb/_ReadGedcom.py: fix character translation diff --git a/src/DisplayModels.py b/src/DisplayModels.py index 300aff26f..15ab9e1e3 100644 --- a/src/DisplayModels.py +++ b/src/DisplayModels.py @@ -612,7 +612,9 @@ class EventModel(BaseModel): def column_date(self,data): if data[3]: - return unicode(DateHandler.displayer.display(data[3])) + event = RelLib.Event() + event.unserialize(data) + return DateHandler.get_date(event) return u'' def column_handle(self,data): diff --git a/src/DisplayTabs.py b/src/DisplayTabs.py index e54a51ed4..9cc29f552 100644 --- a/src/DisplayTabs.py +++ b/src/DisplayTabs.py @@ -218,7 +218,7 @@ class ButtonTab(GrampsTab): self.tooltips = gtk.Tooltips() self.create_buttons(share_button) - def create_buttons(self,share_button): + def create_buttons(self,share_button=None): """ Creates a button box consisting of three buttons, one for Add, one for Edit, and one for Delete. This button box is then appended @@ -1454,6 +1454,7 @@ class EventRefModel(gtk.ListStore): def column_date(self,event_ref): event = self.db.get_event_from_handle(event_ref.ref) + print event, DateHandler.get_date(event) return DateHandler.get_date(event) def column_place(self,event_ref): diff --git a/src/GrampsDb/_ReadGedcom.py b/src/GrampsDb/_ReadGedcom.py index 2e4c5f26b..449b2cb71 100644 --- a/src/GrampsDb/_ReadGedcom.py +++ b/src/GrampsDb/_ReadGedcom.py @@ -81,6 +81,17 @@ addr3_re = re.compile('(.+)([\n\r]+)(.+)\s*,(.+)') # #------------------------------------------------------------------------- +_place_field = [] +_place_match = { + 'city' : RelLib.Location.set_city, + 'county' : RelLib.Location.set_county, + 'country': RelLib.Location.set_country, + 'state' : RelLib.Location.set_state, + } + +def _empty_func(a,b): + return + def utf8_to_latin(s): return s.encode('iso-8859-1','replace') @@ -943,6 +954,7 @@ class GedcomParser: intid = create_id() place.set_handle(intid) place.set_title(pname) + load_place_values(place,pname) place.set_gramps_id(new_id) self.db.add_place(place,self.trans) self.lid2id[title] = intid @@ -1183,7 +1195,6 @@ class GedcomParser: if int(matches[0]) < 1: self.backup() if state.get_text(): - print state state.person.set_note(state.get_text()) return else: @@ -1409,6 +1420,7 @@ class GedcomParser: try: place = self.find_or_create_place(matches[2]) place.set_title(matches[2]) + load_place_values(place,matches[2]) place_handle = place.handle lds_ord.set_place_handle(place_handle) self.ignore_sub_junk(level+1) @@ -1462,6 +1474,7 @@ class GedcomParser: place = self.find_or_create_place(val) place_handle = place.handle place.set_title(matches[2]) + load_place_values(place,matches[2]) event.set_place_handle(place_handle) self.ignore_sub_junk(level+1) elif matches[1] == TOKEN_CAUS: @@ -1515,6 +1528,7 @@ class GedcomParser: place = self.find_or_create_place(val) place_handle = place.handle place.set_title(matches[2]) + load_place_values(place,matches[2]) event.set_place_handle(place_handle) self.ignore_sub_junk(level+1) elif matches[1] == TOKEN_TYPE: @@ -1622,6 +1636,7 @@ class GedcomParser: place = self.find_or_create_place(val) place_handle = place.handle place.set_title(matches[2]) + load_place_values(place,matches[2]) event.set_place_handle(place_handle) self.ignore_sub_junk(level+1) elif matches[1] == TOKEN_OFFI: @@ -1840,7 +1855,12 @@ class GedcomParser: if int(matches[0]) < level: self.backup() return - elif matches[1] != TOKEN_FORM: + elif matches[1] == TOKEN_FORM: + for item in matches[2].split(','): + item = item.lower().strip() + fcn = _place_match.get(item,_empty_func) + _place_field.append(fcn) + else: self.barf(level+1) def parse_date(self,level): @@ -2364,6 +2384,16 @@ def person_event_name(event,person): 'person' : NameDisplay.displayer.display(person), } event.set_description(text) + +def load_place_values(place,text): + items = text.split(',') + if len(items) != len(_place_field): + return + loc = place.get_main_location() + index = 0 + for item in items: + _place_field[index](loc,item.strip()) + index += 1 #------------------------------------------------------------------------- #