From ed85671df5a553217a62b200136779582068da97 Mon Sep 17 00:00:00 2001 From: Michiel Nauta Date: Thu, 3 Feb 2011 18:35:27 +0000 Subject: [PATCH] Fix typos in mergecode, notebly one missing space. svn: r16556 --- src/Merge/mergeevent.py | 3 +- src/Merge/mergefamily.py | 62 +++++++++++++++++++++------------------- src/Merge/mergeperson.py | 10 +++++-- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/Merge/mergeevent.py b/src/Merge/mergeevent.py index 8992173c5..44ebf7937 100644 --- a/src/Merge/mergeevent.py +++ b/src/Merge/mergeevent.py @@ -210,8 +210,7 @@ class MergeEventQuery(object): self.phoenix.merge(self.titanic) - trans = self.database.transaction_begin(_("Merge Event Objects")) - with self.database.transaction_begin() as trans: + with self.database.transaction_begin(_("Merge Event Objects")) as trans: for person in self.database.iter_people(): if person.has_handle_reference("Event", old_handle): bri = person.birth_ref_index diff --git a/src/Merge/mergefamily.py b/src/Merge/mergefamily.py index f9a78e9cd..025c7d2fc 100644 --- a/src/Merge/mergefamily.py +++ b/src/Merge/mergefamily.py @@ -297,7 +297,8 @@ class MergeFamilyQuery(object): self.database.commit_family(self.titanic, trans) self.database.commit_person(phoenix_person, trans) else: - query = MergePersonQuery(self.database, phoenix_person, titanic_person) + query = MergePersonQuery(self.database, phoenix_person, + titanic_person) query.execute(family_merger=False, trans=trans) def execute(self): @@ -309,34 +310,35 @@ class MergeFamilyQuery(object): with self.database.transaction_begin(_('Merge Family')) as trans: - phoenix_father = self.database.get_person_from_handle(self.phoenix_fh) - titanic_father = self.database.get_person_from_handle(self.titanic_fh) - self.merge_person(phoenix_father, titanic_father, 'father', trans) + phoenix_father = self.database.get_person_from_handle(self.phoenix_fh) + titanic_father = self.database.get_person_from_handle(self.titanic_fh) + self.merge_person(phoenix_father, titanic_father, 'father', trans) - phoenix_mother = self.database.get_person_from_handle(self.phoenix_mh) - titanic_mother = self.database.get_person_from_handle(self.titanic_mh) - self.phoenix = self.database.get_family_from_handle(new_handle) - self.titanic = self.database.get_family_from_handle(old_handle) - self.merge_person(phoenix_mother, titanic_mother, 'mother', trans) + phoenix_mother = self.database.get_person_from_handle(self.phoenix_mh) + titanic_mother = self.database.get_person_from_handle(self.titanic_mh) + self.phoenix = self.database.get_family_from_handle(new_handle) + self.titanic = self.database.get_family_from_handle(old_handle) + self.merge_person(phoenix_mother, titanic_mother, 'mother', trans) - phoenix_father = self.database.get_person_from_handle(self.phoenix_fh) - phoenix_mother = self.database.get_person_from_handle(self.phoenix_mh) - self.phoenix = self.database.get_family_from_handle(new_handle) - self.titanic = self.database.get_family_from_handle(old_handle) - self.phoenix.merge(self.titanic) - for childref in self.titanic.get_child_ref_list(): - child = self.database.get_person_from_handle( - childref.get_reference_handle()) - if new_handle in child.parent_family_list: - child.remove_handle_references('Family', [old_handle]) - else: - child.replace_handle_reference('Family', old_handle, new_handle) - self.database.commit_person(child, trans) - if phoenix_father: - phoenix_father.remove_family_handle(old_handle) - self.database.commit_person(phoenix_father, trans) - if phoenix_mother: - phoenix_mother.remove_family_handle(old_handle) - self.database.commit_person(phoenix_mother, trans) - self.database.remove_family(old_handle, trans) - self.database.commit_family(self.phoenix, trans) + phoenix_father = self.database.get_person_from_handle(self.phoenix_fh) + phoenix_mother = self.database.get_person_from_handle(self.phoenix_mh) + self.phoenix = self.database.get_family_from_handle(new_handle) + self.titanic = self.database.get_family_from_handle(old_handle) + self.phoenix.merge(self.titanic) + for childref in self.titanic.get_child_ref_list(): + child = self.database.get_person_from_handle( + childref.get_reference_handle()) + if new_handle in child.parent_family_list: + child.remove_handle_references('Family', [old_handle]) + else: + child.replace_handle_reference('Family', old_handle, + new_handle) + self.database.commit_person(child, trans) + if phoenix_father: + phoenix_father.remove_family_handle(old_handle) + self.database.commit_person(phoenix_father, trans) + if phoenix_mother: + phoenix_mother.remove_family_handle(old_handle) + self.database.commit_person(phoenix_mother, trans) + self.database.remove_family(old_handle, trans) + self.database.commit_family(self.phoenix, trans) diff --git a/src/Merge/mergeperson.py b/src/Merge/mergeperson.py index 20fe01d8e..332eafc2a 100644 --- a/src/Merge/mergeperson.py +++ b/src/Merge/mergeperson.py @@ -362,6 +362,9 @@ class MergePersonQuery(object): return len(fs1.intersection(fp2)) != 0 or len(fs2.intersection(fp1)) def merge_families(self, main_family_handle, family, trans): + """ + Merge content of family into the family with handle main_family_handle. + """ new_handle = self.phoenix.get_handle() if self.phoenix else None family_handle = family.get_handle() main_family = self.database.get_family_from_handle(main_family_handle) @@ -388,6 +391,9 @@ class MergePersonQuery(object): self.database.commit_family(main_family, trans) def execute(self, family_merger=True, trans=None): + """ + Merges two persons into a single person. + """ if trans is None: with self.database.transaction_begin(_('Merge Person')) as trans: self.__execute(family_merger, trans) @@ -396,14 +402,14 @@ class MergePersonQuery(object): def __execute(self, family_merger, trans): """ - Merges two persons into a single person. + Merges two persons into a single person; trans is compulsory. """ new_handle = self.phoenix.get_handle() old_handle = self.titanic.get_handle() self.phoenix.merge(self.titanic) - for (p_dummy, person_handle) in self.database.find_backlink_handles( + for (dummy, person_handle) in self.database.find_backlink_handles( old_handle, ['Person']): person = self.database.get_person_from_handle(person_handle) assert person.has_handle_reference('Person', old_handle)