2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2009-06-21 01:53:40 +05:30
|
|
|
# Copyright (C) 2008-2009 Gary Burton
|
2008-09-04 17:16:43 +05:30
|
|
|
# Copyright (C) 2008 Robert Cheramy <robert@cheramy.net>
|
2010-05-01 09:42:42 +05:30
|
|
|
# Copyright (C) 2010 Jakim Friant
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2007-08-06 09:41:52 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2002-10-20 19:55:16 +05:30
|
|
|
# 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
|
|
|
|
#
|
2003-12-02 08:05:49 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"Export to GEDCOM"
|
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard Python Modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
import os
|
|
|
|
import time
|
2006-03-21 11:53:45 +05:30
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2002-12-30 06:12:47 +05:30
|
|
|
import const
|
2009-12-30 00:50:16 +05:30
|
|
|
import libgedcom
|
2003-06-18 08:20:30 +05:30
|
|
|
import Errors
|
2009-12-05 12:05:21 +05:30
|
|
|
from ExportOptions import WriterOptionBox
|
2010-01-11 01:51:10 +05:30
|
|
|
from gen.updatecallback import UpdateCallback
|
2010-04-19 19:23:43 +05:30
|
|
|
from Utils import media_path_full, get_unicode_path
|
2010-03-23 04:05:53 +05:30
|
|
|
from PlaceUtils import conv_lat_lon
|
2007-02-03 22:41:05 +05:30
|
|
|
|
2006-03-21 11:53:45 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GEDCOM tags representing attributes that may take a parameter, value or
|
|
|
|
# description on the same line as the tag
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-09-06 10:06:04 +05:30
|
|
|
NEEDS_PARAMETER = set(
|
2007-08-22 09:17:51 +05:30
|
|
|
["CAST", "DSCR", "EDUC", "IDNO", "NATI", "NCHI",
|
|
|
|
"NMR", "OCCU", "PROP", "RELI", "SSN", "TITL"])
|
2006-03-21 11:53:45 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
LDS_ORD_NAME = {
|
2007-10-08 22:11:39 +05:30
|
|
|
gen.lib.LdsOrd.BAPTISM : 'BAPL',
|
|
|
|
gen.lib.LdsOrd.ENDOWMENT : 'ENDL',
|
|
|
|
gen.lib.LdsOrd.SEAL_TO_PARENTS : 'SLGC',
|
2007-11-12 13:52:04 +05:30
|
|
|
gen.lib.LdsOrd.SEAL_TO_SPOUSE : 'SLGS',
|
2007-10-08 22:11:39 +05:30
|
|
|
gen.lib.LdsOrd.CONFIRMATION : 'CONL',
|
2006-04-06 07:12:14 +05:30
|
|
|
}
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
LDS_STATUS = {
|
2007-10-08 22:11:39 +05:30
|
|
|
gen.lib.LdsOrd.STATUS_BIC : "BIC",
|
|
|
|
gen.lib.LdsOrd.STATUS_CANCELED : "CANCELED",
|
|
|
|
gen.lib.LdsOrd.STATUS_CHILD : "CHILD",
|
|
|
|
gen.lib.LdsOrd.STATUS_CLEARED : "CLEARED",
|
|
|
|
gen.lib.LdsOrd.STATUS_COMPLETED : "COMPLETED",
|
|
|
|
gen.lib.LdsOrd.STATUS_DNS : "DNS",
|
|
|
|
gen.lib.LdsOrd.STATUS_INFANT : "INFANT",
|
|
|
|
gen.lib.LdsOrd.STATUS_PRE_1970 : "PRE-1970",
|
|
|
|
gen.lib.LdsOrd.STATUS_QUALIFIED : "QUALIFIED",
|
|
|
|
gen.lib.LdsOrd.STATUS_DNS_CAN : "DNS/CAN",
|
|
|
|
gen.lib.LdsOrd.STATUS_STILLBORN : "STILLBORN",
|
|
|
|
gen.lib.LdsOrd.STATUS_SUBMITTED : "SUBMITTED" ,
|
|
|
|
gen.lib.LdsOrd.STATUS_UNCLEARED : "UNCLEARED",
|
2006-04-06 07:12:14 +05:30
|
|
|
}
|
|
|
|
|
2007-08-13 09:10:36 +05:30
|
|
|
LANGUAGES = {
|
|
|
|
'cs' : 'Czech', 'da' : 'Danish', 'nl' : 'Dutch',
|
|
|
|
'en' : 'English', 'eo' : 'Esperanto', 'fi' : 'Finnish',
|
|
|
|
'fr' : 'French', 'de' : 'German', 'hu' : 'Hungarian',
|
|
|
|
'it' : 'Italian', 'lt' : 'Latvian', 'lv' : 'Lithuanian',
|
|
|
|
'no' : 'Norwegian', 'po' : 'Polish', 'pt' : 'Portuguese',
|
|
|
|
'ro' : 'Romanian', 'sk' : 'Slovak', 'es' : 'Spanish',
|
|
|
|
'sv' : 'Swedish', 'ru' : 'Russian',
|
|
|
|
}
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
MIME2GED = {
|
2007-08-06 09:41:52 +05:30
|
|
|
"image/bmp" : "bmp",
|
|
|
|
"image/gif" : "gif",
|
|
|
|
"image/jpeg" : "jpeg",
|
|
|
|
"image/x-pcx" : "pcx",
|
|
|
|
"image/tiff" : "tiff",
|
2006-05-23 05:26:57 +05:30
|
|
|
"audio/x-wav" : "wav"
|
|
|
|
}
|
2006-06-17 00:08:06 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
QUALITY_MAP = {
|
2007-10-08 22:11:39 +05:30
|
|
|
gen.lib.SourceRef.CONF_VERY_HIGH : "3",
|
|
|
|
gen.lib.SourceRef.CONF_HIGH : "2",
|
|
|
|
gen.lib.SourceRef.CONF_LOW : "1",
|
|
|
|
gen.lib.SourceRef.CONF_VERY_LOW : "0",
|
2007-08-25 10:33:23 +05:30
|
|
|
}
|
2006-06-17 00:08:06 +05:30
|
|
|
|
2004-07-12 05:23:02 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2007-09-06 10:06:04 +05:30
|
|
|
# sort_by_gramps_id
|
2004-07-12 05:23:02 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-08-06 09:41:52 +05:30
|
|
|
def sort_by_gramps_id(first, second):
|
2007-09-06 10:06:04 +05:30
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Sort objects by their Gramps ID.
|
2007-09-06 10:06:04 +05:30
|
|
|
"""
|
2007-08-13 05:30:16 +05:30
|
|
|
return cmp(first.gramps_id, second.gramps_id)
|
2004-07-12 05:23:02 +05:30
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# sort_handles_by_id
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-09-07 05:08:38 +05:30
|
|
|
def sort_handles_by_id(handle_list, handle_to_object):
|
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Sort a list of handles by the Gramps ID.
|
2008-02-18 21:22:40 +05:30
|
|
|
|
|
|
|
The function that returns the object from the handle needs to be supplied
|
|
|
|
so that we get the right object.
|
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
sorted_list = []
|
|
|
|
for handle in handle_list:
|
|
|
|
obj = handle_to_object(handle)
|
2010-05-30 17:39:17 +05:30
|
|
|
if obj:
|
|
|
|
data = (obj.get_gramps_id(), handle)
|
|
|
|
sorted_list.append (data)
|
2007-09-07 05:08:38 +05:30
|
|
|
sorted_list.sort()
|
|
|
|
return sorted_list
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2007-09-06 10:06:04 +05:30
|
|
|
# breakup
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-08-08 09:54:49 +05:30
|
|
|
def breakup(txt, limit):
|
2007-08-14 09:32:18 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Break a line of text into a list of strings that conform to the
|
2007-08-14 09:32:18 +05:30
|
|
|
maximum length specified, while breaking words in the middle of a word
|
|
|
|
to avoid issues with spaces.
|
|
|
|
"""
|
2008-04-05 10:04:46 +05:30
|
|
|
if limit < 1:
|
|
|
|
raise ValueError("breakup: unexpected limit: %r" % limit)
|
2007-08-08 09:54:49 +05:30
|
|
|
data = []
|
2008-04-05 10:04:46 +05:30
|
|
|
while len(txt) > limit:
|
|
|
|
# look for non-space pair to break between
|
2008-07-15 00:26:39 +05:30
|
|
|
# do not break within a UTF-8 byte sequence, i. e. first char >127
|
2008-04-05 10:04:46 +05:30
|
|
|
idx = limit
|
2008-07-15 00:26:39 +05:30
|
|
|
while (idx>0 and (txt[idx-1].isspace() or txt[idx].isspace()
|
|
|
|
or ord(txt[idx-1]) > 127)):
|
2007-08-08 09:54:49 +05:30
|
|
|
idx -= 1
|
2008-04-05 10:04:46 +05:30
|
|
|
if idx == 0:
|
|
|
|
#no words to break on, just break at limit anyway
|
|
|
|
idx = limit
|
2007-08-20 08:45:13 +05:30
|
|
|
data.append(txt[:idx])
|
|
|
|
txt = txt[idx:]
|
2007-08-08 09:54:49 +05:30
|
|
|
if len(txt) > 0:
|
|
|
|
data.append(txt)
|
|
|
|
return data
|
|
|
|
|
2008-03-07 12:58:15 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# event_has_subordinate_data
|
|
|
|
# may want to compare description w/ auto-generated one, and
|
|
|
|
# if so, treat it same as if it were empty for this purpose
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def event_has_subordinate_data(event, event_ref):
|
2010-05-02 00:21:31 +05:30
|
|
|
if event and event_ref:
|
|
|
|
return (event.get_description().strip() or
|
|
|
|
not event.get_date_object().is_empty() or
|
|
|
|
event.get_place_handle() or
|
|
|
|
event.get_attribute_list() or
|
|
|
|
event_ref.get_attribute_list() or
|
|
|
|
event.get_note_list() or
|
|
|
|
event.get_source_references() or
|
|
|
|
event.get_media_list())
|
|
|
|
else:
|
|
|
|
return False
|
2008-03-07 12:58:15 +05:30
|
|
|
|
|
|
|
|
2006-05-21 09:44:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GedcomWriter class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-01-11 01:51:10 +05:30
|
|
|
class GedcomWriter(UpdateCallback):
|
2007-09-06 10:06:04 +05:30
|
|
|
"""
|
|
|
|
The GEDCOM writer creates a GEDCOM file that contains the exported
|
2010-01-11 01:51:10 +05:30
|
|
|
information from the database. It derives from UpdateCallback
|
2007-09-06 10:06:04 +05:30
|
|
|
so that it can provide visual feedback via a progress bar if needed.
|
|
|
|
"""
|
2006-05-16 09:17:58 +05:30
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
def __init__(self, database, cmd_line=0,
|
2007-09-06 10:06:04 +05:30
|
|
|
option_box=None, callback=None):
|
2010-01-11 01:51:10 +05:30
|
|
|
UpdateCallback.__init__(self, callback)
|
2007-09-06 10:06:04 +05:30
|
|
|
|
|
|
|
self.dbase = database
|
|
|
|
self.cmd_line = cmd_line
|
|
|
|
self.dirname = None
|
|
|
|
self.gedcom_file = None
|
2008-07-21 00:03:04 +05:30
|
|
|
|
|
|
|
# The number of different stages other than any of the optional filters
|
|
|
|
# which the write_gedcom_file method will call.
|
|
|
|
self.progress_cnt = 5
|
2004-07-11 11:33:07 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.setup(option_box)
|
|
|
|
|
|
|
|
def setup(self, option_box):
|
|
|
|
"""
|
|
|
|
If the option_box is present (GUI interface), then we check the
|
|
|
|
"private", "restrict", and "cfilter" arguments to see if we need
|
|
|
|
to apply proxy databases.
|
|
|
|
"""
|
2006-05-23 05:26:57 +05:30
|
|
|
if option_box:
|
2007-09-06 10:06:04 +05:30
|
|
|
option_box.parse_options()
|
2010-05-30 09:37:50 +05:30
|
|
|
self.dbase = option_box.get_filtered_database(self.dbase, self)
|
2008-07-08 01:02:18 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def write_gedcom_file(self, filename):
|
|
|
|
"""
|
2009-08-09 22:39:32 +05:30
|
|
|
Write the actual GEDCOM file to the specified filename.
|
2007-09-06 10:06:04 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
self.dirname = os.path.dirname (filename)
|
|
|
|
self.gedcom_file = open(filename, "w")
|
|
|
|
self.__header(filename)
|
|
|
|
self.__submitter()
|
|
|
|
self.__individuals()
|
|
|
|
self.__families()
|
|
|
|
self.__sources()
|
|
|
|
self.__repos()
|
|
|
|
self.__notes()
|
|
|
|
|
|
|
|
self.__writeln(0, "TRLR")
|
|
|
|
self.gedcom_file.close()
|
2008-01-15 14:46:45 +05:30
|
|
|
return True
|
2006-05-23 05:26:57 +05:30
|
|
|
|
2007-08-09 10:05:06 +05:30
|
|
|
def __writeln(self, level, token, textlines="", limit=72):
|
2007-09-06 10:06:04 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write a line of text to the output file in the form of:
|
2007-09-06 10:06:04 +05:30
|
|
|
|
2008-02-18 21:22:40 +05:30
|
|
|
LEVEL TOKEN text
|
2007-09-06 10:06:04 +05:30
|
|
|
|
|
|
|
If the line contains newlines, it is broken into multiple lines using
|
|
|
|
the CONT token. If any line is greater than the limit, it will broken
|
|
|
|
into multiple lines using CONC.
|
2008-02-18 21:22:40 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
"""
|
2007-08-29 09:47:20 +05:30
|
|
|
assert(token)
|
2007-08-09 10:05:06 +05:30
|
|
|
if textlines:
|
2007-09-06 10:06:04 +05:30
|
|
|
# break the line into multiple lines if a newline is found
|
2007-08-09 10:05:06 +05:30
|
|
|
textlist = textlines.split('\n')
|
|
|
|
token_level = level
|
|
|
|
for text in textlist:
|
2010-04-19 19:23:43 +05:30
|
|
|
# make it unicode so that breakup below does the right thin.
|
|
|
|
text = get_unicode_path(text)
|
2007-08-09 10:05:06 +05:30
|
|
|
if limit:
|
|
|
|
prefix = "\n%d CONC " % (level + 1)
|
2007-08-10 09:23:48 +05:30
|
|
|
txt = prefix.join(breakup(text, limit))
|
2007-08-09 10:05:06 +05:30
|
|
|
else:
|
2007-08-10 09:23:48 +05:30
|
|
|
txt = text
|
2007-09-06 10:06:04 +05:30
|
|
|
self.gedcom_file.write("%d %s %s\n" % (token_level, token, txt))
|
|
|
|
token_level = level + 1
|
2007-08-09 10:05:06 +05:30
|
|
|
token = "CONT"
|
2007-08-06 09:41:52 +05:30
|
|
|
else:
|
2007-09-06 10:06:04 +05:30
|
|
|
self.gedcom_file.write("%d %s\n" % (level, token))
|
2004-07-11 11:33:07 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __header(self, filename):
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write the GEDCOM header.
|
|
|
|
|
|
|
|
HEADER:=
|
|
|
|
n HEAD {1:1}
|
|
|
|
+1 SOUR <APPROVED_SYSTEM_ID> {1:1}
|
|
|
|
+2 VERS <VERSION_NUMBER> {0:1}
|
|
|
|
+2 NAME <NAME_OF_PRODUCT> {0:1}
|
|
|
|
+2 CORP <NAME_OF_BUSINESS> {0:1} # Not used
|
|
|
|
+3 <<ADDRESS_STRUCTURE>> {0:1} # Not used
|
|
|
|
+2 DATA <NAME_OF_SOURCE_DATA> {0:1} # Not used
|
|
|
|
+3 DATE <PUBLICATION_DATE> {0:1} # Not used
|
|
|
|
+3 COPR <COPYRIGHT_SOURCE_DATA> {0:1} # Not used
|
|
|
|
+1 DEST <RECEIVING_SYSTEM_NAME> {0:1*} # Not used
|
|
|
|
+1 DATE <TRANSMISSION_DATE> {0:1}
|
|
|
|
+2 TIME <TIME_VALUE> {0:1}
|
|
|
|
+1 SUBM @XREF:SUBM@ {1:1}
|
|
|
|
+1 SUBN @XREF:SUBN@ {0:1}
|
|
|
|
+1 FILE <FILE_NAME> {0:1}
|
|
|
|
+1 COPR <COPYRIGHT_GEDCOM_FILE> {0:1}
|
|
|
|
+1 GEDC {1:1}
|
|
|
|
+2 VERS <VERSION_NUMBER> {1:1}
|
|
|
|
+2 FORM <GEDCOM_FORM> {1:1}
|
|
|
|
+1 CHAR <CHARACTER_SET> {1:1}
|
|
|
|
+2 VERS <VERSION_NUMBER> {0:1}
|
|
|
|
+1 LANG <LANGUAGE_OF_TEXT> {0:1}
|
|
|
|
+1 PLAC {0:1}
|
|
|
|
+2 FORM <PLACE_HIERARCHY> {1:1}
|
|
|
|
+1 NOTE <GEDCOM_CONTENT_DESCRIPTION> {0:1}
|
|
|
|
+2 [CONT|CONC] <GEDCOM_CONTENT_DESCRIPTION> {0:M}
|
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2007-09-06 10:06:04 +05:30
|
|
|
local_time = time.localtime(time.time())
|
|
|
|
(year, mon, day, hour, minutes, sec) = local_time[0:6]
|
2010-01-25 10:24:22 +05:30
|
|
|
date_str = "%d %s %d" % (day, libgedcom.MONTH[mon], year)
|
2007-09-06 10:06:04 +05:30
|
|
|
time_str = "%02d:%02d:%02d" % (hour, minutes, sec)
|
|
|
|
rname = self.dbase.get_researcher().get_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(0, "HEAD")
|
2009-11-19 23:02:11 +05:30
|
|
|
self.__writeln(1, "SOUR", "Gramps")
|
2007-09-08 11:24:02 +05:30
|
|
|
self.__writeln(2, "VERS", const.VERSION)
|
2009-11-19 23:02:11 +05:30
|
|
|
self.__writeln(2, "NAME", "Gramps")
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(1, "DATE", date_str)
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(2, "TIME", time_str)
|
|
|
|
self.__writeln(1, "SUBM", "@SUBM@")
|
2010-05-09 19:24:50 +05:30
|
|
|
self.__writeln(1, "FILE", filename, limit=255)
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(1, "COPR", 'Copyright (c) %d %s.' % (year, rname))
|
|
|
|
self.__writeln(1, "GEDC")
|
|
|
|
self.__writeln(2, "VERS", "5.5")
|
|
|
|
self.__writeln(2, "FORM", 'LINEAGE-LINKED')
|
2007-08-10 09:23:48 +05:30
|
|
|
self.__writeln(1, "CHAR", "UTF-8")
|
2007-08-13 09:10:36 +05:30
|
|
|
|
2007-08-14 09:32:18 +05:30
|
|
|
# write the language string if the current LANG variable
|
|
|
|
# matches something we know about.
|
|
|
|
|
2007-08-13 09:10:36 +05:30
|
|
|
lang = os.getenv('LANG')
|
|
|
|
if lang and len(lang) >= 2:
|
|
|
|
lang_code = LANGUAGES.get(lang[0:2])
|
|
|
|
if lang_code:
|
|
|
|
self.__writeln(1, 'LANG', lang_code)
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __submitter(self):
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n @<XREF:SUBM>@ SUBM {1:1}
|
|
|
|
+1 NAME <SUBMITTER_NAME> {1:1}
|
|
|
|
+1 <<ADDRESS_STRUCTURE>> {0:1}
|
|
|
|
+1 <<MULTIMEDIA_LINK>> {0:M} # not used
|
|
|
|
+1 LANG <LANGUAGE_PREFERENCE> {0:3} # not used
|
|
|
|
+1 RFN <SUBMITTER_REGISTERED_RFN> {0:1} # not used
|
|
|
|
+1 RIN <AUTOMATED_RECORD_ID> {0:1} # not used
|
|
|
|
+1 <<CHANGE_DATE>> {0:1} # not used
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2007-09-06 10:06:04 +05:30
|
|
|
owner = self.dbase.get_researcher()
|
2007-10-09 03:09:51 +05:30
|
|
|
name = owner.get_name()
|
|
|
|
addr = owner.get_address()
|
|
|
|
city = owner.get_city()
|
|
|
|
state = owner.get_state()
|
|
|
|
ctry = owner.get_country()
|
|
|
|
post = owner.get_postal_code()
|
2007-10-17 14:17:16 +05:30
|
|
|
phon = owner.get_phone()
|
2007-10-09 03:09:51 +05:30
|
|
|
mail = owner.get_email()
|
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
if not name :
|
|
|
|
name = u'Not Provided'
|
|
|
|
if not addr :
|
|
|
|
addr = u'Not Provided'
|
2007-02-07 16:10:56 +05:30
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(0, "@SUBM@", "SUBM")
|
|
|
|
self.__writeln(1, "NAME", name)
|
|
|
|
self.__writeln(1, "ADDR", addr)
|
2007-10-09 03:09:51 +05:30
|
|
|
if city and state and post:
|
|
|
|
self.__writeln(2, "CONT", "%s, %s %s" % (city, state, post))
|
2007-08-15 09:02:08 +05:30
|
|
|
else:
|
|
|
|
self.__writeln(2, "CONT", u"Not Provided")
|
2007-08-08 09:54:49 +05:30
|
|
|
if city:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, "CITY", city)
|
2007-10-09 03:09:51 +05:30
|
|
|
if state:
|
|
|
|
self.__writeln(2, "STAE", state)
|
2007-08-08 09:54:49 +05:30
|
|
|
if post:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, "POST", post)
|
2007-08-08 09:54:49 +05:30
|
|
|
if ctry:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, "CTRY", ctry)
|
2007-08-08 09:54:49 +05:30
|
|
|
if phon:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(1, "PHON", phon)
|
2007-09-07 05:08:38 +05:30
|
|
|
if mail:
|
|
|
|
self.__writeln(1, "EMAIL", mail)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __individuals(self):
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write the individual people to the gedcom file.
|
|
|
|
|
|
|
|
Since people like to have the list sorted by ID value, we need to go
|
|
|
|
through a sorting step. We need to reset the progress bar, otherwise,
|
|
|
|
people will be confused when the progress bar is idle.
|
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2008-07-21 00:03:04 +05:30
|
|
|
self.reset(_("Writing individuals"))
|
|
|
|
self.progress_cnt += 1
|
|
|
|
self.update(self.progress_cnt)
|
2009-07-04 01:53:41 +05:30
|
|
|
phandles = self.dbase.iter_person_handles()
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
sorted_list = []
|
2007-08-30 09:57:30 +05:30
|
|
|
for handle in phandles:
|
2007-09-06 10:06:04 +05:30
|
|
|
person = self.dbase.get_person_from_handle(handle)
|
2010-05-30 17:39:17 +05:30
|
|
|
if person:
|
|
|
|
data = (person.get_gramps_id(), handle)
|
|
|
|
sorted_list.append(data)
|
2007-09-06 10:06:04 +05:30
|
|
|
sorted_list.sort()
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
for data in sorted_list:
|
|
|
|
self.__person(self.dbase.get_person_from_handle(data[1]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __person(self, person):
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write out a single person.
|
|
|
|
|
|
|
|
n @XREF:INDI@ INDI {1:1}
|
|
|
|
+1 RESN <RESTRICTION_NOTICE> {0:1} # not used
|
|
|
|
+1 <<PERSONAL_NAME_STRUCTURE>> {0:M}
|
|
|
|
+1 SEX <SEX_VALUE> {0:1}
|
|
|
|
+1 <<INDIVIDUAL_EVENT_STRUCTURE>> {0:M}
|
|
|
|
+1 <<INDIVIDUAL_ATTRIBUTE_STRUCTURE>> {0:M}
|
|
|
|
+1 <<LDS_INDIVIDUAL_ORDINANCE>> {0:M}
|
|
|
|
+1 <<CHILD_TO_FAMILY_LINK>> {0:M}
|
|
|
|
+1 <<SPOUSE_TO_FAMILY_LINK>> {0:M}
|
|
|
|
+1 SUBM @<XREF:SUBM>@ {0:M}
|
|
|
|
+1 <<ASSOCIATION_STRUCTURE>> {0:M}
|
|
|
|
+1 ALIA @<XREF:INDI>@ {0:M}
|
|
|
|
+1 ANCI @<XREF:SUBM>@ {0:M}
|
|
|
|
+1 DESI @<XREF:SUBM>@ {0:M}
|
|
|
|
+1 <<SOURCE_CITATION>> {0:M}
|
|
|
|
+1 <<MULTIMEDIA_LINK>> {0:M} ,*
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
+1 RFN <PERMANENT_RECORD_FILE_NUMBER> {0:1}
|
|
|
|
+1 AFN <ANCESTRAL_FILE_NUMBER> {0:1}
|
|
|
|
+1 REFN <USER_REFERENCE_NUMBER> {0:M}
|
|
|
|
+2 TYPE <USER_REFERENCE_TYPE> {0:1}
|
|
|
|
+1 RIN <AUTOMATED_RECORD_ID> {0:1}
|
|
|
|
+1 <<CHANGE_DATE>> {0:1}
|
2007-08-06 09:41:52 +05:30
|
|
|
"""
|
2010-05-30 17:39:17 +05:30
|
|
|
if person is None:
|
|
|
|
return
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(0, "@%s@" % person.get_gramps_id(), "INDI")
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__names(person)
|
|
|
|
self.__gender(person)
|
|
|
|
self.__person_event_ref('BIRT', person.get_birth_ref())
|
|
|
|
self.__person_event_ref('DEAT', person.get_death_ref())
|
|
|
|
self.__remaining_events(person)
|
|
|
|
self.__attributes(person)
|
|
|
|
self.__lds_ords(person, 1)
|
|
|
|
self.__child_families(person)
|
|
|
|
self.__parent_families(person)
|
|
|
|
self.__assoc(person, 1)
|
|
|
|
self.__person_sources(person)
|
|
|
|
self.__addresses(person)
|
|
|
|
self.__photos(person.get_media_list(), 1)
|
|
|
|
self.__url_list(person, 1)
|
|
|
|
self.__note_references(person.get_note_list(), 1)
|
|
|
|
self.__change(person.get_change_time(), 1)
|
|
|
|
|
|
|
|
def __assoc(self, person, level):
|
2007-08-13 09:10:36 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n ASSO @<XREF:INDI>@ {0:M}
|
|
|
|
+1 RELA <RELATION_IS_DESCRIPTOR> {1:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
+1 <<SOURCE_CITATION>> {0:M}
|
2007-08-13 09:10:36 +05:30
|
|
|
"""
|
|
|
|
for ref in person.get_person_ref_list():
|
2007-09-06 10:06:04 +05:30
|
|
|
person = self.dbase.get_person_from_handle(ref.ref)
|
2010-05-30 17:39:17 +05:30
|
|
|
if person:
|
|
|
|
self.__writeln(level, "ASSO", "@%s@" % person.get_gramps_id())
|
|
|
|
self.__writeln(level+1, "RELA", ref.get_relation())
|
|
|
|
self.__note_references(ref.get_note_list(), level+1)
|
|
|
|
self.__source_references(ref.get_source_references(), level+1)
|
2007-08-13 09:10:36 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __note_references(self, notelist, level):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write out the list of note handles to the current level.
|
|
|
|
|
2009-11-19 23:02:11 +05:30
|
|
|
We use the Gramps ID as the XREF for the GEDCOM file.
|
2007-09-07 05:08:38 +05:30
|
|
|
|
|
|
|
"""
|
2007-08-09 10:05:06 +05:30
|
|
|
for note_handle in notelist:
|
2007-09-06 10:06:04 +05:30
|
|
|
note = self.dbase.get_note_from_handle(note_handle)
|
2010-05-30 17:39:17 +05:30
|
|
|
if note:
|
|
|
|
self.__writeln(level, 'NOTE', '@%s@' % note.get_gramps_id())
|
2007-08-09 10:05:06 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __names(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write the names associated with the person to the current level.
|
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
Since nicknames are now separate from the name structure, we search
|
|
|
|
the attribute list to see if we can find a nickname. Because we do
|
|
|
|
not know the mappings, we just take the first nickname we find, and
|
|
|
|
add it to the primary name.
|
|
|
|
|
|
|
|
All other names are assumed to not have a nickname, even if other
|
|
|
|
nicknames exist in the attribute list.
|
2008-02-18 21:22:40 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2007-08-09 10:05:06 +05:30
|
|
|
nicknames = [ attr.get_value() for attr in person.get_attribute_list()
|
2007-10-08 22:11:39 +05:30
|
|
|
if int(attr.get_type()) == gen.lib.AttributeType.NICKNAME ]
|
2007-08-09 10:05:06 +05:30
|
|
|
if len(nicknames) > 0:
|
|
|
|
nickname = nicknames[0]
|
|
|
|
else:
|
|
|
|
nickname = ""
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__person_name(person.get_primary_name(), nickname)
|
2007-08-09 10:05:06 +05:30
|
|
|
for name in person.get_alternate_names():
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__person_name(name, "")
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __gender(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write out the gender of the person to the file.
|
|
|
|
|
|
|
|
If the gender is not male or female, simply do not output anything.
|
|
|
|
The only valid values are M (male) or F (female). So if the geneder is
|
|
|
|
unknown, we output nothing.
|
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2007-10-08 22:11:39 +05:30
|
|
|
if person.get_gender() == gen.lib.Person.MALE:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(1, "SEX", "M")
|
2007-10-08 22:11:39 +05:30
|
|
|
elif person.get_gender() == gen.lib.Person.FEMALE:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(1, "SEX", "F")
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __lds_ords(self, obj, level):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
Simply loop through the list of LDS ordinances, and call the function
|
2008-02-18 21:22:40 +05:30
|
|
|
that writes the LDS ordinance structure.
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2007-08-14 09:32:18 +05:30
|
|
|
for lds_ord in obj.get_lds_ord_list():
|
|
|
|
self.write_ord(lds_ord, level)
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __remaining_events(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
Output all events associated with the person that are not BIRTH or
|
2008-02-18 21:22:40 +05:30
|
|
|
DEATH events.
|
|
|
|
|
|
|
|
Because all we have are event references, we have to
|
2007-09-07 05:08:38 +05:30
|
|
|
extract the real event to discover the event type.
|
2008-02-18 21:22:40 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2007-08-06 09:41:52 +05:30
|
|
|
for event_ref in person.get_event_ref_list():
|
2007-09-06 10:06:04 +05:30
|
|
|
event = self.dbase.get_event_from_handle(event_ref.ref)
|
2007-08-06 09:41:52 +05:30
|
|
|
etype = int(event.get_type())
|
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
# if the event is a birth or death, skip it.
|
2007-10-08 22:11:39 +05:30
|
|
|
if etype in (gen.lib.EventType.BIRTH, gen.lib.EventType.DEATH):
|
2007-08-06 09:41:52 +05:30
|
|
|
continue
|
|
|
|
|
2009-12-28 10:37:21 +05:30
|
|
|
val = libgedcom.personalConstantEvents.get(etype, "").strip()
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-08-15 09:44:19 +05:30
|
|
|
if val and val.strip():
|
2007-09-06 10:06:04 +05:30
|
|
|
if val in NEEDS_PARAMETER:
|
2007-08-06 09:41:52 +05:30
|
|
|
if event.get_description().strip():
|
|
|
|
self.__writeln(1, val, event.get_description())
|
|
|
|
else:
|
|
|
|
self.__writeln(1, val)
|
|
|
|
else:
|
2008-03-07 12:58:15 +05:30
|
|
|
if event_has_subordinate_data(event, event_ref):
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(1, val)
|
|
|
|
else:
|
|
|
|
self.__writeln(1, val, 'Y')
|
|
|
|
if event.get_description().strip():
|
|
|
|
self.__writeln(2, 'TYPE', event.get_description())
|
|
|
|
else:
|
2007-08-21 09:47:12 +05:30
|
|
|
self.__writeln(1, 'EVEN')
|
2007-08-06 09:41:52 +05:30
|
|
|
if val.strip():
|
|
|
|
self.__writeln(2, 'TYPE', val)
|
|
|
|
else:
|
|
|
|
self.__writeln(2, 'TYPE', str(event.get_type()))
|
2007-08-23 09:21:05 +05:30
|
|
|
descr = event.get_description()
|
|
|
|
if descr:
|
|
|
|
self.__writeln(2, 'NOTE', "Description: " + descr)
|
2007-09-07 08:14:22 +05:30
|
|
|
self.__dump_event_stats(event, event_ref)
|
2006-05-21 09:44:47 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__adoption_records(person)
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
def __adoption_records(self, person):
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write Adoption events for each child that has been adopted.
|
2007-09-07 08:14:22 +05:30
|
|
|
|
2008-02-18 21:22:40 +05:30
|
|
|
n ADOP
|
2007-09-07 08:14:22 +05:30
|
|
|
+1 <<INDIVIDUAL_EVENT_DETAIL>>
|
|
|
|
+1 FAMC @<XREF:FAM>@
|
2008-02-18 21:22:40 +05:30
|
|
|
+2 ADOP <ADOPTED_BY_WHICH_PARENT>
|
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2007-08-15 09:44:19 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
adoptions = []
|
2007-08-15 09:44:19 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
for family in [ self.dbase.get_family_from_handle(fh)
|
2007-08-15 09:44:19 +05:30
|
|
|
for fh in person.get_parent_family_handle_list() ]:
|
2010-05-31 21:17:22 +05:30
|
|
|
if family is None:
|
|
|
|
continue
|
2007-09-06 10:06:04 +05:30
|
|
|
for child_ref in [ ref for ref in family.get_child_ref_list()
|
|
|
|
if ref.ref == person.handle ]:
|
2007-10-08 22:11:39 +05:30
|
|
|
if child_ref.mrel == gen.lib.ChildRefType.ADOPTED \
|
|
|
|
or child_ref.frel == gen.lib.ChildRefType.ADOPTED:
|
2007-09-06 10:06:04 +05:30
|
|
|
adoptions.append((family, child_ref.frel, child_ref.mrel))
|
2007-08-15 09:44:19 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
for (fam, frel, mrel) in adoptions:
|
2007-08-15 09:44:19 +05:30
|
|
|
self.__writeln(1, 'ADOP', 'Y')
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'FAMC', '@%s@' % fam.get_gramps_id())
|
|
|
|
if mrel == frel:
|
|
|
|
self.__writeln(3, 'ADOP', 'BOTH')
|
2007-10-08 22:11:39 +05:30
|
|
|
elif mrel == gen.lib.ChildRefType.ADOPTED:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(3, 'ADOP', 'WIFE')
|
|
|
|
else:
|
|
|
|
self.__writeln(3, 'ADOP', 'HUSB')
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __attributes(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write out the attributes to the GEDCOM file.
|
|
|
|
|
|
|
|
Since we have already looked at nicknames when we generated the names,
|
|
|
|
we filter them out here.
|
2007-08-19 08:55:07 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
We use the GEDCOM 5.5.1 FACT command to write out attributes not
|
|
|
|
built in to GEDCOM.
|
2008-02-18 21:22:40 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
# filter out the nicknames
|
2007-08-19 08:55:07 +05:30
|
|
|
attr_list = [ attr for attr in person.get_attribute_list()
|
2007-10-08 22:11:39 +05:30
|
|
|
if attr.get_type() != gen.lib.AttributeType.NICKNAME ]
|
2007-08-19 08:55:07 +05:30
|
|
|
|
|
|
|
for attr in attr_list:
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
attr_type = int(attr.get_type())
|
2009-12-28 10:37:21 +05:30
|
|
|
name = libgedcom.personalConstantAttributes.get(attr_type)
|
2007-08-06 09:41:52 +05:30
|
|
|
key = str(attr.get_type())
|
|
|
|
value = attr.get_value().strip().replace('\r', ' ')
|
|
|
|
|
2007-08-16 10:00:49 +05:30
|
|
|
if key in ("AFN", "RFN", "REFN", "_UID"):
|
2007-08-29 09:47:20 +05:30
|
|
|
self.__writeln(1, key, value)
|
2007-08-06 09:41:52 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
if key == "RESN":
|
|
|
|
self.__writeln(1, 'RESN')
|
|
|
|
continue
|
|
|
|
|
|
|
|
if name and name.strip():
|
|
|
|
self.__writeln(1, name, value)
|
2007-08-23 09:21:05 +05:30
|
|
|
elif value:
|
|
|
|
self.__writeln(1, 'FACT', value)
|
|
|
|
self.__writeln(2, 'TYPE', key)
|
2007-08-06 09:41:52 +05:30
|
|
|
else:
|
2007-08-23 09:21:05 +05:30
|
|
|
continue
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(attr.get_note_list(), 2)
|
|
|
|
self.__source_references(attr.get_source_references(), 2)
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __source_references(self, ref_list, level):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
Loop through the list of source references, writing the information
|
|
|
|
to the file.
|
|
|
|
"""
|
2007-08-13 09:10:36 +05:30
|
|
|
for srcref in ref_list:
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__source_ref_record(level, srcref)
|
2007-08-13 09:10:36 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __addresses(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
Write out the addresses associated with the person as RESI events.
|
|
|
|
"""
|
2007-08-06 09:41:52 +05:30
|
|
|
for addr in person.get_address_list():
|
|
|
|
self.__writeln(1, 'RESI')
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__date(2, addr.get_date_object())
|
2007-08-13 05:30:16 +05:30
|
|
|
self.__writeln(2, "ADDR", addr.get_street())
|
|
|
|
if addr.get_city():
|
|
|
|
self.__writeln(3, 'CITY', addr.get_city())
|
|
|
|
if addr.get_state():
|
|
|
|
self.__writeln(3, 'STAE', addr.get_state())
|
|
|
|
if addr.get_postal_code():
|
|
|
|
self.__writeln(3, 'POST', addr.get_postal_code())
|
|
|
|
if addr.get_country():
|
|
|
|
self.__writeln(3, 'CTRY', addr.get_country())
|
|
|
|
if addr.get_phone():
|
|
|
|
self.__writeln(2, 'PHON', addr.get_phone())
|
2007-08-14 09:32:18 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(addr.get_note_list(), 2)
|
|
|
|
self.__source_references(addr.get_source_references(), 2)
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __photos(self, media_list, level):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
Loop through the list of media objects, writing the information
|
|
|
|
to the file.
|
|
|
|
"""
|
2007-08-25 10:33:23 +05:30
|
|
|
for photo in media_list:
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__photo(photo, level)
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __child_families(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Write the Gramps ID as the XREF for each family in which the person
|
2007-09-07 05:08:38 +05:30
|
|
|
is listed as a child.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# get the list of familes from the handle list
|
|
|
|
family_list = [ self.dbase.get_family_from_handle(hndl)
|
|
|
|
for hndl in person.get_parent_family_handle_list() ]
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
for family in family_list:
|
2010-05-30 17:39:17 +05:30
|
|
|
if family:
|
|
|
|
self.__writeln(1, 'FAMC', '@%s@' % family.get_gramps_id())
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __parent_families(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Write the Gramps ID as the XREF for each family in which the person
|
2007-09-07 05:08:38 +05:30
|
|
|
is listed as a parent.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# get the list of familes from the handle list
|
|
|
|
family_list = [ self.dbase.get_family_from_handle(hndl)
|
|
|
|
for hndl in person.get_family_handle_list() ]
|
|
|
|
|
|
|
|
for family in family_list:
|
2010-05-30 17:39:17 +05:30
|
|
|
if family:
|
|
|
|
self.__writeln(1, 'FAMS', '@%s@' % family.get_gramps_id())
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __person_sources(self, person):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
Loop through the list of source references, writing the information
|
|
|
|
to the file.
|
|
|
|
"""
|
2007-08-06 09:41:52 +05:30
|
|
|
for srcref in person.get_source_references():
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__source_ref_record(1, srcref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __url_list(self, obj, level):
|
2007-08-15 09:02:08 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n OBJE {1:1}
|
|
|
|
+1 FORM <MULTIMEDIA_FORMAT> {1:1}
|
|
|
|
+1 TITL <DESCRIPTIVE_TITLE> {0:1}
|
|
|
|
+1 FILE <MULTIMEDIA_FILE_REFERENCE> {1:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
2007-08-15 09:02:08 +05:30
|
|
|
"""
|
|
|
|
for url in obj.get_url_list():
|
|
|
|
self.__writeln(level, 'OBJE')
|
|
|
|
self.__writeln(level+1, 'FORM', 'URL')
|
2007-08-13 05:30:16 +05:30
|
|
|
if url.get_description():
|
2007-08-15 09:02:08 +05:30
|
|
|
self.__writeln(level+1, 'TITL', url.get_description())
|
|
|
|
if url.get_path():
|
2010-05-09 19:24:50 +05:30
|
|
|
self.__writeln(level+1, 'FILE', url.get_path(), limit=255)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __families(self):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Write out the list of families, sorting by Gramps ID.
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-07-21 00:03:04 +05:30
|
|
|
self.reset(_("Writing families"))
|
|
|
|
self.progress_cnt += 1
|
|
|
|
self.update(self.progress_cnt)
|
2007-09-07 05:08:38 +05:30
|
|
|
# generate a list of (GRAMPS_ID, HANDLE) pairs. This list
|
|
|
|
# can then be sorted by the sort routine, which will use the
|
|
|
|
# first value of the tuple as the sort key.
|
2009-07-12 01:41:37 +05:30
|
|
|
sorted_list = sort_handles_by_id(self.dbase.get_family_handles(),
|
2007-09-07 05:08:38 +05:30
|
|
|
self.dbase.get_family_from_handle)
|
2007-08-08 09:54:49 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
# loop through the sorted list, pulling of the handle. This list
|
|
|
|
# has already been sorted by GRAMPS_ID
|
2007-09-06 10:06:04 +05:30
|
|
|
for family_handle in [hndl[1] for hndl in sorted_list]:
|
|
|
|
self.__family(self.dbase.get_family_from_handle(family_handle))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __family(self, family):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n @<XREF:FAM>@ FAM {1:1}
|
|
|
|
+1 RESN <RESTRICTION_NOTICE> {0:1)
|
|
|
|
+1 <<FAMILY_EVENT_STRUCTURE>> {0:M}
|
|
|
|
+1 HUSB @<XREF:INDI>@ {0:1}
|
|
|
|
+1 WIFE @<XREF:INDI>@ {0:1}
|
|
|
|
+1 CHIL @<XREF:INDI>@ {0:M}
|
|
|
|
+1 NCHI <COUNT_OF_CHILDREN> {0:1}
|
|
|
|
+1 SUBM @<XREF:SUBM>@ {0:M}
|
|
|
|
+1 <<LDS_SPOUSE_SEALING>> {0:M}
|
|
|
|
+1 REFN <USER_REFERENCE_NUMBER> {0:M}
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2010-05-30 17:39:17 +05:30
|
|
|
if family is None:
|
|
|
|
return
|
2007-08-13 09:10:36 +05:30
|
|
|
gramps_id = family.get_gramps_id()
|
2006-06-07 10:13:18 +05:30
|
|
|
|
2007-08-13 09:10:36 +05:30
|
|
|
self.__writeln(0, '@%s@' % gramps_id, 'FAM' )
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__family_reference('HUSB', family.get_father_handle())
|
|
|
|
self.__family_reference('WIFE', family.get_mother_handle())
|
2007-08-16 10:00:49 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__lds_ords(family, 1)
|
|
|
|
self.__family_events(family)
|
|
|
|
self.__family_attributes(family.get_attribute_list(), 1)
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__family_child_list(family.get_child_ref_list())
|
|
|
|
self.__source_references(family.get_source_references(), 1)
|
|
|
|
self.__photos(family.get_media_list(), 1)
|
|
|
|
self.__note_references(family.get_note_list(), 1)
|
|
|
|
self.__change(family.get_change_time(), 1)
|
|
|
|
|
|
|
|
def __family_child_list(self, child_ref_list):
|
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write the child XREF values to the GEDCOM file.
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2007-09-06 10:06:04 +05:30
|
|
|
child_list = [
|
|
|
|
self.dbase.get_person_from_handle(cref.ref).get_gramps_id()
|
2010-05-30 17:39:17 +05:30
|
|
|
for cref in child_ref_list]
|
2007-08-16 10:00:49 +05:30
|
|
|
|
|
|
|
for gid in child_list:
|
|
|
|
self.__writeln(1, 'CHIL', '@%s@' % gid)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
def __family_reference(self, token, person_handle):
|
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write the family reference to the file.
|
|
|
|
|
2009-11-19 23:02:11 +05:30
|
|
|
This is either 'WIFE' or 'HUSB'. As usual, we use the Gramps ID as the
|
2008-02-18 21:22:40 +05:30
|
|
|
XREF value.
|
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
if person_handle:
|
|
|
|
person = self.dbase.get_person_from_handle(person_handle)
|
2010-05-30 17:39:17 +05:30
|
|
|
if person:
|
|
|
|
self.__writeln(1, token, '@%s@' % person.get_gramps_id())
|
2007-08-13 09:10:36 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __family_events(self, family):
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Output the events associated with the family.
|
|
|
|
|
|
|
|
Because all we have are event references, we have to extract the real
|
|
|
|
event to discover the event type.
|
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2010-01-22 00:12:53 +05:30
|
|
|
for event_ref in family.get_event_ref_list():
|
2007-09-06 10:06:04 +05:30
|
|
|
event = self.dbase.get_event_from_handle(event_ref.ref)
|
2007-08-14 09:32:18 +05:30
|
|
|
etype = int(event.get_type())
|
2009-12-28 10:37:21 +05:30
|
|
|
val = libgedcom.familyConstantEvents.get(etype)
|
2007-08-14 09:32:18 +05:30
|
|
|
|
|
|
|
if val:
|
2008-03-07 12:58:15 +05:30
|
|
|
if event_has_subordinate_data(event, event_ref):
|
2007-08-14 09:32:18 +05:30
|
|
|
self.__writeln(1, val)
|
|
|
|
else:
|
|
|
|
self.__writeln(1, val, 'Y')
|
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
if event.get_type() == gen.lib.EventType.MARRIAGE:
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__family_event_attrs(event.get_attribute_list(), 2)
|
2009-01-26 01:28:00 +05:30
|
|
|
|
|
|
|
if event.get_description().strip() != "":
|
2007-08-14 09:32:18 +05:30
|
|
|
self.__writeln(2, 'TYPE', event.get_description())
|
|
|
|
else:
|
|
|
|
self.__writeln(1, 'EVEN')
|
|
|
|
the_type = str(event.get_type())
|
|
|
|
if the_type:
|
|
|
|
self.__writeln(2, 'TYPE', the_type)
|
2007-08-23 09:21:05 +05:30
|
|
|
descr = event.get_description()
|
|
|
|
if descr:
|
|
|
|
self.__writeln(2, 'NOTE', "Description: " + descr)
|
2007-08-14 09:32:18 +05:30
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
self.__dump_event_stats(event, event_ref)
|
2007-08-14 09:32:18 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __family_event_attrs(self, attr_list, level):
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2009-08-09 22:39:32 +05:30
|
|
|
Write the attributes associated with the family event.
|
2008-02-18 21:22:40 +05:30
|
|
|
|
|
|
|
The only ones we really care about are FATHER_AGE and MOTHER_AGE which
|
|
|
|
we translate to WIFE/HUSB AGE attributes.
|
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2007-08-14 09:32:18 +05:30
|
|
|
for attr in attr_list:
|
2007-10-08 22:11:39 +05:30
|
|
|
if attr.get_type() == gen.lib.AttributeType.FATHER_AGE:
|
2007-08-14 09:32:18 +05:30
|
|
|
self.__writeln(level, 'HUSB')
|
|
|
|
self.__writeln(level+1, 'AGE', attr.get_value())
|
2007-10-08 22:11:39 +05:30
|
|
|
elif attr.get_type() == gen.lib.AttributeType.MOTHER_AGE:
|
2007-08-14 09:32:18 +05:30
|
|
|
self.__writeln(level, 'WIFE')
|
|
|
|
self.__writeln(level+1, 'AGE', attr.get_value())
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __family_attributes(self, attr_list, level):
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write out the attributes associated with a family to the GEDCOM file.
|
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
Since we have already looked at nicknames when we generated the names,
|
|
|
|
we filter them out here.
|
|
|
|
|
|
|
|
We use the GEDCOM 5.5.1 FACT command to write out attributes not
|
|
|
|
built in to GEDCOM.
|
2008-02-18 21:22:40 +05:30
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2007-08-13 09:10:36 +05:30
|
|
|
|
|
|
|
for attr in attr_list:
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
attr_type = int(attr.get_type())
|
2009-12-28 10:37:21 +05:30
|
|
|
name = libgedcom.familyConstantAttributes.get(attr_type)
|
2007-08-13 09:10:36 +05:30
|
|
|
value = attr.get_value().replace('\r', ' ')
|
2007-08-16 10:00:49 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
if attr_type in ("AFN", "RFN", "REFN", "_UID"):
|
|
|
|
self.__writeln(1, attr_type, value)
|
2007-08-16 10:00:49 +05:30
|
|
|
continue
|
2007-08-13 09:10:36 +05:30
|
|
|
|
|
|
|
if name and name.strip():
|
|
|
|
self.__writeln(1, name, value)
|
|
|
|
continue
|
|
|
|
else:
|
2007-09-07 08:14:22 +05:30
|
|
|
self.__writeln(1, 'FACT', value)
|
|
|
|
self.__writeln(2, 'TYPE', str(attr.get_type()))
|
2007-08-13 09:10:36 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(attr.get_note_list(), level+1)
|
|
|
|
self.__source_references(attr.get_source_references(),
|
2007-09-07 08:14:22 +05:30
|
|
|
level+1)
|
2007-07-06 08:45:26 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __sources(self):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Write out the list of sources, sorting by Gramps ID.
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-07-21 00:03:04 +05:30
|
|
|
self.reset(_("Writing sources"))
|
|
|
|
self.progress_cnt += 1
|
|
|
|
self.update(self.progress_cnt)
|
2008-02-18 21:22:40 +05:30
|
|
|
sorted_list = sort_handles_by_id(self.dbase.get_source_handles(),
|
2007-09-07 05:08:38 +05:30
|
|
|
self.dbase.get_source_from_handle)
|
2006-05-23 05:26:57 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
for (source_id, handle) in sorted_list:
|
|
|
|
source = self.dbase.get_source_from_handle(handle)
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(0, '@%s@' % source_id, 'SOUR')
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_title():
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(1, 'TITL', source.get_title())
|
2006-05-02 02:41:26 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_author():
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(1, "AUTH", source.get_author())
|
2006-05-02 02:41:26 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_publication_info():
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(1, "PUBL", source.get_publication_info())
|
2006-05-02 02:41:26 +05:30
|
|
|
|
2004-06-10 05:29:03 +05:30
|
|
|
if source.get_abbreviation():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(1, 'ABBR', source.get_abbreviation())
|
2007-08-08 09:54:49 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__photos(source.get_media_list(), 1)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-05-22 05:02:34 +05:30
|
|
|
for reporef in source.get_reporef_list():
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__reporef(reporef, 1)
|
2007-08-15 09:02:08 +05:30
|
|
|
break
|
2006-05-22 05:02:34 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(source.get_note_list(), 1)
|
|
|
|
self.__change(source.get_change_time(), 1)
|
2007-08-09 10:05:06 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __notes(self):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Write out the list of notes, sorting by Gramps ID.
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-07-21 00:03:04 +05:30
|
|
|
self.reset(_("Writing notes"))
|
|
|
|
self.progress_cnt += 1
|
|
|
|
self.update(self.progress_cnt)
|
2008-02-18 21:22:40 +05:30
|
|
|
sorted_list = sort_handles_by_id(self.dbase.get_note_handles(),
|
2007-09-07 05:08:38 +05:30
|
|
|
self.dbase.get_note_from_handle)
|
2007-08-09 10:05:06 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
for note_handle in [hndl[1] for hndl in sorted_list]:
|
|
|
|
note = self.dbase.get_note_from_handle(note_handle)
|
|
|
|
self.__note_record(note)
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __note_record(self, note):
|
2007-08-09 10:05:06 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n @<XREF:NOTE>@ NOTE <SUBMITTER_TEXT> {1:1}
|
|
|
|
+1 [ CONC | CONT] <SUBMITTER_TEXT> {0:M}
|
|
|
|
+1 <<SOURCE_CITATION>> {0:M}
|
|
|
|
+1 REFN <USER_REFERENCE_NUMBER> {0:M}
|
|
|
|
+2 TYPE <USER_REFERENCE_TYPE> {0:1}
|
|
|
|
+1 RIN <AUTOMATED_RECORD_ID> {0:1}
|
|
|
|
+1 <<CHANGE_DATE>> {0:1}
|
2007-08-09 10:05:06 +05:30
|
|
|
"""
|
2010-05-30 17:39:17 +05:30
|
|
|
if note:
|
|
|
|
self.__writeln(0, '@%s@' % note.get_gramps_id(), 'NOTE ' + note.get())
|
2007-08-09 10:05:06 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __repos(self):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2009-11-19 23:02:11 +05:30
|
|
|
Write out the list of repositories, sorting by Gramps ID.
|
2006-05-22 05:02:34 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
REPOSITORY_RECORD:=
|
2008-02-18 21:22:40 +05:30
|
|
|
n @<XREF:REPO>@ REPO {1:1}
|
|
|
|
+1 NAME <NAME_OF_REPOSITORY> {1:1}
|
|
|
|
+1 <<ADDRESS_STRUCTURE>> {0:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
+1 REFN <USER_REFERENCE_NUMBER> {0:M}
|
|
|
|
+2 TYPE <USER_REFERENCE_TYPE> {0:1}
|
|
|
|
+1 RIN <AUTOMATED_RECORD_ID> {0:1}
|
|
|
|
+1 <<CHANGE_DATE>> {0:1}
|
|
|
|
"""
|
2008-07-21 00:03:04 +05:30
|
|
|
self.reset(_("Writing repositories"))
|
|
|
|
self.progress_cnt += 1
|
|
|
|
self.update(self.progress_cnt)
|
2008-02-18 21:22:40 +05:30
|
|
|
sorted_list = sort_handles_by_id(self.dbase.get_repository_handles(),
|
2007-09-07 05:08:38 +05:30
|
|
|
self.dbase.get_repository_from_handle)
|
2007-08-15 09:02:08 +05:30
|
|
|
|
|
|
|
# GEDCOM only allows for a single repository per source
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
for (repo_id, handle) in sorted_list:
|
|
|
|
repo = self.dbase.get_repository_from_handle(handle)
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(0, '@%s@' % repo_id, 'REPO' )
|
2006-05-22 05:02:34 +05:30
|
|
|
if repo.get_name():
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(1, 'NAME', repo.get_name())
|
2006-05-22 05:02:34 +05:30
|
|
|
for addr in repo.get_address_list():
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(1, "ADDR", addr.get_street())
|
2006-05-23 05:26:57 +05:30
|
|
|
if addr.get_city():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'CITY', addr.get_city())
|
2006-05-23 05:26:57 +05:30
|
|
|
if addr.get_state():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'STAE', addr.get_state())
|
2006-05-23 05:26:57 +05:30
|
|
|
if addr.get_postal_code():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'POST', addr.get_postal_code())
|
2006-05-23 05:26:57 +05:30
|
|
|
if addr.get_country():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'CTRY', addr.get_country())
|
2006-05-23 05:26:57 +05:30
|
|
|
if addr.get_phone():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(1, 'PHON', addr.get_phone())
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(repo.get_note_list(), 1)
|
2006-05-22 05:02:34 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
def __reporef(self, reporef, level):
|
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n REPO [ @XREF:REPO@ | <NULL>] {1:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
+1 CALN <SOURCE_CALL_NUMBER> {0:M}
|
|
|
|
+2 MEDI <SOURCE_MEDIA_TYPE> {0:1}
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2006-05-23 05:26:57 +05:30
|
|
|
|
2008-06-16 20:31:46 +05:30
|
|
|
if reporef.ref is None:
|
2006-05-22 05:02:34 +05:30
|
|
|
return
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
repo = self.dbase.get_repository_from_handle(reporef.ref)
|
2010-05-30 17:39:17 +05:30
|
|
|
if repo is None:
|
|
|
|
return
|
|
|
|
|
2006-05-22 05:02:34 +05:30
|
|
|
repo_id = repo.get_gramps_id()
|
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level, 'REPO', '@%s@' % repo_id )
|
2006-05-22 05:02:34 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(reporef.get_note_list(), level+1)
|
2006-05-22 05:02:34 +05:30
|
|
|
|
|
|
|
if reporef.get_call_number():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level+1, 'CALN', reporef.get_call_number() )
|
2006-05-22 05:02:34 +05:30
|
|
|
if reporef.get_media_type():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level+2, 'MEDI', str(reporef.get_media_type()))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __person_event_ref(self, key, event_ref):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write out the BIRTH and DEATH events for the person.
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2007-08-06 09:41:52 +05:30
|
|
|
if event_ref:
|
2007-09-06 10:06:04 +05:30
|
|
|
event = self.dbase.get_event_from_handle(event_ref.ref)
|
2008-03-07 12:58:15 +05:30
|
|
|
if event_has_subordinate_data(event, event_ref):
|
2007-08-08 09:54:49 +05:30
|
|
|
self.__writeln(1, key)
|
|
|
|
else:
|
|
|
|
self.__writeln(1, key, 'Y')
|
|
|
|
if event.get_description().strip() != "":
|
|
|
|
self.__writeln(2, 'TYPE', event.get_description())
|
2007-09-07 08:14:22 +05:30
|
|
|
self.__dump_event_stats(event, event_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __change(self, timeval, level):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
CHANGE_DATE:=
|
|
|
|
n CHAN {1:1}
|
2007-09-07 05:08:38 +05:30
|
|
|
+1 DATE <CHANGE_DATE> {1:1}
|
|
|
|
+2 TIME <TIME_VALUE> {0:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> # not used
|
|
|
|
"""
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level, 'CHAN')
|
2004-08-24 09:18:15 +05:30
|
|
|
time_val = time.localtime(timeval)
|
2007-08-14 09:32:18 +05:30
|
|
|
self.__writeln(level+1, 'DATE', '%d %s %d' % (
|
2010-01-25 10:24:22 +05:30
|
|
|
time_val[2], libgedcom.MONTH[time_val[1]], time_val[0]))
|
2007-08-14 09:32:18 +05:30
|
|
|
self.__writeln(level+2, 'TIME', '%02d:%02d:%02d' % (
|
|
|
|
time_val[3], time_val[4], time_val[5]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
def __dump_event_stats(self, event, event_ref):
|
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write the event details for the event, using the event and event
|
|
|
|
reference information.
|
|
|
|
|
|
|
|
GEDCOM does not make a distinction between the two.
|
|
|
|
|
2007-09-07 08:14:22 +05:30
|
|
|
"""
|
2004-02-14 11:10:30 +05:30
|
|
|
dateobj = event.get_date_object()
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__date(2, dateobj)
|
2005-12-06 12:08:09 +05:30
|
|
|
place = None
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if event.get_place_handle():
|
2007-09-06 10:06:04 +05:30
|
|
|
place = self.dbase.get_place_from_handle(event.get_place_handle())
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__place(place, 2)
|
2007-08-06 09:41:52 +05:30
|
|
|
|
2006-08-16 08:01:29 +05:30
|
|
|
for attr in event.get_attribute_list():
|
2007-09-06 10:06:04 +05:30
|
|
|
attr_type = attr.get_type()
|
2007-10-08 22:11:39 +05:30
|
|
|
if attr_type == gen.lib.AttributeType.CAUSE:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'CAUS', attr.get_value())
|
2007-10-08 22:11:39 +05:30
|
|
|
elif attr_type == gen.lib.AttributeType.AGENCY:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'AGNC', attr.get_value())
|
|
|
|
|
2006-08-16 08:01:29 +05:30
|
|
|
for attr in event_ref.get_attribute_list():
|
2007-09-06 10:06:04 +05:30
|
|
|
attr_type = attr.get_type()
|
2007-10-08 22:11:39 +05:30
|
|
|
if attr_type == gen.lib.AttributeType.AGE:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'AGE', attr.get_value())
|
2007-10-08 22:11:39 +05:30
|
|
|
elif attr_type == gen.lib.AttributeType.FATHER_AGE:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'HUSB')
|
|
|
|
self.__writeln(3, 'AGE', attr.get_value())
|
2007-10-08 22:11:39 +05:30
|
|
|
elif attr_type == gen.lib.AttributeType.MOTHER_AGE:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'WIFE')
|
|
|
|
self.__writeln(3, 'AGE', attr.get_value())
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(event.get_note_list(), 2)
|
|
|
|
self.__source_references(event.get_source_references(), 2)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__photos(event.get_media_list(), 2)
|
2007-08-25 10:33:23 +05:30
|
|
|
if place:
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__photos(place.get_media_list(), 2)
|
|
|
|
|
|
|
|
def write_ord(self, lds_ord, index):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
LDS_INDIVIDUAL_ORDINANCE:=
|
|
|
|
[
|
|
|
|
n [ BAPL | CONL ] {1:1}
|
|
|
|
+1 DATE <DATE_LDS_ORD> {0:1}
|
|
|
|
+1 TEMP <TEMPLE_CODE> {0:1}
|
|
|
|
+1 PLAC <PLACE_LIVING_ORDINANCE> {0:1}
|
|
|
|
+1 STAT <LDS_BAPTISM_DATE_STATUS> {0:1}
|
|
|
|
+2 DATE <CHANGE_DATE> {1:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
+1 <<SOURCE_CITATION>> {0:M} p.39
|
|
|
|
|
|
|
|
|
n ENDL {1:1}
|
|
|
|
+1 DATE <DATE_LDS_ORD> {0:1}
|
|
|
|
+1 TEMP <TEMPLE_CODE> {0:1}
|
|
|
|
+1 PLAC <PLACE_LIVING_ORDINANCE> {0:1}
|
|
|
|
+1 STAT <LDS_ENDOWMENT_DATE_STATUS> {0:1}
|
|
|
|
+2 DATE <CHANGE_DATE> {1:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
+1 <<SOURCE_CITATION>> {0:M}
|
|
|
|
|
|
|
|
|
n SLGC {1:1}
|
|
|
|
+1 DATE <DATE_LDS_ORD> {0:1}
|
|
|
|
+1 TEMP <TEMPLE_CODE> {0:1}
|
|
|
|
+1 PLAC <PLACE_LIVING_ORDINANCE> {0:1}
|
|
|
|
+1 FAMC @<XREF:FAM>@ {1:1}
|
|
|
|
+1 STAT <LDS_CHILD_SEALING_DATE_STATUS> {0:1}
|
|
|
|
+2 DATE <CHANGE_DATE> {1:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
+1 <<SOURCE_CITATION>> {0:M}
|
|
|
|
]
|
|
|
|
"""
|
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__writeln(index, LDS_ORD_NAME[lds_ord.get_type()])
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__date(index + 1, lds_ord.get_date_object())
|
2007-09-06 10:06:04 +05:30
|
|
|
if lds_ord.get_family_handle():
|
|
|
|
family_handle = lds_ord.get_family_handle()
|
|
|
|
family = self.dbase.get_family_from_handle(family_handle)
|
2006-05-23 05:26:57 +05:30
|
|
|
if family:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(index+1, 'FAMC', '@%s@' % family.get_gramps_id())
|
2007-09-06 10:06:04 +05:30
|
|
|
if lds_ord.get_temple():
|
|
|
|
self.__writeln(index+1, 'TEMP', lds_ord.get_temple())
|
|
|
|
if lds_ord.get_place_handle():
|
2007-09-07 05:08:38 +05:30
|
|
|
self.__place(
|
2007-09-06 10:06:04 +05:30
|
|
|
self.dbase.get_place_from_handle(lds_ord.get_place_handle()), 2)
|
2007-10-08 22:11:39 +05:30
|
|
|
if lds_ord.get_status() != gen.lib.LdsOrd.STATUS_NONE:
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__writeln(2, 'STAT', LDS_STATUS[lds_ord.get_status()])
|
2007-08-09 10:05:06 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(lds_ord.get_note_list(), index+1)
|
|
|
|
self.__source_references(lds_ord.get_source_references(), index+1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
def __date(self, level, date):
|
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
Write the 'DATE' GEDCOM token, along with the date in GEDCOM's
|
2009-09-26 02:15:05 +05:30
|
|
|
expected format.
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
2002-10-20 19:55:16 +05:30
|
|
|
start = date.get_start_date()
|
2007-10-08 22:11:39 +05:30
|
|
|
if start != gen.lib.Date.EMPTY:
|
2004-09-17 09:00:04 +05:30
|
|
|
cal = date.get_calendar()
|
|
|
|
mod = date.get_modifier()
|
2008-01-26 03:17:38 +05:30
|
|
|
quality = date.get_quality()
|
2008-01-26 03:19:40 +05:30
|
|
|
if mod == gen.lib.Date.MOD_SPAN:
|
2006-05-23 05:26:57 +05:30
|
|
|
val = "FROM %s TO %s" % (
|
2010-01-25 10:24:22 +05:30
|
|
|
libgedcom.make_gedcom_date(start, cal, mod, quality),
|
|
|
|
libgedcom.make_gedcom_date(date.get_stop_date(),
|
|
|
|
cal, mod, quality))
|
2008-01-26 03:19:40 +05:30
|
|
|
elif mod == gen.lib.Date.MOD_RANGE:
|
2006-05-23 05:26:57 +05:30
|
|
|
val = "BET %s AND %s" % (
|
2010-01-25 10:24:22 +05:30
|
|
|
libgedcom.make_gedcom_date(start, cal, mod, quality),
|
|
|
|
libgedcom.make_gedcom_date(date.get_stop_date(),
|
|
|
|
cal, mod, quality))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2010-01-25 10:24:22 +05:30
|
|
|
val = libgedcom.make_gedcom_date(start, cal, mod, quality)
|
2007-08-13 05:30:16 +05:30
|
|
|
self.__writeln(level, 'DATE', val)
|
2005-07-09 01:54:54 +05:30
|
|
|
elif date.get_text():
|
2007-08-13 05:30:16 +05:30
|
|
|
self.__writeln(level, 'DATE', date.get_text())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __person_name(self, name, nick):
|
2007-08-09 10:05:06 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n NAME <NAME_PERSONAL> {1:1}
|
|
|
|
+1 NPFX <NAME_PIECE_PREFIX> {0:1}
|
|
|
|
+1 GIVN <NAME_PIECE_GIVEN> {0:1}
|
|
|
|
+1 NICK <NAME_PIECE_NICKNAME> {0:1}
|
|
|
|
+1 SPFX <NAME_PIECE_SURNAME_PREFIX {0:1}
|
|
|
|
+1 SURN <NAME_PIECE_SURNAME> {0:1}
|
|
|
|
+1 NSFX <NAME_PIECE_SUFFIX> {0:1}
|
|
|
|
+1 <<SOURCE_CITATION>> {0:M}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
2007-08-09 10:05:06 +05:30
|
|
|
"""
|
2009-09-26 06:35:08 +05:30
|
|
|
gedcom_name = name.get_gedcom_name()
|
|
|
|
|
2007-08-09 10:05:06 +05:30
|
|
|
firstname = name.get_first_name().strip()
|
|
|
|
patron = name.get_patronymic().strip()
|
|
|
|
if patron:
|
2007-08-31 00:02:15 +05:30
|
|
|
firstname = "%s %s" % (firstname, patron)
|
2007-08-06 09:41:52 +05:30
|
|
|
surname = name.get_surname().replace('/', '?')
|
|
|
|
surprefix = name.get_surname_prefix().replace('/', '?')
|
|
|
|
suffix = name.get_suffix()
|
|
|
|
title = name.get_title()
|
2009-09-26 06:35:08 +05:30
|
|
|
|
|
|
|
self.__writeln(1, 'NAME', gedcom_name)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
if firstname:
|
|
|
|
self.__writeln(2, 'GIVN', firstname)
|
2007-08-13 05:30:16 +05:30
|
|
|
if surprefix:
|
|
|
|
self.__writeln(2, 'SPFX', surprefix)
|
|
|
|
if surname:
|
|
|
|
self.__writeln(2, 'SURN', surname)
|
2002-12-04 10:28:07 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_suffix():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'NSFX', suffix)
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_title():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'NPFX', title)
|
2002-12-30 06:12:47 +05:30
|
|
|
if nick:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(2, 'NICK', nick)
|
2007-08-14 09:32:18 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__source_references(name.get_source_references(), 2)
|
|
|
|
self.__note_references(name.get_note_list(), 2)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
def __source_ref_record(self, level, ref):
|
2007-08-09 10:05:06 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n SOUR @<XREF:SOUR>@ /* pointer to source record */ {1:1}
|
|
|
|
+1 PAGE <WHERE_WITHIN_SOURCE> {0:1}
|
|
|
|
+1 EVEN <EVENT_TYPE_CITED_FROM> {0:1}
|
|
|
|
+2 ROLE <ROLE_IN_EVENT> {0:1}
|
|
|
|
+1 DATA {0:1}
|
|
|
|
+2 DATE <ENTRY_RECORDING_DATE> {0:1}
|
|
|
|
+2 TEXT <TEXT_FROM_SOURCE> {0:M}
|
|
|
|
+3 [ CONC | CONT ] <TEXT_FROM_SOURCE> {0:M}
|
|
|
|
+1 QUAY <CERTAINTY_ASSESSMENT> {0:1}
|
|
|
|
+1 <<MULTIMEDIA_LINK>> {0:M} ,*
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
2007-08-09 10:05:06 +05:30
|
|
|
"""
|
2006-05-23 05:26:57 +05:30
|
|
|
|
|
|
|
src_handle = ref.get_reference_handle()
|
2008-06-16 20:31:46 +05:30
|
|
|
if src_handle is None:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2003-01-03 08:49:50 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
src = self.dbase.get_source_from_handle(src_handle)
|
2010-05-02 00:21:31 +05:30
|
|
|
if src is None:
|
|
|
|
return
|
2006-05-23 05:26:57 +05:30
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
# Reference to the source
|
|
|
|
self.__writeln(level, "SOUR", "@%s@" % src.get_gramps_id())
|
|
|
|
if ref.get_page() != "":
|
2010-01-03 17:01:19 +05:30
|
|
|
# PAGE <WHERE_WITHIN_SOURCE> can not have CONC lines.
|
|
|
|
# WHERE_WITHIN_SOURCE:= {Size=1:248}
|
|
|
|
# Maximize line to 248 and set limit to 248, for no line split
|
|
|
|
self.__writeln(level+1, 'PAGE', ref.get_page()[0:248], limit=248)
|
|
|
|
|
2007-08-09 10:05:06 +05:30
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
conf = min(ref.get_confidence_level(), gen.lib.SourceRef.CONF_VERY_HIGH)
|
|
|
|
if conf != gen.lib.SourceRef.CONF_NORMAL and conf != -1:
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__writeln(level+1, "QUAY", QUALITY_MAP[conf])
|
2006-06-17 00:08:06 +05:30
|
|
|
|
2009-06-21 01:53:40 +05:30
|
|
|
if not ref.get_date_object().is_empty():
|
|
|
|
self.__writeln(level+1, 'DATA')
|
|
|
|
self.__date(level+2, ref.get_date_object())
|
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
if len(ref.get_note_list()) > 0:
|
2007-07-18 09:47:30 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
note_list = [ self.dbase.get_note_from_handle(h)
|
|
|
|
for h in ref.get_note_list() ]
|
2007-08-06 09:41:52 +05:30
|
|
|
note_list = [ n for n in note_list
|
2007-10-08 22:11:39 +05:30
|
|
|
if n.get_type() == gen.lib.NoteType.SOURCE_TEXT]
|
2007-07-18 09:47:30 +05:30
|
|
|
|
2007-08-06 09:41:52 +05:30
|
|
|
if note_list:
|
|
|
|
ref_text = note_list[0].get()
|
|
|
|
else:
|
|
|
|
ref_text = ""
|
2007-07-18 09:47:30 +05:30
|
|
|
|
2009-06-21 01:53:40 +05:30
|
|
|
if ref_text != "" and ref.get_date_object().is_empty():
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level+1, 'DATA')
|
2009-06-21 01:53:40 +05:30
|
|
|
if ref_text != "":
|
|
|
|
self.__writeln(level+2, "TEXT", ref_text)
|
2007-07-18 09:47:30 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
note_list = [ self.dbase.get_note_from_handle(h)
|
|
|
|
for h in ref.get_note_list() ]
|
2007-08-13 05:30:16 +05:30
|
|
|
note_list = [ n.handle for n in note_list
|
2010-05-30 17:39:17 +05:30
|
|
|
if n and n.get_type() != gen.lib.NoteType.SOURCE_TEXT]
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(note_list, level+1)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
def __photo(self, photo, level):
|
2007-08-15 09:02:08 +05:30
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
n OBJE {1:1}
|
|
|
|
+1 FORM <MULTIMEDIA_FORMAT> {1:1}
|
|
|
|
+1 TITL <DESCRIPTIVE_TITLE> {0:1}
|
|
|
|
+1 FILE <MULTIMEDIA_FILE_REFERENCE> {1:1}
|
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
2007-08-15 09:02:08 +05:30
|
|
|
"""
|
2005-12-06 12:08:09 +05:30
|
|
|
photo_obj_id = photo.get_reference_handle()
|
2007-09-06 10:06:04 +05:30
|
|
|
photo_obj = self.dbase.get_object_from_handle(photo_obj_id)
|
2005-12-06 12:08:09 +05:30
|
|
|
if photo_obj:
|
|
|
|
mime = photo_obj.get_mime_type()
|
2007-09-06 10:06:04 +05:30
|
|
|
form = MIME2GED.get(mime, mime)
|
2008-02-18 19:36:41 +05:30
|
|
|
path = media_path_full(self.dbase, photo_obj.get_path())
|
2005-12-06 12:08:09 +05:30
|
|
|
if not os.path.isfile(path):
|
|
|
|
return
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level, 'OBJE')
|
2005-12-06 12:08:09 +05:30
|
|
|
if form:
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level+1, 'FORM', form)
|
|
|
|
self.__writeln(level+1, 'TITL', photo_obj.get_description())
|
2010-05-09 19:24:50 +05:30
|
|
|
self.__writeln(level+1, 'FILE', path, limit=255)
|
2007-08-09 10:05:06 +05:30
|
|
|
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__note_references(photo_obj.get_note_list(), level+1)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-09-07 05:08:38 +05:30
|
|
|
def __place(self, place, level):
|
|
|
|
"""
|
2008-02-18 21:22:40 +05:30
|
|
|
PLACE_STRUCTURE:=
|
|
|
|
n PLAC <PLACE_NAME> {1:1}
|
2007-09-07 05:08:38 +05:30
|
|
|
+1 FORM <PLACE_HIERARCHY> {0:1}
|
|
|
|
+1 FONE <PLACE_PHONETIC_VARIATION> {0:M} # not used
|
2008-02-18 21:22:40 +05:30
|
|
|
+2 TYPE <PHONETIC_TYPE> {1:1}
|
2007-09-07 05:08:38 +05:30
|
|
|
+1 ROMN <PLACE_ROMANIZED_VARIATION> {0:M} # not used
|
2008-02-18 21:22:40 +05:30
|
|
|
+2 TYPE <ROMANIZED_TYPE> {1:1}
|
2007-09-07 05:08:38 +05:30
|
|
|
+1 MAP {0:1}
|
2008-02-18 21:22:40 +05:30
|
|
|
+2 LATI <PLACE_LATITUDE> {1:1}
|
|
|
|
+2 LONG <PLACE_LONGITUDE> {1:1}
|
2007-09-07 05:08:38 +05:30
|
|
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
|
|
|
"""
|
2005-12-06 12:08:09 +05:30
|
|
|
place_name = place.get_title()
|
2007-08-06 09:41:52 +05:30
|
|
|
self.__writeln(level, "PLAC", place_name.replace('\r', ' '))
|
2007-09-06 10:06:04 +05:30
|
|
|
longitude = place.get_longitude()
|
|
|
|
latitude = place.get_latitude()
|
2010-03-23 04:05:53 +05:30
|
|
|
if longitude and latitude:
|
|
|
|
(latitude, longitude) = conv_lat_lon(latitude, longitude, "GEDCOM")
|
2007-09-06 10:06:04 +05:30
|
|
|
if longitude and latitude:
|
2007-08-25 03:24:06 +05:30
|
|
|
self.__writeln(level+1, "MAP")
|
2007-09-06 10:06:04 +05:30
|
|
|
self.__writeln(level+2, 'LATI', latitude)
|
|
|
|
self.__writeln(level+2, 'LONG', longitude)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2008-03-19 03:42:49 +05:30
|
|
|
# The Gedcom standard shows that an optional address structure can
|
|
|
|
# be written out in the event detail.
|
|
|
|
# http://homepages.rootsweb.com/~pmcbride/gedcom/55gcch2.htm#EVENT_DETAIL
|
|
|
|
location = place.get_main_location()
|
2008-06-28 17:20:41 +05:30
|
|
|
if location and not location.is_empty():
|
|
|
|
self.__writeln(level, "ADDR", location.get_street())
|
2008-03-19 03:42:49 +05:30
|
|
|
if location.get_city():
|
|
|
|
self.__writeln(level + 1, 'CITY', location.get_city())
|
|
|
|
if location.get_state():
|
|
|
|
self.__writeln(level + 1, 'STAE', location.get_state())
|
|
|
|
if location.get_postal_code():
|
|
|
|
self.__writeln(level + 1, 'POST', location.get_postal_code())
|
|
|
|
if location.get_country():
|
|
|
|
self.__writeln(level + 1, 'CTRY', location.get_country())
|
|
|
|
if location.get_phone():
|
|
|
|
self.__writeln(level, 'PHON', location.get_phone())
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-05-01 09:42:42 +05:30
|
|
|
def export_data(database, filename, msg_callback, option_box=None, callback=None):
|
2007-09-07 05:08:38 +05:30
|
|
|
"""
|
|
|
|
External interface used to register with the plugin system.
|
|
|
|
"""
|
2008-01-15 14:46:45 +05:30
|
|
|
ret = False
|
2008-07-22 00:05:37 +05:30
|
|
|
try:
|
2008-11-04 09:42:51 +05:30
|
|
|
ged_write = GedcomWriter(database, 0, option_box, callback)
|
2008-07-22 00:05:37 +05:30
|
|
|
ret = ged_write.write_gedcom_file(filename)
|
|
|
|
except IOError, msg:
|
|
|
|
msg2 = _("Could not create %s") % filename
|
2010-05-01 09:42:42 +05:30
|
|
|
msg_callback(msg2, str(msg))
|
2008-07-22 00:05:37 +05:30
|
|
|
except Errors.DatabaseError, msg:
|
2010-05-01 09:42:42 +05:30
|
|
|
msg_callback(_("Export failed"), str(msg))
|
2004-07-11 05:01:28 +05:30
|
|
|
return ret
|