2009-09-04 22:50:37 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2004-2006 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2009-12-21 19:13:50 +05:30
|
|
|
# $Id$
|
2009-09-04 22:50:37 +05:30
|
|
|
|
|
|
|
from __future__ import with_statement
|
2010-09-18 03:43:31 +05:30
|
|
|
|
2010-10-23 04:52:33 +05:30
|
|
|
from gen.lib.markertype import MarkerType
|
|
|
|
from gen.lib.tag import Tag
|
|
|
|
import time
|
|
|
|
|
2009-09-09 20:13:55 +05:30
|
|
|
"""
|
2010-09-18 03:43:31 +05:30
|
|
|
methods to upgrade a database from version 13 to current version
|
2009-09-09 20:13:55 +05:30
|
|
|
"""
|
2010-10-02 21:31:34 +05:30
|
|
|
from bsddb import db
|
2010-09-18 03:43:31 +05:30
|
|
|
from gen.db import BSDDBTxn
|
|
|
|
from gen.lib.nameorigintype import NameOriginType
|
2010-10-02 21:31:34 +05:30
|
|
|
from gen.db.write import _mkname, SURNAMES
|
2009-09-04 22:50:37 +05:30
|
|
|
|
2010-08-30 00:06:42 +05:30
|
|
|
def gramps_upgrade_15(self):
|
2010-09-18 03:43:31 +05:30
|
|
|
"""Upgrade database from version 14 to 15. This upgrade adds:
|
|
|
|
* tagging
|
|
|
|
* surname list
|
2010-10-24 20:13:47 +05:30
|
|
|
* remove marker
|
2010-09-18 03:43:31 +05:30
|
|
|
"""
|
2010-10-23 04:52:33 +05:30
|
|
|
length = (len(self.note_map) + len(self.person_map) +
|
|
|
|
len(self.event_map) + len(self.family_map) +
|
|
|
|
len(self.repository_map) + len(self.media_map) +
|
2010-10-24 20:13:47 +05:30
|
|
|
len(self.place_map) + len(self.source_map)) + 10
|
2010-08-30 00:06:42 +05:30
|
|
|
self.set_total(length)
|
2010-10-23 04:52:33 +05:30
|
|
|
self.tags = {}
|
2010-08-30 00:06:42 +05:30
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Person
|
|
|
|
# ---------------------------------
|
2010-10-23 04:52:33 +05:30
|
|
|
# Replace the old marker field with the new tag list field.
|
2010-08-30 00:06:42 +05:30
|
|
|
for handle in self.person_map.keys():
|
|
|
|
person = self.person_map[handle]
|
2010-10-24 20:13:47 +05:30
|
|
|
|
2010-09-18 03:43:31 +05:30
|
|
|
(junk_handle, # 0
|
|
|
|
gramps_id, # 1
|
|
|
|
gender, # 2
|
|
|
|
primary_name, # 3
|
|
|
|
alternate_names, # 4
|
|
|
|
death_ref_index, # 5
|
|
|
|
birth_ref_index, # 6
|
|
|
|
event_ref_list, # 7
|
|
|
|
family_list, # 8
|
|
|
|
parent_family_list, # 9
|
|
|
|
media_list, # 10
|
|
|
|
address_list, # 11
|
|
|
|
attribute_list, # 12
|
|
|
|
urls, # 13
|
|
|
|
ord_list, # 14
|
|
|
|
psource_list, # 15
|
|
|
|
pnote_list, # 16
|
|
|
|
change, # 17
|
|
|
|
marker, # 18
|
|
|
|
pprivate, # 19
|
|
|
|
person_ref_list, # 20
|
|
|
|
) = person
|
|
|
|
|
2010-10-24 20:13:47 +05:30
|
|
|
tag_handle = convert_marker(self, marker)
|
2010-10-23 04:52:33 +05:30
|
|
|
if tag_handle:
|
2010-10-24 20:13:47 +05:30
|
|
|
tags = [tag_handle]
|
2010-10-23 04:52:33 +05:30
|
|
|
else:
|
2010-10-24 20:13:47 +05:30
|
|
|
tags = []
|
2010-10-27 23:43:53 +05:30
|
|
|
address_list = [convert_address(addr) for addr in address_list]
|
2010-09-18 03:43:31 +05:30
|
|
|
new_primary_name = convert_name_15(primary_name)
|
|
|
|
new_alternate_names = [convert_name_15(altname) for altname in
|
|
|
|
alternate_names]
|
|
|
|
new_person = (junk_handle, # 0
|
|
|
|
gramps_id, # 1
|
|
|
|
gender, # 2
|
|
|
|
new_primary_name, # 3
|
|
|
|
new_alternate_names,# 4
|
|
|
|
death_ref_index, # 5
|
|
|
|
birth_ref_index, # 6
|
|
|
|
event_ref_list, # 7
|
|
|
|
family_list, # 8
|
|
|
|
parent_family_list, # 9
|
|
|
|
media_list, # 10
|
|
|
|
address_list, # 11
|
|
|
|
attribute_list, # 12
|
|
|
|
urls, # 13
|
|
|
|
ord_list, # 14
|
|
|
|
psource_list, # 15
|
|
|
|
pnote_list, # 16
|
|
|
|
change, # 17
|
2010-10-24 20:13:47 +05:30
|
|
|
tags, # 18
|
2010-09-18 03:43:31 +05:30
|
|
|
pprivate, # 19
|
2010-10-24 20:13:47 +05:30
|
|
|
person_ref_list # 20
|
2010-09-18 03:43:31 +05:30
|
|
|
)
|
2010-10-24 20:13:47 +05:30
|
|
|
|
2010-08-30 00:06:42 +05:30
|
|
|
with BSDDBTxn(self.env, self.person_map) as txn:
|
2010-08-30 16:06:58 +05:30
|
|
|
txn.put(str(handle), new_person)
|
2010-10-29 01:26:46 +05:30
|
|
|
self.update()
|
2010-10-02 21:31:34 +05:30
|
|
|
#surname is now different, remove secondary index with names
|
|
|
|
_db = db.DB(self.env)
|
|
|
|
try:
|
|
|
|
_db.remove(_mkname(self.full_name, SURNAMES), SURNAMES)
|
|
|
|
except db.DBNoSuchFileError:
|
|
|
|
pass
|
2010-08-30 00:06:42 +05:30
|
|
|
|
2010-10-23 04:52:33 +05:30
|
|
|
# ---------------------------------
|
|
|
|
# Modify Family
|
|
|
|
# ---------------------------------
|
|
|
|
# Replace the old marker field with the new tag list field.
|
|
|
|
for handle in self.family_map.keys():
|
|
|
|
family = self.family_map[handle]
|
|
|
|
new_family = list(family)
|
|
|
|
tag_handle = convert_marker(self, new_family[13])
|
|
|
|
if tag_handle:
|
|
|
|
new_family[13] = [tag_handle]
|
|
|
|
else:
|
|
|
|
new_family[13] = []
|
|
|
|
new_family = tuple(new_family)
|
|
|
|
with BSDDBTxn(self.env, self.family_map) as txn:
|
|
|
|
txn.put(str(handle), new_family)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Note
|
|
|
|
# ---------------------------------
|
|
|
|
# Replace the old marker field with the new tag list field.
|
|
|
|
for handle in self.note_map.keys():
|
|
|
|
note = self.note_map[handle]
|
|
|
|
new_note = list(note)
|
|
|
|
tag_handle = convert_marker(self, new_note[6])
|
|
|
|
if tag_handle:
|
|
|
|
new_note[6] = [tag_handle]
|
|
|
|
else:
|
|
|
|
new_note[6] = []
|
|
|
|
new_note = tuple(new_note)
|
|
|
|
with BSDDBTxn(self.env, self.note_map) as txn:
|
|
|
|
txn.put(str(handle), new_note)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Media object
|
|
|
|
# ---------------------------------
|
|
|
|
# Replace the old marker field with the new tag list field.
|
|
|
|
for handle in self.media_map.keys():
|
|
|
|
media = self.media_map[handle]
|
|
|
|
new_media = list(media)
|
|
|
|
new_media[10] = []
|
|
|
|
new_media = tuple(new_media)
|
|
|
|
with BSDDBTxn(self.env, self.media_map) as txn:
|
|
|
|
txn.put(str(handle), new_media)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Event
|
|
|
|
# ---------------------------------
|
|
|
|
# Replace the old marker field with the new tag list field.
|
|
|
|
for handle in self.event_map.keys():
|
|
|
|
event = self.event_map[handle]
|
|
|
|
new_event = list(event)
|
|
|
|
new_event = new_event[:10] + new_event[11:]
|
|
|
|
#new_event[11] = []
|
|
|
|
new_event = tuple(new_event)
|
|
|
|
with BSDDBTxn(self.env, self.event_map) as txn:
|
|
|
|
txn.put(str(handle), new_event)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Place
|
|
|
|
# ---------------------------------
|
2010-10-29 01:26:46 +05:30
|
|
|
# Remove the old marker field, set new locality.
|
2010-10-23 04:52:33 +05:30
|
|
|
for handle in self.place_map.keys():
|
|
|
|
place = self.place_map[handle]
|
|
|
|
new_place = list(place)
|
2010-10-27 23:43:53 +05:30
|
|
|
new_place[5] = convert_location(new_place[5])
|
|
|
|
new_place[6] = [convert_location(loc) for loc in new_place[6]]
|
2010-10-23 04:52:33 +05:30
|
|
|
new_place = new_place[:11] + new_place[12:]
|
|
|
|
new_place = tuple(new_place)
|
|
|
|
with BSDDBTxn(self.env, self.place_map) as txn:
|
|
|
|
txn.put(str(handle), new_place)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Source
|
|
|
|
# ---------------------------------
|
|
|
|
# Remove the old marker field.
|
|
|
|
for handle in self.source_map.keys():
|
|
|
|
source = self.source_map[handle]
|
|
|
|
new_source = list(source)
|
|
|
|
new_source = new_source[:11] + new_source[12:]
|
|
|
|
new_source = tuple(new_source)
|
|
|
|
with BSDDBTxn(self.env, self.source_map) as txn:
|
|
|
|
txn.put(str(handle), new_source)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Repository
|
|
|
|
# ---------------------------------
|
2010-10-29 01:26:46 +05:30
|
|
|
# Remove the old marker field, set new locality.
|
2010-10-23 04:52:33 +05:30
|
|
|
for handle in self.repository_map.keys():
|
|
|
|
repository = self.repository_map[handle]
|
|
|
|
new_repository = list(repository)
|
|
|
|
new_repository = new_repository[:7] + new_repository[8:]
|
2010-10-29 01:26:46 +05:30
|
|
|
new_repository[5] = [convert_address(addr) for addr in new_repository[5]]
|
2010-10-23 04:52:33 +05:30
|
|
|
new_repository = tuple(new_repository)
|
|
|
|
with BSDDBTxn(self.env, self.repository_map) as txn:
|
|
|
|
txn.put(str(handle), new_repository)
|
|
|
|
self.update()
|
|
|
|
|
2010-08-30 00:06:42 +05:30
|
|
|
# Bump up database version. Separate transaction to save metadata.
|
|
|
|
with BSDDBTxn(self.env, self.metadata) as txn:
|
|
|
|
txn.put('version', 15)
|
|
|
|
|
2010-10-23 04:52:33 +05:30
|
|
|
def convert_marker(self, marker_field):
|
|
|
|
"""Convert a marker into a tag."""
|
|
|
|
marker = MarkerType()
|
|
|
|
marker.unserialize(marker_field)
|
|
|
|
tag_name = str(marker)
|
|
|
|
|
|
|
|
if tag_name != '':
|
|
|
|
if tag_name not in self.tags:
|
|
|
|
tag = Tag()
|
|
|
|
handle = self.create_id()
|
|
|
|
tag.set_handle(handle)
|
|
|
|
tag.set_change_time(time.time())
|
|
|
|
tag.set_name(tag_name)
|
|
|
|
tag.set_priority(len(self.tags))
|
|
|
|
with BSDDBTxn(self.env, self.tag_map) as txn:
|
|
|
|
txn.put(handle, tag.serialize())
|
|
|
|
self.tags[tag_name] = handle
|
|
|
|
return self.tags[tag_name]
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2010-10-27 23:43:53 +05:30
|
|
|
def convert_locbase(loc):
|
|
|
|
"""Convert location base to include an empty locality field."""
|
|
|
|
return tuple([loc[0], u''] + list(loc[1:]))
|
|
|
|
|
|
|
|
def convert_location(loc):
|
|
|
|
"""Convert a location into the new format."""
|
|
|
|
return (convert_locbase(loc[0]), loc[1])
|
|
|
|
|
|
|
|
def convert_address(addr):
|
|
|
|
"""Convert an address into the new format."""
|
|
|
|
return (addr[0], addr[1], addr[2], addr[3], convert_locbase(addr[4]))
|
|
|
|
|
2010-09-18 03:43:31 +05:30
|
|
|
def convert_name_15(name):
|
|
|
|
(privacy, source_list, note_list, date,
|
|
|
|
first_name, surname, suffix, title,
|
|
|
|
name_type, prefix, patronymic,
|
|
|
|
group_as, sort_as, display_as, call) = name
|
|
|
|
|
|
|
|
connector = u""
|
|
|
|
origintype = (NameOriginType.NONE, u"")
|
|
|
|
patorigintype = (NameOriginType.PATRONYMIC, u"")
|
|
|
|
|
|
|
|
if patronymic.strip() == u"":
|
|
|
|
#no patronymic, create a single surname
|
|
|
|
surname_list = [(surname, prefix, True, origintype, connector)]
|
|
|
|
else:
|
|
|
|
#a patronymic, if no surname or equal as patronymic, a single surname
|
|
|
|
if (surname.strip() == u"") or (surname == patronymic and prefix == u""):
|
|
|
|
surname_list = [(patronymic, prefix, True, patorigintype, connector)]
|
|
|
|
else:
|
|
|
|
#two surnames, first patronymic, then surname which is primary
|
|
|
|
surname_list = [(patronymic, u"", False, patorigintype, u""),
|
|
|
|
(surname, prefix, True, origintype, connector)]
|
|
|
|
|
2010-09-25 20:41:54 +05:30
|
|
|
#return new value, add two empty strings for nick and family nick
|
2010-09-18 03:43:31 +05:30
|
|
|
return (privacy, source_list, note_list, date,
|
|
|
|
first_name, surname_list, suffix, title, name_type,
|
2010-09-25 20:41:54 +05:30
|
|
|
group_as, sort_as, display_as, call, u"", u"")
|
2010-09-18 03:43:31 +05:30
|
|
|
|
2009-08-19 22:35:39 +05:30
|
|
|
def gramps_upgrade_14(self):
|
|
|
|
"""Upgrade database from version 13 to 14."""
|
|
|
|
# This upgrade modifies notes and dates
|
|
|
|
length = (len(self.note_map) + len(self.person_map) +
|
|
|
|
len(self.event_map) + len(self.family_map) +
|
|
|
|
len(self.repository_map) + len(self.media_map) +
|
|
|
|
len(self.place_map) + len(self.source_map))
|
|
|
|
self.set_total(length)
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Notes
|
|
|
|
# ---------------------------------
|
|
|
|
# replace clear text with StyledText in Notes
|
|
|
|
for handle in self.note_map.keys():
|
|
|
|
note = self.note_map[handle]
|
|
|
|
(junk_handle, gramps_id, text, format, note_type,
|
|
|
|
change, marker, private) = note
|
|
|
|
styled_text = (text, [])
|
|
|
|
new_note = (handle, gramps_id, styled_text, format, note_type,
|
|
|
|
change, marker, private)
|
|
|
|
with BSDDBTxn(self.env, self.note_map) as txn:
|
|
|
|
txn.put(str(handle), new_note)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Event
|
|
|
|
# ---------------------------------
|
|
|
|
# update dates with newyear
|
|
|
|
for handle in self.event_map.keys():
|
|
|
|
event = self.event_map[handle]
|
|
|
|
(junk_handle, gramps_id, the_type, date, description, place,
|
|
|
|
source_list, note_list, media_list, attribute_list,
|
|
|
|
change, marker, private) = event
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
new_media_list = new_media_list_14(media_list)
|
|
|
|
new_attribute_list = new_attribute_list_14(attribute_list)
|
|
|
|
new_event = (junk_handle, gramps_id, the_type, new_date,
|
|
|
|
description, place, new_source_list, note_list,
|
|
|
|
new_media_list, new_attribute_list, change,marker,private)
|
|
|
|
with BSDDBTxn(self.env, self.event_map) as txn:
|
|
|
|
txn.put(str(handle), new_event)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Person
|
|
|
|
# ---------------------------------
|
|
|
|
# update dates with newyear
|
|
|
|
for handle in self.person_map.keys():
|
|
|
|
person = self.person_map[handle]
|
|
|
|
(junk_handle, # 0
|
|
|
|
gramps_id, # 1
|
|
|
|
gender, # 2
|
|
|
|
primary_name, # 3
|
|
|
|
alternate_names, # 4
|
|
|
|
death_ref_index, # 5
|
|
|
|
birth_ref_index, # 6
|
|
|
|
event_ref_list, # 7
|
|
|
|
family_list, # 8
|
|
|
|
parent_family_list, # 9
|
|
|
|
media_list, # 10
|
|
|
|
address_list, # 11
|
|
|
|
attribute_list, # 12
|
|
|
|
urls, # 13
|
|
|
|
lds_ord_list, # 14
|
|
|
|
psource_list, # 15
|
|
|
|
pnote_list, # 16
|
|
|
|
change, # 17
|
|
|
|
marker, # 18
|
|
|
|
pprivate, # 19
|
|
|
|
person_ref_list, # 20
|
|
|
|
) = person
|
|
|
|
|
|
|
|
new_address_list = []
|
|
|
|
for address in address_list:
|
|
|
|
(privacy, asource_list, anote_list, date, location) = address
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_asource_list = new_source_list_14(asource_list)
|
|
|
|
new_address_list.append((privacy, new_asource_list, anote_list,
|
|
|
|
new_date, location))
|
|
|
|
new_ord_list = []
|
|
|
|
for ldsord in lds_ord_list:
|
|
|
|
(lsource_list, lnote_list, date, type, place,
|
|
|
|
famc, temple, status, lprivate) = ldsord
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_lsource_list = new_source_list_14(lsource_list)
|
|
|
|
new_ord_list.append( (new_lsource_list, lnote_list, new_date, type,
|
|
|
|
place, famc, temple, status, lprivate))
|
|
|
|
|
|
|
|
new_primary_name = convert_name_14(primary_name)
|
|
|
|
|
|
|
|
new_alternate_names = [convert_name_14(name) for name
|
|
|
|
in alternate_names]
|
|
|
|
|
|
|
|
new_media_list = new_media_list_14(media_list)
|
|
|
|
new_psource_list = new_source_list_14(psource_list)
|
|
|
|
new_attribute_list = new_attribute_list_14(attribute_list)
|
|
|
|
new_person_ref_list = new_person_ref_list_14(person_ref_list)
|
|
|
|
|
|
|
|
new_person = (junk_handle, # 0
|
|
|
|
gramps_id, # 1
|
|
|
|
gender, # 2
|
|
|
|
new_primary_name, # 3
|
|
|
|
new_alternate_names, # 4
|
|
|
|
death_ref_index, # 5
|
|
|
|
birth_ref_index, # 6
|
|
|
|
event_ref_list, # 7
|
|
|
|
family_list, # 8
|
|
|
|
parent_family_list, # 9
|
|
|
|
new_media_list, # 10
|
|
|
|
new_address_list, # 11
|
|
|
|
new_attribute_list, # 12
|
|
|
|
urls, # 13
|
|
|
|
new_ord_list, # 14
|
|
|
|
new_psource_list, # 15
|
|
|
|
pnote_list, # 16
|
|
|
|
change, # 17
|
|
|
|
marker, # 18
|
|
|
|
pprivate, # 19
|
|
|
|
new_person_ref_list, # 20
|
|
|
|
)
|
|
|
|
|
|
|
|
with BSDDBTxn(self.env, self.person_map) as txn:
|
|
|
|
txn.put(str(handle), new_person)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Family
|
|
|
|
# ---------------------------------
|
|
|
|
# update dates with newyear
|
|
|
|
for handle in self.family_map.keys():
|
|
|
|
family = self.family_map[handle]
|
|
|
|
(junk_handle, gramps_id, father_handle, mother_handle,
|
|
|
|
child_ref_list, the_type, event_ref_list, media_list,
|
|
|
|
attribute_list, lds_seal_list, source_list, note_list,
|
|
|
|
change, marker, private) = family
|
|
|
|
new_child_ref_list = new_child_ref_list_14(child_ref_list)
|
|
|
|
new_media_list = new_media_list_14(media_list)
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
new_attribute_list = new_attribute_list_14(attribute_list)
|
|
|
|
new_seal_list = []
|
|
|
|
for ldsord in lds_seal_list:
|
|
|
|
(lsource_list, lnote_list, date, type, place,
|
|
|
|
famc, temple, status, lprivate) = ldsord
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_lsource_list = new_source_list_14(lsource_list)
|
|
|
|
new_seal_list.append( (new_lsource_list, lnote_list, new_date, type,
|
|
|
|
place, famc, temple, status, lprivate))
|
|
|
|
|
|
|
|
new_family = (junk_handle, gramps_id, father_handle, mother_handle,
|
|
|
|
new_child_ref_list, the_type, event_ref_list, new_media_list,
|
|
|
|
new_attribute_list, new_seal_list, new_source_list, note_list,
|
|
|
|
change, marker, private)
|
|
|
|
|
|
|
|
with BSDDBTxn(self.env, self.family_map) as txn:
|
|
|
|
txn.put(str(handle), new_family)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Repository
|
|
|
|
# ---------------------------------
|
|
|
|
# update dates with newyear
|
|
|
|
for handle in self.repository_map.keys():
|
|
|
|
repository = self.repository_map[handle]
|
|
|
|
# address
|
|
|
|
(junk_handle, gramps_id, the_type, name, note_list,
|
|
|
|
address_list, urls, change, marker, private) = repository
|
|
|
|
|
|
|
|
new_address_list = []
|
|
|
|
for address in address_list:
|
|
|
|
(privacy, asource_list, anote_list, date, location) = address
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_asource_list = new_source_list_14(asource_list)
|
|
|
|
new_address_list.append((privacy, new_asource_list, anote_list,
|
|
|
|
new_date, location))
|
|
|
|
|
|
|
|
new_repository = (junk_handle, gramps_id, the_type, name, note_list,
|
|
|
|
new_address_list, urls, change, marker, private)
|
|
|
|
|
|
|
|
with BSDDBTxn(self.env, self.repository_map) as txn:
|
|
|
|
txn.put(str(handle), new_repository)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Media
|
|
|
|
# ---------------------------------
|
|
|
|
for media_handle in self.media_map.keys():
|
|
|
|
media = self.media_map[media_handle]
|
|
|
|
(handle, gramps_id, path, mime, desc,
|
|
|
|
attribute_list, source_list, note_list, change,
|
|
|
|
date, marker, private) = media
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_media = (handle, gramps_id, path, mime, desc,
|
|
|
|
attribute_list, new_source_list, note_list, change,
|
|
|
|
new_date, marker, private)
|
|
|
|
|
|
|
|
with BSDDBTxn(self.env, self.media_map) as txn:
|
|
|
|
txn.put(str(handle), new_media)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Place
|
|
|
|
# ---------------------------------
|
|
|
|
for place_handle in self.place_map.keys():
|
|
|
|
place = self.place_map[place_handle]
|
|
|
|
(handle, gramps_id, title, long, lat,
|
|
|
|
main_loc, alt_loc, urls, media_list, source_list, note_list,
|
|
|
|
change, marker, private) = place
|
|
|
|
new_media_list = new_media_list_14(media_list)
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
new_place = (handle, gramps_id, title, long, lat,
|
|
|
|
main_loc, alt_loc, urls, new_media_list,
|
|
|
|
new_source_list, note_list, change, marker, private)
|
|
|
|
|
|
|
|
with BSDDBTxn(self.env, self.place_map) as txn:
|
|
|
|
txn.put(str(handle), new_place)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# ---------------------------------
|
|
|
|
# Modify Source
|
|
|
|
# ---------------------------------
|
|
|
|
for source_handle in self.source_map.keys():
|
|
|
|
source = self.source_map[source_handle]
|
|
|
|
(handle, gramps_id, title, author,
|
|
|
|
pubinfo, note_list, media_list,
|
|
|
|
abbrev, change, datamap, reporef_list,
|
|
|
|
marker, private) = source
|
|
|
|
new_media_list = new_media_list_14(media_list)
|
|
|
|
new_source = (handle, gramps_id, title, author,
|
|
|
|
pubinfo, note_list, new_media_list,
|
|
|
|
abbrev, change, datamap, reporef_list,
|
|
|
|
marker, private)
|
|
|
|
|
|
|
|
with BSDDBTxn(self.env, self.source_map) as txn:
|
|
|
|
txn.put(str(handle), new_source)
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
# Bump up database version. Separate transaction to save metadata.
|
|
|
|
with BSDDBTxn(self.env, self.metadata) as txn:
|
|
|
|
txn.put('version', 14)
|
|
|
|
|
|
|
|
def new_source_list_14(source_list):
|
|
|
|
new_source_list = []
|
|
|
|
for source in source_list:
|
|
|
|
(date, private, note_list, confidence, ref, page) = source
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_source_list.append((new_date, private, note_list, confidence, ref, page))
|
|
|
|
return new_source_list
|
|
|
|
|
|
|
|
def new_attribute_list_14(attribute_list):
|
|
|
|
new_attribute_list = []
|
|
|
|
for attribute in attribute_list:
|
|
|
|
(private, asource_list, note_list, the_type, value) = attribute
|
|
|
|
new_asource_list = new_source_list_14(asource_list)
|
|
|
|
new_attribute_list.append((private, new_asource_list, note_list, the_type, value))
|
|
|
|
return new_attribute_list
|
|
|
|
|
|
|
|
def new_media_list_14(media_list):
|
|
|
|
# ---------------------------------
|
|
|
|
# Event Media list
|
|
|
|
# ---------------------------------
|
|
|
|
new_media_list = []
|
|
|
|
for media in media_list:
|
|
|
|
(private, source_list, note_list,attribute_list,ref,role) = media
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
new_attribute_list = new_attribute_list_14(attribute_list)
|
|
|
|
new_media_list.append((private, new_source_list, note_list, new_attribute_list, ref, role))
|
|
|
|
return new_media_list
|
|
|
|
|
|
|
|
def new_person_ref_list_14(person_ref_list):
|
|
|
|
new_person_ref_list = []
|
|
|
|
for person_ref in person_ref_list:
|
|
|
|
(private, source_list, note_list, ref, rel) = person_ref
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
new_person_ref_list.append((private, new_source_list, note_list, ref, rel))
|
|
|
|
return new_person_ref_list
|
|
|
|
|
|
|
|
def new_child_ref_list_14(child_ref_list):
|
|
|
|
new_child_ref_list = []
|
|
|
|
for data in child_ref_list:
|
|
|
|
(private, source_list, note_list, ref, frel, mrel) = data
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
new_child_ref_list.append((private, new_source_list, note_list, ref, frel, mrel))
|
|
|
|
return new_child_ref_list
|
|
|
|
|
|
|
|
def convert_date_14(date):
|
|
|
|
if date:
|
|
|
|
(calendar, modifier, quality, dateval, text, sortval) = date
|
|
|
|
return (calendar, modifier, quality, dateval, text, sortval, 0)
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def convert_name_14(name):
|
|
|
|
(privacy, source_list, note_list, date,
|
|
|
|
first_name, surname, suffix, title,
|
|
|
|
name_type, prefix, patronymic,
|
|
|
|
group_as, sort_as, display_as, call) = name
|
|
|
|
new_date = convert_date_14(date)
|
|
|
|
new_source_list = new_source_list_14(source_list)
|
|
|
|
return (privacy, new_source_list, note_list, new_date,
|
|
|
|
first_name, surname, suffix, title,
|
|
|
|
name_type, prefix, patronymic,
|
|
|
|
group_as, sort_as, display_as, call)
|
2010-10-23 04:52:33 +05:30
|
|
|
|