From 5084294a1ecda234819b9b4073ed14a378be8db7 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Thu, 28 Oct 2010 19:56:46 +0000 Subject: [PATCH] Various fixes for GEP21 and locality * narweb and webcal works again * proxy filters work * locality upgrade in repository * fix progress on upgrade svn: r16074 --- src/gen/db/base.py | 2 +- src/gen/db/read.py | 4 ++-- src/gen/db/upgrade.py | 7 ++++--- src/gen/display/name.py | 24 +++++++++++++++--------- src/gen/proxy/living.py | 9 +++++---- src/gen/proxy/private.py | 13 ++++++++----- src/gen/proxy/proxybase.py | 4 ++-- src/gui/editors/editname.py | 10 +++++----- src/plugins/webreport/NarrativeWeb.py | 18 ++++++------------ src/plugins/webreport/WebCal.py | 11 +++-------- 10 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/gen/db/base.py b/src/gen/db/base.py index 6a128727c..ba19e9c99 100644 --- a/src/gen/db/base.py +++ b/src/gen/db/base.py @@ -343,7 +343,7 @@ class DbReadBase(object): """ raise NotImplementedError - def get_name_group_mapping(self, name): + def get_name_group_mapping(self, surname): """ Return the default grouping name for a surname. """ diff --git a/src/gen/db/read.py b/src/gen/db/read.py index 0c1df20ad..7631aac1f 100644 --- a/src/gen/db/read.py +++ b/src/gen/db/read.py @@ -745,11 +745,11 @@ class DbBsddbRead(DbReadBase, Callback): return self.__get_obj_from_gramps_id(val, self.tag_trans, Tag, self.tag_map) - def get_name_group_mapping(self, name): + def get_name_group_mapping(self, surname): """ Return the default grouping name for a surname. """ - return unicode(self.name_group.get(str(name), name)) + return unicode(self.name_group.get(str(surname), surname)) def get_name_group_keys(self): """ diff --git a/src/gen/db/upgrade.py b/src/gen/db/upgrade.py index 96dca3421..937341a91 100644 --- a/src/gen/db/upgrade.py +++ b/src/gen/db/upgrade.py @@ -111,7 +111,7 @@ def gramps_upgrade_15(self): with BSDDBTxn(self.env, self.person_map) as txn: txn.put(str(handle), new_person) - self.update(length) + self.update() #surname is now different, remove secondary index with names _db = db.DB(self.env) try: @@ -183,7 +183,7 @@ def gramps_upgrade_15(self): # --------------------------------- # Modify Place # --------------------------------- - # Remove the old marker field. + # Remove the old marker field, set new locality. for handle in self.place_map.keys(): place = self.place_map[handle] new_place = list(place) @@ -211,11 +211,12 @@ def gramps_upgrade_15(self): # --------------------------------- # Modify Repository # --------------------------------- - # Remove the old marker field. + # Remove the old marker field, set new locality. for handle in self.repository_map.keys(): repository = self.repository_map[handle] new_repository = list(repository) new_repository = new_repository[:7] + new_repository[8:] + new_repository[5] = [convert_address(addr) for addr in new_repository[5]] new_repository = tuple(new_repository) with BSDDBTxn(self.env, self.repository_map) as txn: txn.put(str(handle), new_repository) diff --git a/src/gen/display/name.py b/src/gen/display/name.py index 7de772d96..86268ba6f 100644 --- a/src/gen/display/name.py +++ b/src/gen/display/name.py @@ -147,6 +147,13 @@ def _raw_primary_surname(raw_surn_data_list): return ' '.join(result.split()) return '' +def _raw_primary_surname_only(raw_surn_data_list): + """method for the 'm' symbol: primary surname""" + for raw_surn_data in raw_surn_data_list: + if raw_surn_data[_PRIMARY_IN_LIST]: + return raw_surn_data[_SURNAME_IN_LIST] + return '' + def _raw_patro_surname(raw_surn_data_list): """method for the 'y' symbol: patronymic surname""" for raw_surn_data in raw_surn_data_list: @@ -763,28 +770,27 @@ def fn(%s): return pn.group_as sv = pn.sort_as if sv == Name.DEF: - return db.get_name_group_mapping(pn.get_primary_surname()) + return db.get_name_group_mapping(pn.get_primary_surname().get_surname()) elif sv == Name.LNFN: - return db.get_name_group_mapping(pn.get_surname()) + return pn.get_surname() elif sv == Name.FN: - return db.get_name_group_mapping(pn.first_name) + return pn.first_name else: - return db.get_name_group_mapping(pn.get_primary_surname()) + return db.get_name_group_mapping(pn.get_primary_surname().get_surname()) def name_grouping_data(self, db, pn): if pn[_GROUP]: return pn[_GROUP] sv = pn[_SORT] if sv == Name.DEF: - return db.get_name_group_mapping(_raw_primary_surname( + return db.get_name_group_mapping(_raw_primary_surname_only( pn[_SURNAME_LIST])) elif sv == Name.LNFN: - return db.get_name_group_mapping(_raw_full_surname( - pn[_SURNAME_LIST])) + return _raw_full_surname(pn[_SURNAME_LIST]) elif sv == Name.FN: - return db.get_name_group_mapping(pn[_FIRSTNAME]) + return pn[_FIRSTNAME] else: - return db.get_name_group_mapping(_raw_primary_surname( + return db.get_name_group_mapping(_raw_primary_surname_only( pn[_SURNAME_LIST])) displayer = NameDisplay() diff --git a/src/gen/proxy/living.py b/src/gen/proxy/living.py index db27bc0ab..fd22ed6e9 100644 --- a/src/gen/proxy/living.py +++ b/src/gen/proxy/living.py @@ -37,7 +37,7 @@ from itertools import ifilter # #------------------------------------------------------------------------- from proxybase import ProxyDbBase -from gen.lib import Date, Person, Name +from gen.lib import Date, Person, Name, Surname from Utils import probably_alive import config @@ -261,7 +261,6 @@ class LivingProxyDb(ProxyDbBase): new_name.set_group_as(old_name.get_group_as()) new_name.set_sort_as(old_name.get_sort_as()) new_name.set_display_as(old_name.get_display_as()) - new_name.set_surname_prefix(old_name.get_surname_prefix()) new_name.set_type(old_name.get_type()) if self.mode == self.MODE_INCLUDE_LAST_NAME_ONLY: new_name.set_first_name(config.get('preferences.private-given-text')) @@ -269,8 +268,10 @@ class LivingProxyDb(ProxyDbBase): new_name.set_first_name(old_name.get_first_name()) new_name.set_suffix(old_name.get_suffix()) new_name.set_title(old_name.get_title()) - new_name.set_patronymic(old_name.get_patronymic()) - new_name.set_surname(old_name.get_surname()) + surnlst = [] + for surn in name.get_surname_list(): + surnlst.append(Surname(source=surn)) + new_name.set_surname_list(surnlst) new_name.set_privacy(old_name.get_privacy()) new_person.set_primary_name(new_name) diff --git a/src/gen/proxy/private.py b/src/gen/proxy/private.py index 081f57251..bd06bae29 100644 --- a/src/gen/proxy/private.py +++ b/src/gen/proxy/private.py @@ -39,7 +39,7 @@ from gen.ggettext import gettext as _ #------------------------------------------------------------------------- from gen.lib import (MediaRef, SourceRef, Attribute, Address, EventRef, Person, Name, Source, RepoRef, MediaObject, Place, Event, - Family, ChildRef, Repository, LdsOrd) + Family, ChildRef, Repository, LdsOrd, Surname) from proxybase import ProxyDbBase class PrivateProxyDb(ProxyDbBase): @@ -644,14 +644,14 @@ def sanitize_name(db, name): new_name.set_sort_as(name.get_sort_as()) new_name.set_display_as(name.get_display_as()) new_name.set_call_name(name.get_call_name()) - new_name.set_surname_prefix(name.get_surname_prefix()) + new_name.set_nick_name(name.get_nick_name()) + new_name.set_family_nick_name(name.get_family_nick_name()) new_name.set_type(name.get_type()) new_name.set_first_name(name.get_first_name()) - new_name.set_patronymic(name.get_patronymic()) - new_name.set_surname(name.get_surname()) new_name.set_suffix(name.get_suffix()) new_name.set_title(name.get_title()) new_name.set_date_object(name.get_date_object()) + new_name.set_surname_list(name.get_surname_list()) copy_source_ref_list(db, name, new_name) copy_notes(db, name, new_name) @@ -756,7 +756,10 @@ def sanitize_person(db, person): if (name and name.get_privacy()) or (person and person.get_privacy()): # Do this so a person always has a primary name of some sort. name = Name() - name.set_surname(_('Private')) + surn = Surname() + surn.set_surname(_('Private')) + name.set_surname_list([surn]) + name.set_primary_surname() else: name = sanitize_name(db, name) new_person.set_primary_name(name) diff --git a/src/gen/proxy/proxybase.py b/src/gen/proxy/proxybase.py index 1b46a0d1f..e43269c11 100644 --- a/src/gen/proxy/proxybase.py +++ b/src/gen/proxy/proxybase.py @@ -502,11 +502,11 @@ class ProxyDbBase(DbReadBase): return self.gfilter(self.include_tag, self.db.get_tag_from_name(val)) - def get_name_group_mapping(self, name): + def get_name_group_mapping(self, surname): """ Return the default grouping name for a surname """ - return self.db.get_name_group_mapping(name) + return self.db.get_name_group_mapping(surname) def has_name_group_key(self, name): """ diff --git a/src/gui/editors/editname.py b/src/gui/editors/editname.py index 6018faf06..a80cade52 100644 --- a/src/gui/editors/editname.py +++ b/src/gui/editors/editname.py @@ -128,7 +128,7 @@ class EditName(EditSecondary): self.original_group_as = self.obj.get_group_as() self.original_group_set = not (self.original_group_as == '') - srn = self.obj.get_surname() + srn = self.obj.get_primary_surname().get_surname() self._get_global_grouping(srn) self.group_over = self.top.get_object('group_over') @@ -176,7 +176,7 @@ class EditName(EditSecondary): if self.global_group_set : self.group_as.force_value(self.global_group_as) else : - self.group_as.force_value(self.obj.get_surname()) + self.group_as.force_value(self.obj.get_primary_surname().get_surname()) format_list = [(name, number) for (number, name,fmt_str,act) in name_displayer.get_name_format(also_default=True)] @@ -305,7 +305,7 @@ class EditName(EditSecondary): """Callback if surname changes on GUI If overwrite is not set, we change the group name too """ - name = self.obj.get_surname() + name = self.obj.get_primary_surname().get_surname() if not self.group_over.get_active(): self.group_as.force_value(name) #new surname, so perhaps now a different grouping? @@ -338,7 +338,7 @@ class EditName(EditSecondary): if self.global_group_set: self.group_as.set_text(self.global_group_as) else: - surname = self.obj.get_surname() + surname = self.obj.get_primary_surname().get_surname() self.group_as.set_text(surname) def save(self, *obj): @@ -354,7 +354,7 @@ class EditName(EditSecondary): 6/ local set, global set --> set (set to global if possible) """ closeit = True - surname = self.obj.get_surname() + surname = self.obj.get_primary_surname().get_surname() group_as= self.obj.get_group_as() grouping_active = self.group_over.get_active() diff --git a/src/plugins/webreport/NarrativeWeb.py b/src/plugins/webreport/NarrativeWeb.py index 6e0ae4f49..83c888919 100644 --- a/src/plugins/webreport/NarrativeWeb.py +++ b/src/plugins/webreport/NarrativeWeb.py @@ -6799,7 +6799,8 @@ def sort_people(db, handle_list): if primary_name.group_as: surname = primary_name.group_as else: - surname = db.get_name_group_mapping(primary_name.surname) + surname = db.get_name_group_mapping( + primary_name.get_primary_surname().get_surname()) sortnames[person_handle] = _nd.sort_string(primary_name) sname_sub[surname].append(person_handle) @@ -6844,18 +6845,11 @@ def sort_event_types(db, event_types, event_handle_list): # Modified _get_regular_surname from WebCal.py to get prefix, first name, and suffix def _get_short_name(gender, name): - """ Will get prefix and suffix for all people passed through it """ - + """ Will get suffix for all people passed through it """ short_name = name.get_first_name() - prefix = name.get_surname_prefix() - if prefix: - short_name = prefix + " " + short_name - if gender == gen.lib.Person.FEMALE: - return short_name - else: - suffix = name.get_suffix() - if suffix: - short_name = short_name + ", " + suffix + suffix = name.get_suffix() + if suffix: + short_name = short_name + ", " + suffix return short_name def __get_person_keyname(db, handle): diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index f751b3518..33863a29d 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -1616,15 +1616,10 @@ def _get_regular_surname(sex, name): """ Returns a name string built from the components of the Name instance. """ - surname = name.get_surname() - prefix = name.get_surname_prefix() - if prefix: - surname = prefix + " " + surname - if sex is not gen.lib.Person.FEMALE: - suffix = name.get_suffix() - if suffix: - surname = surname + ", " + suffix + suffix = name.get_suffix() + if suffix: + surname = surname + ", " + suffix return surname # Simple utility list to convert Gramps day-of-week numbering