From 0115ebb09e9fbbc29f08dabb2c505743fc75372f Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 4 Oct 2004 04:28:58 +0000 Subject: [PATCH] * src/ReadXML.py: name enhancements * src/WriteXML.py: name enhancements svn: r3596 --- gramps2/ChangeLog | 2 ++ gramps2/src/EditPerson.py | 1 + gramps2/src/PeopleView.py | 11 ++++++----- gramps2/src/ReadXML.py | 6 ++++++ gramps2/src/RelLib.py | 9 +++++++++ gramps2/src/WriteXML.py | 29 +++++++++++++++++++++++------ 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index e14b298da..954b56fbd 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -2,6 +2,8 @@ * src/data/tips.xml: Add more tips. 2004-10-03 Don Allingham + * src/ReadXML.py: name enhancements + * src/WriteXML.py: name enhancements * src/Date.py: fix get_month_valid call * src/DateDisplay.py: pychecker fixes * src/EditPerson.py: pychecker fixes diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 2d7c1f0e9..c56385eca 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -1654,6 +1654,7 @@ class EditPerson: ntype = unicode(self.ntype_field.child.get_text()) self.pname.set_type(const.NameTypesMap.find_value(ntype)) self.pname.set_suffix(unicode(self.suffix.get_text())) + self.pname.set_surname(unicode(self.surname.get_text())) self.pname.set_surname_prefix(unicode(self.prefix.get_text())) self.pname.set_first_name(unicode(self.given.get_text())) self.pname.set_title(unicode(self.title.get_text())) diff --git a/gramps2/src/PeopleView.py b/gramps2/src/PeopleView.py index 98f6aabd6..bf2858b05 100644 --- a/gramps2/src/PeopleView.py +++ b/gramps2/src/PeopleView.py @@ -262,13 +262,14 @@ class PeopleView: def add_person(self,person): node = person.get_handle() top = person.get_primary_name().get_group_name() - if len(self.person_model.sname_sub[top]) == 1: + if not self.person_model.sname_sub.has_key(top) or \ + len(self.person_model.sname_sub[top]) == 1: path = self.person_model.on_get_path(top) - node = self.person_model.get_iter(path) - self.person_model.row_inserted(path,node) + pnode = self.person_model.get_iter(path) + self.person_model.row_inserted(path,pnode) path = self.person_model.on_get_path(node) - node = self.person_model.get_iter(path) - self.person_model.row_inserted(path,node) + pnode = self.person_model.get_iter(path) + self.person_model.row_inserted(path,pnode) def delete_person(self,person): node = person.get_handle() diff --git a/gramps2/src/ReadXML.py b/gramps2/src/ReadXML.py index c5d78c863..375151174 100644 --- a/gramps2/src/ReadXML.py +++ b/gramps2/src/ReadXML.py @@ -816,6 +816,10 @@ class GrampsParser: self.name = RelLib.Name() if attrs.has_key("type"): self.name.set_type(attrs["type"]) + if attrs.has_key("sort"): + self.name.set_sort_as(int(attrs["sort"])) + if attrs.has_key("display"): + self.name.set_display_as(int(attrs["display"])) if attrs.has_key("conf"): self.name.set_confidence(int(attrs["conf"])) else: @@ -826,6 +830,8 @@ class GrampsParser: def start_last(self,attrs): if attrs.has_key('prefix'): self.name.set_surname_prefix(attrs['prefix']) + if attrs.has_key('group'): + self.name.set_group_as(attrs['group']) def start_note(self,attrs): self.in_note = 1 diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 8f9d216e2..4157e4638 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -1949,6 +1949,11 @@ class Name(DataObj): self.first_name = name self.build_sort_name() + def set_patronymic(self,name): + """sets the patronymic name for the Name instance""" + self.patronymic = name + self.build_sort_name() + def set_surname(self,name): """sets the surname (or last name) for the Name instance""" self.surname = name @@ -1966,6 +1971,10 @@ class Name(DataObj): """returns the given name for the Name instance""" return self.first_name + def get_patronymic(self): + """returns the patronymic name for the Name instance""" + return self.patronymic + def get_surname(self): """returns the surname (or last name) for the Name instance""" return self.surname diff --git a/gramps2/src/WriteXML.py b/gramps2/src/WriteXML.py index dd56fc584..4316742e9 100644 --- a/gramps2/src/WriteXML.py +++ b/gramps2/src/WriteXML.py @@ -423,6 +423,13 @@ class XmlWriter: self.g.write(' \n' % person_handle) self.g.write(" \n") + if len(self.db.name_group) > 0: + self.g.write(' \n') + for key in self.db.name_group.keys(): + self.g.write(' \n' % + (key,self.db.name_group[key])) + self.g.write(' \n') + self.g.write("\n") def fix(self,line): @@ -581,10 +588,13 @@ class XmlWriter: def write_last(self,name,indent=1): p = name.get_surname_prefix() n = name.get_surname() + g = name.get_group_as() + self.g.write('%s%s\n' % (' '*indent,p,self.fix(n))) - else: - self.g.write('%s%s\n' % (' '*indent,self.fix(n))) + self.g.write(' prefix="%s"' % p) + if g: + self.g.write(' group="%s"' % g) + self.g.write('>%s\n' % self.fix(n)) def write_line(self,label,value,indent=1): if value: @@ -647,13 +657,20 @@ class XmlWriter: def dump_name(self,label,name,index=1): sp = " "*index name_type = name.get_type() + self.g.write('%s<%s' % (sp,label)) if name_type: - self.g.write('%s<%s type="%s"%s>\n' % (sp,label,name_type,conf_priv(name))) - else: - self.g.write('%s<%s%s>\n' % (sp,label,conf_priv(name))) + self.g.write(' type="%s"' % name_type) + if name.get_privacy() != 0: + self.g.write(' priv="%d"' % name.get_privacy()) + if name.get_sort_as() != 0: + self.g.write(' sort="%d"' % name.get_sort_as()) + if name.get_display_as() != 0: + self.g.write(' display="%d"' % name.get_display_as()) + self.g.write('>\n') self.write_line("first",name.get_first_name(),index+1) self.write_last(name,index+1) self.write_line("suffix",name.get_suffix(),index+1) + self.write_line("patronymic",name.get_patronymic(),index+1) self.write_line("title",name.get_title(),index+1) if name.get_note() != "": self.write_note("note",name.get_note_object(),index+1)