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
|
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.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-23 05:26:57 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import re
|
2005-08-18 11:28:28 +05:30
|
|
|
import shutil
|
2006-03-21 11:53:45 +05:30
|
|
|
|
2006-03-05 10:01:24 +05:30
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".WriteGedcom")
|
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk
|
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-01-15 10:55:50 +05:30
|
|
|
import RelLib
|
2006-05-03 06:32:54 +05:30
|
|
|
from Filters import GenericFilter, Rules, build_filter_menu
|
2002-12-30 06:12:47 +05:30
|
|
|
import const
|
2005-12-21 16:57:05 +05:30
|
|
|
import _GedcomInfo as GedcomInfo
|
2003-06-18 08:20:30 +05:30
|
|
|
import Errors
|
2003-01-19 11:55:20 +05:30
|
|
|
import ansel_utf8
|
2004-10-11 04:52:12 +05:30
|
|
|
import Utils
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer
|
2006-12-11 09:40:46 +05:30
|
|
|
from QuestionDialog import *
|
2006-05-16 09:17:58 +05:30
|
|
|
from BasicUtils import UpdateCallback
|
2002-12-30 06:12:47 +05:30
|
|
|
|
2007-02-03 22:41:05 +05:30
|
|
|
try:
|
|
|
|
import Config
|
2007-02-04 23:07:36 +05:30
|
|
|
HAVE_CONFIG = True
|
2007-02-03 22:41:05 +05:30
|
|
|
except:
|
|
|
|
log.warn("No Config module available using defaults.")
|
2007-02-04 23:07:36 +05:30
|
|
|
HAVE_CONFIG = False
|
2007-02-03 22:41:05 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Helper functions
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-01-19 11:55:20 +05:30
|
|
|
def keep_utf8(s):
|
|
|
|
return s
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-06-25 04:37:14 +05:30
|
|
|
def iso8859(s):
|
2005-05-24 18:38:06 +05:30
|
|
|
return s.encode('iso-8859-1','replace')
|
2003-06-25 04:37:14 +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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
personalAttributeTakesParam = set(["CAST", "DSCR", "EDUC", "IDNO",
|
|
|
|
"NATI", "NCHI", "NMR", "OCCU",
|
|
|
|
"PROP", "RELI", "SSN", "TITL"])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Calendar month names
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
_hmonth = [
|
2003-01-15 10:55:50 +05:30
|
|
|
"", "ELUL", "TSH", "CSH", "KSL", "TVT", "SHV", "ADR",
|
2002-10-20 19:55:16 +05:30
|
|
|
"ADS", "NSN", "IYR", "SVN", "TMZ", "AAV", "ELL" ]
|
|
|
|
|
|
|
|
_fmonth = [
|
|
|
|
"", "VEND", "BRUM", "FRIM", "NIVO", "PLUV", "VENT",
|
|
|
|
"GERM", "FLOR", "PRAI", "MESS", "THER", "FRUC", "COMP"]
|
|
|
|
|
|
|
|
_month = [
|
|
|
|
"", "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
|
|
|
|
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ]
|
|
|
|
|
|
|
|
_calmap = {
|
2007-04-21 10:24:28 +05:30
|
|
|
RelLib.Date.CAL_HEBREW : (_hmonth, '@#DHEBREW@'),
|
|
|
|
RelLib.Date.CAL_FRENCH : (_fmonth, '@#DFRENCH R@'),
|
|
|
|
RelLib.Date.CAL_JULIAN : (_month, '@#DJULIAN@'),
|
2002-10-20 19:55:16 +05:30
|
|
|
}
|
|
|
|
|
2002-12-29 11:14:35 +05:30
|
|
|
_caldef = {
|
2006-02-04 03:33:53 +05:30
|
|
|
RelLib.Date.MOD_ABOUT : "ABT",
|
|
|
|
RelLib.Date.MOD_BEFORE : "BEF",
|
|
|
|
RelLib.Date.MOD_AFTER : "AFT",
|
2002-12-29 11:14:35 +05:30
|
|
|
}
|
|
|
|
|
2006-04-06 07:12:14 +05:30
|
|
|
|
|
|
|
lds_ord_name = {
|
|
|
|
RelLib.LdsOrd.BAPTISM : 'BAPL',
|
|
|
|
RelLib.LdsOrd.ENDOWMENT : 'ENDL',
|
|
|
|
RelLib.LdsOrd.SEAL_TO_PARENTS : 'SLGC',
|
|
|
|
RelLib.LdsOrd.SEAL_TO_SPOUSE : 'SGLS',
|
2006-06-14 05:21:24 +05:30
|
|
|
RelLib.LdsOrd.CONFIRMATION : 'CONL',
|
2006-04-06 07:12:14 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
lds_status = {
|
|
|
|
RelLib.LdsOrd.STATUS_BIC : "BIC",
|
|
|
|
RelLib.LdsOrd.STATUS_CANCELED : "CANCELED",
|
|
|
|
RelLib.LdsOrd.STATUS_CHILD : "CHILD",
|
|
|
|
RelLib.LdsOrd.STATUS_CLEARED : "CLEARED",
|
|
|
|
RelLib.LdsOrd.STATUS_COMPLETED : "COMPLETED",
|
|
|
|
RelLib.LdsOrd.STATUS_DNS : "DNS",
|
|
|
|
RelLib.LdsOrd.STATUS_INFANT : "INFANT",
|
|
|
|
RelLib.LdsOrd.STATUS_PRE_1970 : "PRE-1970",
|
|
|
|
RelLib.LdsOrd.STATUS_QUALIFIED : "QUALIFIED",
|
|
|
|
RelLib.LdsOrd.STATUS_DNS_CAN : "DNS/CAN",
|
|
|
|
RelLib.LdsOrd.STATUS_STILLBORN : "STILLBORN",
|
|
|
|
RelLib.LdsOrd.STATUS_SUBMITTED : "SUBMITTED" ,
|
|
|
|
RelLib.LdsOrd.STATUS_UNCLEARED : "UNCLEARED",
|
|
|
|
}
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-12-30 06:12:47 +05:30
|
|
|
_get_int = re.compile('([0-9]+)')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
mime2ged = {
|
|
|
|
"image/bmp" : "bmp",
|
|
|
|
"image/gif" : "gif",
|
|
|
|
"image/jpeg" : "jpeg",
|
|
|
|
"image/x-pcx" : "pcx",
|
|
|
|
"image/tiff" : "tiff",
|
|
|
|
"audio/x-wav" : "wav"
|
|
|
|
}
|
2006-06-17 00:08:06 +05:30
|
|
|
|
|
|
|
quay_map = {
|
|
|
|
RelLib.SourceRef.CONF_VERY_HIGH : 3,
|
|
|
|
RelLib.SourceRef.CONF_HIGH : 2,
|
|
|
|
RelLib.SourceRef.CONF_LOW : 1,
|
|
|
|
RelLib.SourceRef.CONF_VERY_LOW : 0,
|
|
|
|
}
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def addr_append(text,data):
|
|
|
|
if data:
|
|
|
|
return "%s, %s" % (text,data)
|
|
|
|
else:
|
|
|
|
return text
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-07-12 05:23:02 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def sort_by_gramps_id(first,second):
|
|
|
|
fid = first.get_gramps_id()
|
|
|
|
sid = second.get_gramps_id()
|
|
|
|
|
|
|
|
if fid == sid:
|
|
|
|
return 0
|
|
|
|
elif fid < sid:
|
|
|
|
return -1
|
|
|
|
else:
|
|
|
|
return 1
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-09-17 09:00:04 +05:30
|
|
|
def make_date(subdate,calendar,mode):
|
2002-10-20 19:55:16 +05:30
|
|
|
retval = ""
|
2004-09-17 09:00:04 +05:30
|
|
|
(day,mon,year,sl) = subdate
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-09-17 09:00:04 +05:30
|
|
|
(mmap,prefix) = _calmap.get(calendar,(_month,""))
|
2004-10-16 10:40:35 +05:30
|
|
|
|
|
|
|
if year < 0:
|
|
|
|
year = -year
|
|
|
|
bc = " B.C."
|
|
|
|
else:
|
|
|
|
bc = ""
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-09-17 09:00:04 +05:30
|
|
|
if day == 0:
|
2002-10-20 19:55:16 +05:30
|
|
|
try:
|
2004-09-17 09:00:04 +05:30
|
|
|
if mon == 0:
|
2004-10-16 10:40:35 +05:30
|
|
|
retval = '%d%s' % (year,bc)
|
2004-09-17 09:00:04 +05:30
|
|
|
elif year == 0:
|
2002-12-29 11:14:35 +05:30
|
|
|
retval = '(%s)' % mmap[mon]
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-10-16 10:40:35 +05:30
|
|
|
retval = "%s %d%s" % (mmap[mon],year,bc)
|
2002-10-20 19:55:16 +05:30
|
|
|
except IndexError:
|
|
|
|
print "Month index error - %d" % mon
|
2004-10-16 10:40:35 +05:30
|
|
|
retval = '%d%s' % (year,bc)
|
2004-09-17 09:00:04 +05:30
|
|
|
elif mon == 0:
|
2004-10-16 10:40:35 +05:30
|
|
|
retval = '%d%s' % (year,bc)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
try:
|
|
|
|
month = mmap[mon]
|
2004-09-17 09:00:04 +05:30
|
|
|
if year == 0:
|
2002-12-29 11:14:35 +05:30
|
|
|
retval = "(%d %s)" % (day,month)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-10-16 10:40:35 +05:30
|
|
|
retval = "%d %s %d%s" % (day,month,year,bc)
|
2002-10-20 19:55:16 +05:30
|
|
|
except IndexError:
|
|
|
|
print "Month index error - %d" % mon
|
2004-10-16 10:40:35 +05:30
|
|
|
retval = "%d%s" % (year,bc)
|
2002-12-29 11:14:35 +05:30
|
|
|
|
|
|
|
if prefix:
|
|
|
|
retval = "%s %s" % (prefix, retval)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-12-29 11:14:35 +05:30
|
|
|
if _caldef.has_key(mode):
|
|
|
|
retval = "%s %s" % (_caldef[mode],retval)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-06-10 05:29:03 +05:30
|
|
|
return retval
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def writeData(database,person):
|
2006-03-05 10:01:24 +05:30
|
|
|
GedcomWriter(database,person)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-07-11 11:33:07 +05:30
|
|
|
class GedcomWriterOptionBox:
|
|
|
|
"""
|
|
|
|
Create a VBox with the option widgets and define methods to retrieve
|
|
|
|
the options.
|
|
|
|
"""
|
|
|
|
def __init__(self,person):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.person = person
|
2004-07-11 11:33:07 +05:30
|
|
|
|
|
|
|
def get_option_box(self):
|
2005-01-16 09:30:35 +05:30
|
|
|
self.restrict = True
|
|
|
|
self.private = True
|
2007-01-27 11:00:15 +05:30
|
|
|
self.cnvtxt = keep_utf8
|
2003-01-15 10:55:50 +05:30
|
|
|
self.adopt = GedcomInfo.ADOPT_EVENT
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
glade_file = "%s/gedcomexport.glade" % os.path.dirname(__file__)
|
2004-08-01 09:51:31 +05:30
|
|
|
if not os.path.isfile(glade_file):
|
|
|
|
glade_file = "plugins/gedcomexport.glade"
|
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
self.topDialog = gtk.glade.XML(glade_file,"gedcomExport","gramps")
|
|
|
|
self.topDialog.signal_autoconnect({
|
2003-05-21 02:01:16 +05:30
|
|
|
"gnu_free" : self.gnu_free,
|
|
|
|
"standard_copyright" : self.standard_copyright,
|
|
|
|
"no_copyright" : self.no_copyright,
|
2004-07-13 02:59:15 +05:30
|
|
|
"ansel" : self.ansel,
|
|
|
|
"ansi" : self.ansi,
|
|
|
|
"unicode" : self.uncd,
|
2003-07-22 15:44:49 +05:30
|
|
|
"on_restrict_toggled": self.on_restrict_toggled,
|
2003-05-21 02:01:16 +05:30
|
|
|
})
|
|
|
|
|
2007-01-27 11:00:15 +05:30
|
|
|
self.topDialog.get_widget("encoding").set_history(1)
|
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
filter_obj = self.topDialog.get_widget("filter")
|
|
|
|
self.copy = 0
|
2003-01-08 10:28:00 +05:30
|
|
|
|
2006-05-03 06:32:54 +05:30
|
|
|
all = GenericFilter()
|
2004-07-11 11:33:07 +05:30
|
|
|
all.set_name(_("Entire Database"))
|
2006-05-03 11:59:07 +05:30
|
|
|
all.add_rule(Rules.Person.Everyone([]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-10-08 07:35:17 +05:30
|
|
|
the_filters = [all]
|
|
|
|
|
2005-07-09 01:54:54 +05:30
|
|
|
if self.person:
|
2006-05-03 06:32:54 +05:30
|
|
|
des = GenericFilter()
|
2005-07-09 01:54:54 +05:30
|
|
|
des.set_name(_("Descendants of %s") %
|
2007-06-28 11:11:40 +05:30
|
|
|
name_displayer.display(self.person))
|
2006-05-03 11:59:07 +05:30
|
|
|
des.add_rule(Rules.Person.IsDescendantOf(
|
2005-07-09 01:54:54 +05:30
|
|
|
[self.person.get_gramps_id(),1]))
|
|
|
|
|
2006-05-03 06:32:54 +05:30
|
|
|
ans = GenericFilter()
|
2005-07-09 01:54:54 +05:30
|
|
|
ans.set_name(_("Ancestors of %s")
|
2007-06-28 11:11:40 +05:30
|
|
|
% name_displayer.display(self.person))
|
2006-05-03 11:59:07 +05:30
|
|
|
ans.add_rule(Rules.Person.IsAncestorOf(
|
2005-07-09 01:54:54 +05:30
|
|
|
[self.person.get_gramps_id(),1]))
|
|
|
|
|
2006-05-03 06:32:54 +05:30
|
|
|
com = GenericFilter()
|
2005-07-09 01:54:54 +05:30
|
|
|
com.set_name(_("People with common ancestor with %s") %
|
2007-06-28 11:11:40 +05:30
|
|
|
name_displayer.display(self.person))
|
2006-05-03 11:59:07 +05:30
|
|
|
com.add_rule(Rules.Person.HasCommonAncestorWith(
|
2005-07-09 01:54:54 +05:30
|
|
|
[self.person.get_gramps_id()]))
|
|
|
|
|
2006-10-08 07:35:17 +05:30
|
|
|
the_filters += [des,ans,com]
|
|
|
|
|
|
|
|
from Filters import CustomFilters
|
|
|
|
the_filters.extend(CustomFilters.get_filters('Person'))
|
|
|
|
self.filter_menu = build_filter_menu(the_filters)
|
2004-07-11 11:33:07 +05:30
|
|
|
filter_obj.set_menu(self.filter_menu)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
gedmap = GedcomInfo.GedcomInfoDB()
|
2003-11-03 17:28:15 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
target_obj = self.topDialog.get_widget("target")
|
|
|
|
myMenu = gtk.Menu()
|
|
|
|
for name in gedmap.get_name_list():
|
|
|
|
menuitem = gtk.MenuItem(name)
|
|
|
|
myMenu.append(menuitem)
|
|
|
|
data = gedmap.get_description(name)
|
|
|
|
menuitem.set_data("data",data)
|
|
|
|
menuitem.show()
|
|
|
|
|
|
|
|
target_obj.set_menu(myMenu)
|
|
|
|
self.target_menu = myMenu
|
|
|
|
|
|
|
|
the_box = self.topDialog.get_widget('vbox1')
|
|
|
|
the_parent = self.topDialog.get_widget('dialog-vbox1')
|
|
|
|
the_parent.remove(the_box)
|
|
|
|
self.topDialog.get_widget("gedcomExport").destroy()
|
|
|
|
return the_box
|
2003-05-21 02:01:16 +05:30
|
|
|
|
2003-02-12 09:55:27 +05:30
|
|
|
def gnu_free(self,obj):
|
|
|
|
self.copy = 1
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-02-12 09:55:27 +05:30
|
|
|
def standard_copyright(self,obj):
|
|
|
|
self.copy = 0
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-02-12 09:55:27 +05:30
|
|
|
def no_copyright(self,obj):
|
|
|
|
self.copy = 2
|
2003-07-22 15:44:49 +05:30
|
|
|
|
2004-07-13 02:59:15 +05:30
|
|
|
def ansel(self,obj):
|
|
|
|
self.cnvtxt = ansel_utf8.utf8_to_ansel
|
|
|
|
|
|
|
|
def uncd(self,obj):
|
|
|
|
self.cnvtxt = keep_utf8
|
|
|
|
|
|
|
|
def ansi(self,obj):
|
|
|
|
self.cnvtxt = iso8859
|
|
|
|
|
2003-07-22 15:44:49 +05:30
|
|
|
def on_restrict_toggled(self,restrict):
|
2003-07-23 19:45:34 +05:30
|
|
|
active = restrict.get_active ()
|
|
|
|
map (lambda x: x.set_sensitive (active),
|
|
|
|
[self.topDialog.get_widget("living"),
|
|
|
|
self.topDialog.get_widget("notes"),
|
|
|
|
self.topDialog.get_widget("sources")])
|
2003-07-22 15:44:49 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
def parse_options(self):
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.restrict = self.topDialog.get_widget("restrict").get_active()
|
2003-07-22 15:44:49 +05:30
|
|
|
self.living = (self.restrict and
|
|
|
|
self.topDialog.get_widget("living").get_active())
|
2003-07-23 19:45:34 +05:30
|
|
|
self.exclnotes = (self.restrict and
|
|
|
|
self.topDialog.get_widget("notes").get_active())
|
|
|
|
self.exclsrcs = (self.restrict and
|
|
|
|
self.topDialog.get_widget("sources").get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.private = self.topDialog.get_widget("private").get_active()
|
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
self.cfilter = self.filter_menu.get_active().get_data("filter")
|
2002-10-20 19:55:16 +05:30
|
|
|
act_tgt = self.target_menu.get_active()
|
|
|
|
|
|
|
|
self.target_ged = act_tgt.get_data("data")
|
2003-11-03 17:28:15 +05:30
|
|
|
self.images = self.topDialog.get_widget ("images").get_active ()
|
|
|
|
if self.images:
|
|
|
|
images_path = self.topDialog.get_widget ("images_path")
|
2003-12-17 21:36:36 +05:30
|
|
|
self.images_path = unicode(images_path.get_text ())
|
2004-07-14 07:14:04 +05:30
|
|
|
else:
|
|
|
|
self.images_path = ""
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.dest = self.target_ged.get_dest()
|
|
|
|
self.adopt = self.target_ged.get_adopt()
|
|
|
|
self.conc = self.target_ged.get_conc()
|
|
|
|
self.altname = self.target_ged.get_alt_name()
|
|
|
|
self.cal = self.target_ged.get_alt_calendar()
|
|
|
|
self.obje = self.target_ged.get_obje()
|
|
|
|
self.resi = self.target_ged.get_resi()
|
2002-12-04 10:28:07 +05:30
|
|
|
self.prefix = self.target_ged.get_prefix()
|
2003-01-03 08:49:50 +05:30
|
|
|
self.source_refs = self.target_ged.get_source_refs()
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-06-29 02:51:13 +05:30
|
|
|
self.nl = self.cnvtxt(self.target_ged.get_endl())
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2006-05-21 09:44:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GedcomWriter class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-16 09:17:58 +05:30
|
|
|
class GedcomWriter(UpdateCallback):
|
2006-03-01 11:46:36 +05:30
|
|
|
def __init__(self,database,person,cl=0,filename="",option_box=None,
|
|
|
|
callback=None):
|
2006-05-16 09:17:58 +05:30
|
|
|
UpdateCallback.__init__(self,callback)
|
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
self.db = database
|
|
|
|
self.person = person
|
|
|
|
self.option_box = option_box
|
|
|
|
self.cl = cl
|
|
|
|
self.filename = filename
|
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
if option_box:
|
|
|
|
setup_func = self.gui_setup
|
2004-07-11 11:33:07 +05:30
|
|
|
else:
|
2006-05-23 05:26:57 +05:30
|
|
|
setup_func = self.cli_setup
|
|
|
|
|
|
|
|
# Run setup, bail out if status is not Ture
|
|
|
|
if not setup_func():
|
|
|
|
return
|
|
|
|
|
|
|
|
self.flist = set()
|
|
|
|
self.slist = set()
|
|
|
|
self.rlist = set()
|
2004-07-11 11:33:07 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
# Collect needed families
|
|
|
|
for handle in list(self.plist):
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
|
|
|
if self.private and person.private:
|
|
|
|
self.plist.remove(handle)
|
|
|
|
for family_handle in person.get_family_handle_list():
|
2006-06-23 00:02:16 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.private and family.private:
|
|
|
|
continue
|
|
|
|
self.flist.add(family_handle)
|
2004-07-11 11:33:07 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
def gui_setup(self):
|
|
|
|
# Get settings from the options store/dialog
|
|
|
|
self.option_box.parse_options()
|
|
|
|
|
|
|
|
self.restrict = self.option_box.restrict
|
|
|
|
self.living = self.option_box.living
|
|
|
|
self.exclnotes = self.option_box.exclnotes
|
|
|
|
self.exclsrcs = self.option_box.exclsrcs
|
|
|
|
self.private = self.option_box.private
|
|
|
|
self.copy = self.option_box.copy
|
|
|
|
self.images = self.option_box.images
|
|
|
|
self.images_path = self.option_box.images_path
|
|
|
|
self.target_ged = self.option_box.target_ged
|
|
|
|
self.dest = self.option_box.dest
|
|
|
|
self.adopt = self.option_box.adopt
|
|
|
|
self.conc = self.option_box.conc
|
|
|
|
self.altname = self.option_box.altname
|
|
|
|
self.cal = self.option_box.cal
|
|
|
|
self.obje = self.option_box.obje
|
|
|
|
self.resi = self.option_box.resi
|
|
|
|
self.prefix = self.option_box.prefix
|
|
|
|
self.source_refs = self.option_box.source_refs
|
|
|
|
self.cnvtxt = self.option_box.cnvtxt
|
|
|
|
self.nl = self.option_box.nl
|
|
|
|
|
2007-02-04 23:07:36 +05:30
|
|
|
if HAVE_CONFIG:
|
|
|
|
show_owner_missing_warning = not Config.get(Config.OWNER_WARN)
|
|
|
|
owner_name_empty = self.db.get_researcher().get_name() == ''
|
|
|
|
|
|
|
|
if show_owner_missing_warning and owner_name_empty:
|
|
|
|
MessageHideDialog(
|
|
|
|
_('Researcher information'),
|
|
|
|
_('A valid GEDCOM file is required to contain researcher '
|
|
|
|
'information. You need to fill these data in the '
|
|
|
|
'Preferences dialog.\n\n'
|
|
|
|
'However, most programs do not require it. You may '
|
|
|
|
'leave this empty if you want.'),Config.OWNER_WARN)
|
2006-08-28 02:34:49 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.option_box.cfilter == None:
|
|
|
|
self.plist = set(self.db.get_person_handles(sort_handles=False))
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
self.plist = set(self.option_box.cfilter.apply(
|
|
|
|
self.db,self.db.get_person_handles(sort_handles=False)))
|
|
|
|
return True
|
|
|
|
except Errors.FilterError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
|
|
|
return False
|
|
|
|
|
|
|
|
def cli_setup(self):
|
|
|
|
# use default settings
|
2003-05-21 02:01:16 +05:30
|
|
|
self.restrict = 0
|
|
|
|
self.private = 0
|
|
|
|
self.copy = 0
|
2004-07-11 05:01:28 +05:30
|
|
|
self.images = 0
|
2003-05-21 02:01:16 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
self.plist = set(self.db.get_person_handles(sort_handles=False))
|
2003-05-21 02:01:16 +05:30
|
|
|
|
|
|
|
gedmap = GedcomInfo.GedcomInfoDB()
|
|
|
|
self.target_ged = gedmap.standard
|
|
|
|
|
|
|
|
self.dest = self.target_ged.get_dest()
|
|
|
|
self.adopt = self.target_ged.get_adopt()
|
|
|
|
self.conc = self.target_ged.get_conc()
|
|
|
|
self.altname = self.target_ged.get_alt_name()
|
|
|
|
self.cal = self.target_ged.get_alt_calendar()
|
|
|
|
self.obje = self.target_ged.get_obje()
|
|
|
|
self.resi = self.target_ged.get_resi()
|
|
|
|
self.prefix = self.target_ged.get_prefix()
|
|
|
|
self.source_refs = self.target_ged.get_source_refs()
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-05-21 02:01:16 +05:30
|
|
|
self.cnvtxt = keep_utf8
|
2003-09-16 07:05:09 +05:30
|
|
|
self.nl = self.cnvtxt(self.target_ged.get_endl())
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
return True
|
2003-05-21 02:01:16 +05:30
|
|
|
|
2003-06-28 23:05:00 +05:30
|
|
|
def writeln(self,text):
|
|
|
|
self.g.write('%s%s' % (text,self.nl))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def export_data(self,filename):
|
2004-07-11 11:33:07 +05:30
|
|
|
|
2003-11-03 17:28:15 +05:30
|
|
|
self.dirname = os.path.dirname (filename)
|
2002-10-20 19:55:16 +05:30
|
|
|
try:
|
|
|
|
self.g = open(filename,"w")
|
|
|
|
except IOError,msg:
|
2003-03-21 09:55:55 +05:30
|
|
|
msg2 = _("Could not create %s") % filename
|
|
|
|
ErrorDialog(msg2,str(msg))
|
2004-07-14 07:14:04 +05:30
|
|
|
return 0
|
2002-10-20 19:55:16 +05:30
|
|
|
except:
|
2003-03-21 09:55:55 +05:30
|
|
|
ErrorDialog(_("Could not create %s") % filename)
|
2004-07-14 07:14:04 +05:30
|
|
|
return 0
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-06-10 05:29:03 +05:30
|
|
|
date = time.ctime(time.time()).split()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-02-07 16:10:56 +05:30
|
|
|
# HEADER
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("0 HEAD")
|
|
|
|
self.writeln("1 SOUR GRAMPS")
|
|
|
|
self.writeln("2 VERS %s" % const.version)
|
|
|
|
self.writeln("2 NAME GRAMPS")
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.dest:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 DEST %s" % self.dest)
|
2004-06-10 05:29:03 +05:30
|
|
|
self.writeln("1 DATE %s %s %s" % (date[2],date[1].upper(),date[4]))
|
2003-01-19 11:55:20 +05:30
|
|
|
if self.cnvtxt == ansel_utf8.utf8_to_ansel:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 CHAR ANSEL")
|
2003-06-25 04:37:14 +05:30
|
|
|
elif self.cnvtxt == iso8859:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 CHAR ANSI")
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 CHAR UTF-8")
|
|
|
|
self.writeln("1 SUBM @SUBM@")
|
|
|
|
self.writeln("1 FILE %s" % filename)
|
2003-02-12 09:55:27 +05:30
|
|
|
self.write_copy()
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 GEDC")
|
|
|
|
self.writeln("2 VERS 5.5")
|
|
|
|
self.writeln('2 FORM LINEAGE-LINKED')
|
2003-02-12 09:55:27 +05:30
|
|
|
self.gnu_fdl()
|
2007-02-07 16:10:56 +05:30
|
|
|
|
|
|
|
# SUBMITTER RECORD
|
2004-02-14 11:10:30 +05:30
|
|
|
owner = self.db.get_researcher()
|
2007-02-07 16:10:56 +05:30
|
|
|
(name,addr,city,stae,ctry,post,phon,mail) = owner.get()
|
|
|
|
if name == '': name = u'Not Provided'
|
|
|
|
if addr == '': addr = u'Not Provided'
|
|
|
|
if city == '': city = u'City (not provided)'
|
|
|
|
if post == '': post = u'Postal code (not provided)'
|
|
|
|
if ctry == '': ctry = u'Country (not provided)'
|
|
|
|
|
|
|
|
self.writeln("0 @SUBM@ SUBM")
|
|
|
|
self.writeln("1 NAME %s" % self.cnvtxt(name))
|
|
|
|
self.writeln("1 ADDR %s" % self.cnvtxt(addr))
|
|
|
|
self.writeln("2 CONT %s, %s" % (self.cnvtxt(city), self.cnvtxt(post)))
|
|
|
|
self.writeln("2 CONT %s" % self.cnvtxt(ctry))
|
|
|
|
self.writeln("2 ADR1 %s" % self.cnvtxt(addr))
|
|
|
|
self.writeln("2 ADR2 %s, %s" % (self.cnvtxt(city), self.cnvtxt(post)))
|
|
|
|
if city != u'City (not provided)':
|
|
|
|
self.writeln("2 CITY %s" % self.cnvtxt(city))
|
|
|
|
if stae != '':
|
|
|
|
self.writeln("2 STAE %s" % self.cnvtxt(stae))
|
|
|
|
if post != u'Postal code (not provided)':
|
|
|
|
self.writeln("2 POST %s" % self.cnvtxt(post))
|
|
|
|
if ctry != u'Country (not provided)':
|
|
|
|
self.writeln("2 CTRY %s" % self.cnvtxt(ctry))
|
|
|
|
if phon != '':
|
|
|
|
self.writeln("1 PHON %s" % self.cnvtxt(phon))
|
|
|
|
if mail != '':
|
|
|
|
self.writeln("1 PHON %s" % self.cnvtxt(mail))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
self.set_total(len(self.plist) + len(self.flist))
|
2006-03-01 11:46:36 +05:30
|
|
|
|
2007-02-07 16:10:56 +05:30
|
|
|
# INDIVIDUAL RECORDS
|
2004-08-22 22:00:43 +05:30
|
|
|
sorted = []
|
2006-05-23 05:26:57 +05:30
|
|
|
for handle in self.plist:
|
|
|
|
person = self.db.get_person_from_handle (handle)
|
2004-10-06 09:12:54 +05:30
|
|
|
data = (person.get_gramps_id (), person)
|
|
|
|
sorted.append (data)
|
2004-08-22 22:00:43 +05:30
|
|
|
sorted.sort()
|
|
|
|
for (gramps_id, person) in sorted:
|
|
|
|
self.write_person(person)
|
2006-03-01 11:46:36 +05:30
|
|
|
self.update()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-02-07 16:10:56 +05:30
|
|
|
# FAM RECORDS
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_families()
|
2007-02-07 16:10:56 +05:30
|
|
|
|
|
|
|
# SOURCE and REPOSITORY RECORDS
|
2003-01-03 08:49:50 +05:30
|
|
|
if self.source_refs:
|
|
|
|
self.write_sources()
|
2006-05-23 05:26:57 +05:30
|
|
|
self.write_repos()
|
2006-05-21 09:44:47 +05:30
|
|
|
|
2007-02-07 16:10:56 +05:30
|
|
|
# TRAILER
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("0 TRLR")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.close()
|
2004-07-14 07:14:04 +05:30
|
|
|
return 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-02-12 09:55:27 +05:30
|
|
|
def write_copy(self):
|
|
|
|
t = time.localtime(time.time())
|
|
|
|
y = t[0]
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-02-12 09:55:27 +05:30
|
|
|
if self.copy == 0:
|
2004-02-14 11:10:30 +05:30
|
|
|
o = self.db.get_researcher().get_name()
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 COPR Copyright (c) %d %s.' % (y,o))
|
2003-02-12 09:55:27 +05:30
|
|
|
elif self.copy == 1:
|
2004-02-14 11:10:30 +05:30
|
|
|
o = self.db.get_researcher().get_name()
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln('1 COPR Copyright (c) %d %s. '
|
|
|
|
'See additional copyright NOTE below.' % (y,o))
|
2003-02-12 09:55:27 +05:30
|
|
|
|
|
|
|
def gnu_fdl(self):
|
|
|
|
if self.copy != 1:
|
|
|
|
return
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-02-12 09:55:27 +05:30
|
|
|
t = time.localtime(time.time())
|
|
|
|
y = t[0]
|
2004-02-14 11:10:30 +05:30
|
|
|
o = self.db.get_researcher().get_name()
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 NOTE Copyright (c) %d %s.' % (y,o))
|
2003-02-12 09:55:27 +05:30
|
|
|
try:
|
|
|
|
f = open(const.fdl,"r")
|
|
|
|
for line in f.readlines():
|
|
|
|
self.g.write('2 CONT %s' % line)
|
|
|
|
f.close()
|
|
|
|
except:
|
|
|
|
pass
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_families(self):
|
2004-08-23 04:41:30 +05:30
|
|
|
sorted = []
|
2006-05-23 05:26:57 +05:30
|
|
|
for family_handle in self.flist:
|
2004-08-11 22:30:38 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2006-05-23 05:26:57 +05:30
|
|
|
data = (family.get_gramps_id(), family_handle, family)
|
2004-10-06 09:12:54 +05:30
|
|
|
sorted.append (data)
|
2004-08-23 04:41:30 +05:30
|
|
|
sorted.sort ()
|
|
|
|
for (gramps_id, family_handle, family) in sorted:
|
2002-10-20 19:55:16 +05:30
|
|
|
father_alive = mother_alive = 0
|
2004-08-23 04:41:30 +05:30
|
|
|
self.writeln("0 @%s@ FAM" % gramps_id)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.frefn(family)
|
2004-07-28 07:59:07 +05:30
|
|
|
person_handle = family.get_father_handle()
|
2006-05-23 05:26:57 +05:30
|
|
|
if (person_handle != None) and (person_handle in self.plist):
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_handle(person_handle)
|
2004-07-13 09:51:05 +05:30
|
|
|
gramps_id = person.get_gramps_id()
|
|
|
|
self.writeln("1 HUSB @%s@" % gramps_id)
|
2004-10-08 09:29:55 +05:30
|
|
|
father_alive = Utils.probably_alive(person,self.db)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
person_handle = family.get_mother_handle()
|
2006-05-23 05:26:57 +05:30
|
|
|
if (person_handle != None) and (person_handle in self.plist):
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_handle(person_handle)
|
2004-07-13 09:51:05 +05:30
|
|
|
gramps_id = person.get_gramps_id()
|
|
|
|
self.writeln("1 WIFE @%s@" % gramps_id)
|
2004-10-08 09:29:55 +05:30
|
|
|
mother_alive = Utils.probably_alive(person,self.db)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if not self.restrict or ( not father_alive and not mother_alive ):
|
2006-05-24 10:58:33 +05:30
|
|
|
for lds_ord in family.get_lds_ord_list():
|
|
|
|
self.write_ord(lds_ord,1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-02 10:02:37 +05:30
|
|
|
for event_ref in family.get_event_ref_list():
|
|
|
|
event_handle = event_ref.ref
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
event = self.db.get_event_from_handle(event_handle)
|
2005-03-10 04:29:24 +05:30
|
|
|
if not event or self.private and event.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2006-06-07 10:13:18 +05:30
|
|
|
|
|
|
|
etype = int(event.get_type())
|
|
|
|
val = GedcomInfo.familyConstantEvents.get(etype)
|
|
|
|
|
|
|
|
if val == None:
|
|
|
|
val = self.target_ged.gramps2tag(etype)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
if val:
|
2006-05-23 05:26:57 +05:30
|
|
|
if (not event.get_date_object().is_empty()) \
|
|
|
|
or event.get_place_handle():
|
2005-12-06 12:08:09 +05:30
|
|
|
self.writeln("1 %s" % self.cnvtxt(val))
|
|
|
|
else:
|
|
|
|
self.writeln("1 %s Y" % self.cnvtxt(val))
|
2006-06-07 10:13:18 +05:30
|
|
|
|
|
|
|
if event.get_type() == RelLib.EventType.MARRIAGE:
|
|
|
|
ftype = family.get_relationship()
|
2006-06-24 09:58:43 +05:30
|
|
|
if ftype != RelLib.FamilyRelType.MARRIED and \
|
|
|
|
str(ftype).strip() != "":
|
2006-06-07 10:13:18 +05:30
|
|
|
self.writeln("2 TYPE %s" % str(ftype))
|
2006-06-24 09:58:43 +05:30
|
|
|
elif event.get_description().strip() != "":
|
2005-12-06 12:08:09 +05:30
|
|
|
self.writeln("2 TYPE %s" % event.get_description())
|
2004-07-14 07:14:04 +05:30
|
|
|
else:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.writeln("1 EVEN")
|
2006-08-23 08:44:06 +05:30
|
|
|
the_type = str(event.get_type())
|
2006-06-24 09:58:43 +05:30
|
|
|
if the_type:
|
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(the_type))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2006-08-16 08:01:29 +05:30
|
|
|
self.dump_event_stats(event, event_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-05-02 02:41:26 +05:30
|
|
|
for attr in family.get_attribute_list():
|
|
|
|
if self.private and attr.get_privacy():
|
|
|
|
continue
|
2006-06-07 10:13:18 +05:30
|
|
|
|
|
|
|
t = int(attr.get_type())
|
|
|
|
name = GedcomInfo.familyConstantAttributes.get(t)
|
2006-05-10 02:06:12 +05:30
|
|
|
value = self.cnvtxt(attr.get_value()).replace('\r',' ')
|
2006-06-07 10:13:18 +05:30
|
|
|
|
2006-06-24 09:58:43 +05:30
|
|
|
if name and name.strip():
|
2006-05-10 02:06:12 +05:30
|
|
|
self.writeln("1 %s %s" % (name,value))
|
2006-05-02 02:41:26 +05:30
|
|
|
continue
|
2006-06-07 10:13:18 +05:30
|
|
|
else:
|
2006-10-31 21:45:21 +05:30
|
|
|
the_name = str(attr.get_type())
|
2006-05-10 02:06:12 +05:30
|
|
|
self.writeln("1 EVEN")
|
2006-05-02 02:41:26 +05:30
|
|
|
if value:
|
2006-10-31 21:45:21 +05:30
|
|
|
self.writeln("2 TYPE %s %s" %(self.cnvtxt(the_name),
|
|
|
|
value))
|
2006-05-02 02:41:26 +05:30
|
|
|
else:
|
2006-10-31 21:45:21 +05:30
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(the_name))
|
2006-05-10 02:06:12 +05:30
|
|
|
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in attr.get_note_list():
|
|
|
|
self.write_long_text("NOTE",2,self.cnvtxt(note))
|
2006-05-02 02:41:26 +05:30
|
|
|
for srcref in attr.get_source_references():
|
|
|
|
self.write_source_ref(2,srcref)
|
|
|
|
|
2006-05-10 02:06:12 +05:30
|
|
|
for child_ref in family.get_child_ref_list():
|
2006-05-23 05:26:57 +05:30
|
|
|
if child_ref.ref not in self.plist:
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2006-05-10 02:06:12 +05:30
|
|
|
person = self.db.get_person_from_handle(child_ref.ref)
|
2005-05-24 18:38:06 +05:30
|
|
|
if not person:
|
|
|
|
continue
|
2004-07-13 09:51:05 +05:30
|
|
|
self.writeln("1 CHIL @%s@" % person.get_gramps_id())
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.adopt == GedcomInfo.ADOPT_FTW:
|
2006-05-23 05:26:57 +05:30
|
|
|
if person.get_main_parents_family_handle() \
|
|
|
|
== family.get_handle():
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('2 _FREL Natural')
|
|
|
|
self.writeln('2 _MREL Natural')
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2006-05-10 02:06:12 +05:30
|
|
|
if family.get_handle() in \
|
|
|
|
person.get_parent_family_handle_list():
|
|
|
|
for child_ref in family.get_child_ref_list():
|
|
|
|
if child_ref.ref == person.handle:
|
|
|
|
self.writeln('2 _FREL %s' %
|
|
|
|
child_ref.frel.xml_str())
|
|
|
|
self.writeln('2 _MREL %s' %
|
|
|
|
child_ref.mrel.xml_str())
|
|
|
|
break
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.adopt == GedcomInfo.ADOPT_LEGACY:
|
2006-05-10 02:06:12 +05:30
|
|
|
if family.get_handle() in \
|
|
|
|
person.get_parent_family_handle_list():
|
2006-05-18 08:44:55 +05:30
|
|
|
self.writeln('2 _STAT %s' % child_ref.mrel.xml_str())
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2005-07-09 01:54:54 +05:30
|
|
|
for srcref in family.get_source_references():
|
|
|
|
self.write_source_ref(1,srcref)
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.images:
|
|
|
|
photos = family.get_media_list ()
|
|
|
|
for photo in photos:
|
|
|
|
if self.private and photo.get_privacy():
|
|
|
|
continue
|
|
|
|
self.write_photo(photo,1)
|
|
|
|
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in family.get_note_list():
|
|
|
|
self.write_long_text("NOTE",1,self.cnvtxt(note))
|
2006-05-02 02:41:26 +05:30
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
self.write_change(1,family.get_change_time())
|
2006-03-01 11:46:36 +05:30
|
|
|
self.update()
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_sources(self):
|
2004-08-23 16:56:24 +05:30
|
|
|
sorted = []
|
2006-05-23 05:26:57 +05:30
|
|
|
for handle in self.slist:
|
2005-07-09 01:54:54 +05:30
|
|
|
source = self.db.get_source_from_handle(handle)
|
2005-05-24 18:38:06 +05:30
|
|
|
if not source:
|
|
|
|
continue
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.private and source.private:
|
|
|
|
continue
|
|
|
|
data = (source.get_gramps_id(), source)
|
2004-10-06 09:12:54 +05:30
|
|
|
sorted.append (data)
|
2004-08-23 16:56:24 +05:30
|
|
|
sorted.sort ()
|
2006-05-23 05:26:57 +05:30
|
|
|
|
2004-08-23 16:56:24 +05:30
|
|
|
for (source_id, source) in sorted:
|
|
|
|
self.writeln("0 @%s@ SOUR" % source_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_title():
|
2006-05-02 02:41:26 +05:30
|
|
|
self.write_long_text('TITL',1,
|
|
|
|
"%s" % self.cnvtxt(source.get_title()))
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_author():
|
2006-05-02 02:41:26 +05:30
|
|
|
self.write_long_text("AUTH", 1,
|
|
|
|
"%s" % self.cnvtxt(source.get_author()))
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_publication_info():
|
2006-05-02 02:41:26 +05:30
|
|
|
self.write_long_text("PUBL", 1,"%s" % self.cnvtxt(
|
|
|
|
source.get_publication_info()))
|
|
|
|
|
2004-06-10 05:29:03 +05:30
|
|
|
if source.get_abbreviation():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("1 ABBR %s" %
|
|
|
|
self.cnvtxt(source.get_abbreviation()))
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.images:
|
|
|
|
photos = source.get_media_list ()
|
|
|
|
for photo in photos:
|
|
|
|
if self.private and photo.get_privacy():
|
|
|
|
continue
|
|
|
|
self.write_photo(photo,1)
|
|
|
|
|
2006-05-22 05:02:34 +05:30
|
|
|
for reporef in source.get_reporef_list():
|
|
|
|
self.write_reporef(reporef,1)
|
|
|
|
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in source.get_note_list():
|
|
|
|
self.write_long_text("NOTE",1,self.cnvtxt(note))
|
2004-08-24 09:18:15 +05:30
|
|
|
self.write_change(1,source.get_change_time())
|
|
|
|
|
2006-05-21 09:44:47 +05:30
|
|
|
def write_repos(self):
|
2006-05-22 05:02:34 +05:30
|
|
|
sorted = []
|
|
|
|
for handle in self.rlist:
|
|
|
|
repo = self.db.get_repository_from_handle(handle)
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.private and repo.private:
|
|
|
|
continue
|
2006-05-22 05:02:34 +05:30
|
|
|
repo_id = repo.get_gramps_id()
|
2006-05-23 05:26:57 +05:30
|
|
|
sorted.append((repo_id,repo))
|
2006-05-22 05:02:34 +05:30
|
|
|
|
|
|
|
sorted.sort()
|
2006-05-23 05:26:57 +05:30
|
|
|
|
|
|
|
slist = set()
|
2006-05-22 05:02:34 +05:30
|
|
|
|
|
|
|
for (repo_id,repo) in sorted:
|
|
|
|
self.writeln("0 @%s@ REPO" % repo_id)
|
|
|
|
if repo.get_name():
|
|
|
|
self.write_long_text('NAME',1,
|
|
|
|
"%s" % self.cnvtxt(repo.get_name()))
|
|
|
|
for addr in repo.get_address_list():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.write_long_text("ADDR",1,
|
|
|
|
self.cnvtxt(addr.get_street()))
|
|
|
|
if addr.get_city():
|
|
|
|
self.writeln("2 CITY %s"
|
|
|
|
% self.cnvtxt(addr.get_city()))
|
|
|
|
if addr.get_state():
|
|
|
|
self.writeln("2 STAE %s"
|
|
|
|
% self.cnvtxt(addr.get_state()))
|
|
|
|
if addr.get_postal_code():
|
|
|
|
self.writeln("2 POST %s"
|
|
|
|
% self.cnvtxt(addr.get_postal_code()))
|
|
|
|
if addr.get_country():
|
|
|
|
self.writeln("2 CTRY %s"
|
|
|
|
% self.cnvtxt(addr.get_country()))
|
|
|
|
if addr.get_phone():
|
|
|
|
self.writeln("1 PHON %s"
|
|
|
|
% self.cnvtxt(addr.get_phone()))
|
|
|
|
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in repo.get_note_list():
|
|
|
|
self.write_long_text("NOTE",1,self.cnvtxt(note))
|
2006-05-22 05:02:34 +05:30
|
|
|
|
|
|
|
def write_reporef(self,reporef,level):
|
2006-05-23 05:26:57 +05:30
|
|
|
|
2006-05-22 05:02:34 +05:30
|
|
|
if reporef.ref == None:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Append handle to the list for exporting REPOs later
|
|
|
|
self.rlist.add(reporef.ref)
|
|
|
|
|
|
|
|
repo = self.db.get_repository_from_handle(reporef.ref)
|
|
|
|
repo_id = repo.get_gramps_id()
|
|
|
|
|
|
|
|
self.writeln("%d REPO @%s@" % (level,repo_id) )
|
|
|
|
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in reporef.get_note_list():
|
2006-05-22 05:02:34 +05:30
|
|
|
self.write_long_text("NOTE",level+1,
|
2007-04-18 07:42:40 +05:30
|
|
|
self.cnvtxt(note))
|
2006-05-22 05:02:34 +05:30
|
|
|
|
|
|
|
if reporef.get_call_number():
|
|
|
|
self.writeln("%d CALN %s" %
|
|
|
|
( (level+1), reporef.get_call_number() ) )
|
|
|
|
if reporef.get_media_type():
|
|
|
|
self.writeln("%d MEDI %s" %
|
|
|
|
((level+2),
|
|
|
|
self.cnvtxt(str(reporef.get_media_type()))))
|
|
|
|
|
2006-05-21 09:44:47 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_person(self,person):
|
2004-07-13 09:51:05 +05:30
|
|
|
self.writeln("0 @%s@ INDI" % person.get_gramps_id())
|
2004-10-11 04:52:12 +05:30
|
|
|
restricted = self.restrict and Utils.probably_alive (person,self.db)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.prefn(person)
|
2004-02-14 11:10:30 +05:30
|
|
|
primaryname = person.get_primary_name ()
|
2006-05-06 02:46:24 +05:30
|
|
|
nickname = ""
|
2003-07-22 15:44:49 +05:30
|
|
|
if restricted and self.living:
|
|
|
|
primaryname = RelLib.Name (primaryname)
|
2004-02-14 11:10:30 +05:30
|
|
|
primaryname.set_first_name ("Living")
|
2006-05-06 02:46:24 +05:30
|
|
|
#nickname = ""
|
2003-07-22 15:44:49 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
primaryname = person.get_primary_name ()
|
2006-05-06 02:46:24 +05:30
|
|
|
#nickname = person.get_nick_name ()
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-07-23 19:45:34 +05:30
|
|
|
if restricted and self.exclnotes:
|
|
|
|
primaryname = RelLib.Name (primaryname)
|
2007-04-18 07:42:40 +05:30
|
|
|
primaryname.set_note_list ([])
|
2003-07-23 19:45:34 +05:30
|
|
|
|
|
|
|
if restricted and self.exclsrcs:
|
|
|
|
primaryname = RelLib.Name (primaryname)
|
2004-02-14 11:10:30 +05:30
|
|
|
primaryname.set_source_reference_list ([])
|
2003-07-23 19:45:34 +05:30
|
|
|
|
2003-07-22 15:44:49 +05:30
|
|
|
self.write_person_name(primaryname, nickname)
|
|
|
|
|
|
|
|
if (self.altname == GedcomInfo.ALT_NAME_STD and
|
|
|
|
not (restricted and self.living)):
|
2004-02-14 11:10:30 +05:30
|
|
|
for name in person.get_alternate_names():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_person_name(name,"")
|
|
|
|
|
2005-05-31 02:11:43 +05:30
|
|
|
if person.get_gender() == RelLib.Person.MALE:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 SEX M")
|
2005-05-31 02:11:43 +05:30
|
|
|
elif person.get_gender() == RelLib.Person.FEMALE:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 SEX F")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-07-22 15:44:49 +05:30
|
|
|
if not restricted:
|
2006-03-02 10:02:37 +05:30
|
|
|
birth_ref = person.get_birth_ref()
|
|
|
|
if birth_ref:
|
|
|
|
birth = self.db.get_event_from_handle(birth_ref.ref)
|
|
|
|
if not (self.private and birth.get_privacy()):
|
2006-05-23 05:26:57 +05:30
|
|
|
if (not birth.get_date_object().is_empty()) \
|
|
|
|
or birth.get_place_handle():
|
2006-03-02 10:02:37 +05:30
|
|
|
self.writeln("1 BIRT")
|
|
|
|
else:
|
|
|
|
self.writeln("1 BIRT Y")
|
2006-06-24 09:58:43 +05:30
|
|
|
if birth.get_description().strip() != "":
|
2006-03-02 10:02:37 +05:30
|
|
|
self.writeln("2 TYPE %s" % birth.get_description())
|
2006-08-16 08:01:29 +05:30
|
|
|
self.dump_event_stats(birth, birth_ref)
|
2006-03-02 10:02:37 +05:30
|
|
|
|
|
|
|
death_ref = person.get_death_ref()
|
|
|
|
if death_ref:
|
|
|
|
death = self.db.get_event_from_handle(death_ref.ref)
|
|
|
|
if not (self.private and death.get_privacy()):
|
2006-05-23 05:26:57 +05:30
|
|
|
if (not death.get_date_object().is_empty()) \
|
|
|
|
or death.get_place_handle():
|
2006-03-02 10:02:37 +05:30
|
|
|
self.writeln("1 DEAT")
|
|
|
|
else:
|
|
|
|
self.writeln("1 DEAT Y")
|
2006-06-24 09:58:43 +05:30
|
|
|
if death.get_description().strip() != "":
|
2006-03-02 10:02:37 +05:30
|
|
|
self.writeln("2 TYPE %s" % death.get_description())
|
2006-08-16 08:01:29 +05:30
|
|
|
self.dump_event_stats(death, death_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
ad = 0
|
|
|
|
|
2006-04-06 07:12:14 +05:30
|
|
|
for lds_ord in person.get_lds_ord_list():
|
|
|
|
self.write_ord(lds_ord,1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-02 10:02:37 +05:30
|
|
|
for event_ref in person.get_event_ref_list():
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
2006-05-25 08:00:16 +05:30
|
|
|
if int(event.get_type()) in (RelLib.EventType.BIRTH,
|
|
|
|
RelLib.EventType.DEATH):
|
|
|
|
continue
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.private and event.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2006-06-07 10:13:18 +05:30
|
|
|
|
|
|
|
etype = int(event.get_type())
|
|
|
|
val = GedcomInfo.personalConstantEvents.get(etype)
|
|
|
|
if val == None:
|
|
|
|
val = self.target_ged.gramps2tag(etype)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.adopt == GedcomInfo.ADOPT_EVENT and val == "ADOP":
|
2002-10-20 19:55:16 +05:30
|
|
|
ad = 1
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 ADOP')
|
2002-10-20 19:55:16 +05:30
|
|
|
fam = None
|
2006-05-10 02:06:12 +05:30
|
|
|
for fh in person.get_parent_family_handle_list():
|
|
|
|
family = self.db.get_family_from_handle(fh)
|
|
|
|
for child_ref in family.get_child_ref_list():
|
|
|
|
if child_ref.ref == person.handle:
|
|
|
|
if \
|
|
|
|
child_ref.mrel == \
|
|
|
|
RelLib.ChildRefType.ADOPTED \
|
|
|
|
or child_ref.frel == \
|
|
|
|
RelLib.ChildRefType.ADOPTED:
|
|
|
|
frel = child_ref.frel
|
|
|
|
mrel = child_ref.mrel
|
|
|
|
fam = family
|
|
|
|
break
|
2002-10-20 19:55:16 +05:30
|
|
|
if fam:
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln('2 FAMC @%s@' % fam.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
if mrel == frel:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP BOTH')
|
2006-05-10 02:06:12 +05:30
|
|
|
elif mrel == RelLib.ChildRefType.ADOPTED:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP WIFE')
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP HUSB')
|
2006-06-24 09:58:43 +05:30
|
|
|
elif val and val.strip():
|
2006-03-21 11:53:45 +05:30
|
|
|
if val in personalAttributeTakesParam:
|
2006-06-24 09:58:43 +05:30
|
|
|
if event.get_description().strip():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln(
|
|
|
|
"1 %s %s" %
|
|
|
|
(self.cnvtxt(val),
|
|
|
|
self.cnvtxt(event.get_description())))
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
self.writeln("1 %s" % self.cnvtxt(val))
|
|
|
|
else:
|
2006-05-23 05:26:57 +05:30
|
|
|
if (not event.get_date_object().is_empty()) \
|
|
|
|
or event.get_place_handle():
|
2005-12-06 12:08:09 +05:30
|
|
|
self.writeln("1 %s" % self.cnvtxt(val))
|
|
|
|
else:
|
|
|
|
self.writeln("1 %s Y" % self.cnvtxt(val))
|
2006-06-24 09:58:43 +05:30
|
|
|
if event.get_description().strip():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln(
|
|
|
|
"2 TYPE %s"
|
|
|
|
% self.cnvtxt(event.get_description()))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-12-06 12:08:09 +05:30
|
|
|
# Actually, it is against the spec to put anything
|
|
|
|
# after EVEN on the same line, possibly an option is
|
|
|
|
# needed on how to handle this
|
2006-08-22 08:49:37 +05:30
|
|
|
|
2006-06-24 09:58:43 +05:30
|
|
|
if event.get_description().strip() != "":
|
2006-05-10 02:06:12 +05:30
|
|
|
self.writeln("1 EVEN %s" %
|
2006-05-18 08:44:55 +05:30
|
|
|
self.cnvtxt(event.get_description()))
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
self.writeln("1 EVEN")
|
2006-06-24 09:58:43 +05:30
|
|
|
if val.strip():
|
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(val))
|
2006-08-22 08:49:37 +05:30
|
|
|
else:
|
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(str(event.get_type())))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-08-16 08:01:29 +05:30
|
|
|
self.dump_event_stats(event, event_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
if (self.adopt == GedcomInfo.ADOPT_EVENT) and (ad == 0) \
|
|
|
|
and (len(person.get_parent_family_handle_list()) != 0):
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 ADOP')
|
2002-10-20 19:55:16 +05:30
|
|
|
fam = None
|
2006-05-10 02:06:12 +05:30
|
|
|
for fh in person.get_parent_family_handle_list():
|
|
|
|
family = self.db.get_family_from_handle(fh)
|
|
|
|
for child_ref in family.get_child_ref_list():
|
|
|
|
if child_ref.ref == person.handle:
|
2006-05-23 05:26:57 +05:30
|
|
|
if (child_ref.mrel == RelLib.ChildRefType.ADOPTED)\
|
|
|
|
or (child_ref.frel \
|
|
|
|
== RelLib.ChildRefType.ADOPTED):
|
|
|
|
frel = child_ref.frel
|
|
|
|
mrel = child_ref.mrel
|
|
|
|
fam = family
|
|
|
|
break
|
2002-10-20 19:55:16 +05:30
|
|
|
if fam:
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln('2 FAMC @%s@' % fam.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
if mrel == frel:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP BOTH')
|
2006-05-10 02:06:12 +05:30
|
|
|
elif mrel == RelLib.ChildRefType.ADOPTED:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP WIFE')
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP HUSB')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for attr in person.get_attribute_list():
|
|
|
|
if self.private and attr.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2006-06-07 10:13:18 +05:30
|
|
|
|
|
|
|
t = int(attr.get_type())
|
|
|
|
name = GedcomInfo.personalConstantAttributes.get(t)
|
2006-08-23 09:23:17 +05:30
|
|
|
key = str(attr.get_type())
|
2006-06-24 09:58:43 +05:30
|
|
|
value = self.cnvtxt(attr.get_value().strip()).replace('\r',' ')
|
2006-05-10 02:06:12 +05:30
|
|
|
|
2006-08-23 09:23:17 +05:30
|
|
|
if key in ("AFN", "RFN", "_UID"):
|
|
|
|
self.writeln("1 %s %s" % (name,value))
|
|
|
|
continue
|
|
|
|
|
|
|
|
if key == "RESN":
|
|
|
|
self.writeln("1 RESN")
|
|
|
|
continue
|
2006-06-07 10:13:18 +05:30
|
|
|
|
2006-06-24 09:58:43 +05:30
|
|
|
if name and name.strip():
|
2006-05-10 02:06:12 +05:30
|
|
|
self.writeln("1 %s %s" % (name,value))
|
2006-06-07 10:13:18 +05:30
|
|
|
else:
|
2006-05-10 02:06:12 +05:30
|
|
|
self.writeln("1 EVEN")
|
2005-07-09 01:54:54 +05:30
|
|
|
if value:
|
2006-11-28 07:46:15 +05:30
|
|
|
self.writeln("2 TYPE %s %s" %(self.cnvtxt(key),value))
|
2005-07-09 01:54:54 +05:30
|
|
|
else:
|
2006-11-28 07:46:15 +05:30
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(key))
|
2006-05-10 02:06:12 +05:30
|
|
|
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in attr.get_note_list():
|
|
|
|
self.write_long_text("NOTE", 2, self.cnvtxt(note))
|
2004-02-14 11:10:30 +05:30
|
|
|
for srcref in attr.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_source_ref(2,srcref)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for addr in person.get_address_list():
|
|
|
|
if self.private and addr.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 RESI")
|
2004-02-14 11:10:30 +05:30
|
|
|
self.print_date("2 DATE",addr.get_date_object())
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.resi == 0:
|
2006-05-23 05:26:57 +05:30
|
|
|
self.write_long_text("ADDR",2,
|
|
|
|
self.cnvtxt(addr.get_street()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if addr.get_city():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("3 CITY %s"
|
|
|
|
% self.cnvtxt(addr.get_city()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if addr.get_state():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("3 STAE %s"
|
|
|
|
% self.cnvtxt(addr.get_state()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if addr.get_postal_code():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("3 POST %s"
|
|
|
|
% self.cnvtxt(addr.get_postal_code()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if addr.get_country():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("3 CTRY %s"
|
|
|
|
% self.cnvtxt(addr.get_country()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if addr.get_phone():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("2 PHON %s"
|
|
|
|
% self.cnvtxt(addr.get_phone()))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
text = addr.get_street()
|
|
|
|
text = addr_append(text,addr.get_city())
|
|
|
|
text = addr_append(text,addr.get_state())
|
|
|
|
text = addr_append(text,addr.get_postal_code())
|
|
|
|
text = addr_append(text,addr.get_country())
|
|
|
|
text = addr_append(text,addr.get_phone())
|
2002-10-20 19:55:16 +05:30
|
|
|
if text:
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("2 PLAC %s"
|
|
|
|
% self.cnvtxt(text).replace('\r',' '))
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in addr.get_note_list():
|
|
|
|
self.write_long_text("NOTE", 2, self.cnvtxt(note))
|
2004-02-14 11:10:30 +05:30
|
|
|
for srcref in addr.get_source_references():
|
2003-05-21 03:28:07 +05:30
|
|
|
self.write_source_ref(2,srcref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-11-03 17:28:15 +05:30
|
|
|
if self.images:
|
2004-02-21 11:41:59 +05:30
|
|
|
photos = person.get_media_list ()
|
2005-12-06 12:08:09 +05:30
|
|
|
for photo in photos:
|
|
|
|
if self.private and photo.get_privacy():
|
2004-08-25 08:55:23 +05:30
|
|
|
continue
|
2005-12-06 12:08:09 +05:30
|
|
|
self.write_photo(photo,1)
|
2003-11-03 17:28:15 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
for family_handle in person.get_parent_family_handle_list():
|
|
|
|
if family_handle in self.flist:
|
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
family_id = family.get_gramps_id()
|
|
|
|
self.writeln("1 FAMC @%s@" % family_id)
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.adopt == GedcomInfo.ADOPT_PEDI:
|
2006-05-23 05:26:57 +05:30
|
|
|
# Go over all children of the family to find the ref
|
2006-10-16 09:27:15 +05:30
|
|
|
for child_ref in family.get_child_ref_list():
|
2006-05-23 05:26:57 +05:30
|
|
|
if child_ref.ref == person.handle:
|
|
|
|
if (child_ref.frel ==
|
2006-11-27 08:50:37 +05:30
|
|
|
RelLib.ChildRefType.ADOPTED) \
|
2006-05-23 05:26:57 +05:30
|
|
|
or (child_ref.mrel \
|
2006-11-27 08:50:37 +05:30
|
|
|
== RelLib.ChildRefType.ADOPTED):
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("2 PEDI Adopted")
|
|
|
|
break
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
2006-05-23 05:26:57 +05:30
|
|
|
if (family_handle != None) and (family_handle in self.flist):
|
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
self.writeln("1 FAMS @%s@" % family.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-07-09 01:54:54 +05:30
|
|
|
for srcref in person.get_source_references():
|
|
|
|
self.write_source_ref(1,srcref)
|
|
|
|
|
2003-07-22 15:44:49 +05:30
|
|
|
if not restricted:
|
|
|
|
if self.obje:
|
2004-02-14 11:10:30 +05:30
|
|
|
for url in person.get_url_list():
|
2005-07-09 01:54:54 +05:30
|
|
|
if self.private and url.get_privacy():
|
|
|
|
continue
|
2003-07-22 15:44:49 +05:30
|
|
|
self.writeln('1 OBJE')
|
|
|
|
self.writeln('2 FORM URL')
|
|
|
|
if url.get_description():
|
|
|
|
self.writeln('2 TITL %s' % url.get_description())
|
|
|
|
if url.get_path():
|
|
|
|
self.writeln('2 FILE %s' % url.get_path())
|
|
|
|
|
2003-07-23 19:45:34 +05:30
|
|
|
if not restricted or not self.exclnotes:
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in person.get_note_list():
|
|
|
|
self.write_long_text("NOTE", 1, self.cnvtxt(note))
|
2003-07-22 15:44:49 +05:30
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
self.write_change(1,person.get_change_time())
|
|
|
|
|
|
|
|
|
|
|
|
def write_change(self,level,timeval):
|
|
|
|
self.writeln('%d CHAN' % level)
|
|
|
|
time_val = time.localtime(timeval)
|
|
|
|
self.writeln('%d DATE %d %s %d' % (level + 1,time_val[2],
|
|
|
|
_month[time_val[1]],time_val[0]))
|
|
|
|
self.writeln('%d TIME %02d:%02d:%02d' % (level + 2,time_val[3],
|
|
|
|
time_val[4],time_val[5]))
|
|
|
|
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_long_text(self,tag,level,note):
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.conc == GedcomInfo.CONC_OK:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_conc_ok(tag,level,note)
|
|
|
|
else:
|
|
|
|
self.write_conc_broken(tag,level,note)
|
|
|
|
|
|
|
|
def write_conc_ok(self,tag,level,note):
|
|
|
|
prefix = "%d %s" % (level,tag)
|
2004-06-10 05:29:03 +05:30
|
|
|
textlines = note.split('\n')
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(note) == 0:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln(prefix)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
for line in textlines:
|
|
|
|
ll = len(line)
|
2006-05-02 02:41:26 +05:30
|
|
|
if ll == 0:
|
|
|
|
self.writeln("%s " % prefix)
|
|
|
|
prefix = "%d CONT" % (level+1)
|
|
|
|
continue
|
2002-10-20 19:55:16 +05:30
|
|
|
while ll > 0:
|
|
|
|
brkpt = 70
|
|
|
|
if ll > brkpt:
|
2005-03-28 10:28:28 +05:30
|
|
|
while (ll > brkpt and line[brkpt].isspace()):
|
2002-10-20 19:55:16 +05:30
|
|
|
brkpt = brkpt+1
|
|
|
|
if ll == brkpt:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,line))
|
2002-10-20 19:55:16 +05:30
|
|
|
line = ''
|
|
|
|
break
|
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,line[0:brkpt+1]))
|
2002-10-20 19:55:16 +05:30
|
|
|
line = line[brkpt+1:]
|
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,line))
|
2002-10-20 19:55:16 +05:30
|
|
|
line = ""
|
|
|
|
if len(line) > 0:
|
|
|
|
prefix = "%d CONC" % (level+1)
|
|
|
|
else:
|
|
|
|
prefix = "%d CONT" % (level+1)
|
|
|
|
ll = len(line)
|
|
|
|
|
|
|
|
def write_conc_broken(self,tag,level,note):
|
|
|
|
prefix = "%d %s" % (level,tag)
|
2004-06-10 05:29:03 +05:30
|
|
|
textlines = note.split('\n')
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(note) == 0:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln(prefix)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
for line in textlines:
|
|
|
|
ll = len(line)
|
2006-05-02 02:41:26 +05:30
|
|
|
if ll == 0:
|
|
|
|
self.writeln("%s " % prefix)
|
|
|
|
prefix = "%d CONT" % (level+1)
|
|
|
|
continue
|
2002-10-20 19:55:16 +05:30
|
|
|
while ll > 0:
|
|
|
|
brkpt = 70
|
|
|
|
if ll > brkpt:
|
2005-03-28 10:28:28 +05:30
|
|
|
while (ll > brkpt and not line[brkpt].isspace()):
|
2002-10-20 19:55:16 +05:30
|
|
|
brkpt = brkpt+1
|
|
|
|
if ll == brkpt:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,line))
|
2002-10-20 19:55:16 +05:30
|
|
|
line = ''
|
|
|
|
break
|
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,line[0:brkpt+1]))
|
2002-10-20 19:55:16 +05:30
|
|
|
line = line[brkpt+1:]
|
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,line))
|
2002-10-20 19:55:16 +05:30
|
|
|
line = ""
|
|
|
|
if len(line) > 0:
|
|
|
|
prefix = "%d CONC" % (level+1)
|
|
|
|
else:
|
|
|
|
prefix = "%d CONT" % (level+1)
|
|
|
|
ll = len(line)
|
|
|
|
|
2006-08-16 08:01:29 +05:30
|
|
|
def dump_event_stats(self,event, event_ref):
|
2004-02-14 11:10:30 +05:30
|
|
|
dateobj = event.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.print_date("2 DATE",dateobj)
|
2005-12-06 12:08:09 +05:30
|
|
|
place = None
|
2004-07-28 07:59:07 +05:30
|
|
|
if event.get_place_handle():
|
2005-12-06 12:08:09 +05:30
|
|
|
place = self.db.get_place_from_handle(event.get_place_handle())
|
|
|
|
self.write_place(place,2)
|
2006-08-16 08:01:29 +05:30
|
|
|
for attr in event.get_attribute_list():
|
|
|
|
t = attr.get_type()
|
|
|
|
if t == RelLib.AttributeType.CAUSE:
|
|
|
|
self.writeln("2 CAUS %s" % self.cnvtxt(attr.get_value()))
|
|
|
|
elif t == RelLib.AttributeType.AGENCY:
|
|
|
|
self.writeln("2 AGNC %s" % self.cnvtxt(attr.get_value()))
|
|
|
|
for attr in event_ref.get_attribute_list():
|
|
|
|
t = attr.get_type()
|
|
|
|
if t == RelLib.AttributeType.AGE:
|
|
|
|
self.writeln("2 AGE %s" % self.cnvtxt(attr.get_value()))
|
|
|
|
elif t == RelLib.AttributeType.FATHER_AGE:
|
|
|
|
self.writeln("2 HUSB")
|
|
|
|
self.writeln("3 AGE %s" % self.cnvtxt(attr.get_value()))
|
|
|
|
elif t == RelLib.AttributeType.MOTHER_AGE:
|
|
|
|
self.writeln("2 WIFE")
|
|
|
|
self.writeln("3 AGE %s" % self.cnvtxt(attr.get_value()))
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in event.get_note_list():
|
|
|
|
self.write_long_text("NOTE", 2, self.cnvtxt(note))
|
2004-02-14 11:10:30 +05:30
|
|
|
for srcref in event.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_source_ref(2,srcref)
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.images:
|
|
|
|
photos = event.get_media_list()
|
|
|
|
for photo in photos:
|
|
|
|
if self.private and photo.get_privacy():
|
|
|
|
continue
|
|
|
|
self.write_photo(photo,2)
|
|
|
|
if place:
|
|
|
|
for photo in place.get_media_list():
|
|
|
|
if self.private and photo.get_privacy():
|
|
|
|
continue
|
|
|
|
self.write_photo(photo,2)
|
|
|
|
|
2006-04-06 07:12:14 +05:30
|
|
|
def write_ord(self, ord, index):
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.private and ord.private:
|
|
|
|
return
|
2006-04-06 07:12:14 +05:30
|
|
|
self.writeln('%d %s' % (index, lds_ord_name[ord.get_type()]))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.print_date("%d DATE" % (index + 1), ord.get_date_object())
|
2004-07-28 07:59:07 +05:30
|
|
|
if ord.get_family_handle():
|
2006-05-23 05:26:57 +05:30
|
|
|
family_handle = ord.get_family_handle()
|
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
if family:
|
|
|
|
self.writeln('%d FAMC @%s@' % (index+1,family.get_gramps_id()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if ord.get_temple():
|
|
|
|
self.writeln('%d TEMP %s' % (index+1,ord.get_temple()))
|
2004-07-28 07:59:07 +05:30
|
|
|
if ord.get_place_handle():
|
2006-05-23 05:26:57 +05:30
|
|
|
self.write_place(
|
|
|
|
self.db.get_place_from_handle(ord.get_place_handle()),2)
|
2006-04-06 07:12:14 +05:30
|
|
|
if ord.get_status() != RelLib.LdsOrd.STATUS_NONE:
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("2 STAT %s" %
|
|
|
|
self.cnvtxt(lds_status[ord.get_status()]))
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in ord.get_note_list():
|
|
|
|
self.write_long_text("NOTE", index+1, self.cnvtxt(note))
|
2004-02-14 11:10:30 +05:30
|
|
|
for srcref in ord.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_source_ref(index+1,srcref)
|
|
|
|
|
|
|
|
def print_date(self,prefix,date):
|
|
|
|
start = date.get_start_date()
|
2006-02-04 03:33:53 +05:30
|
|
|
if start != RelLib.Date.EMPTY:
|
2004-09-17 09:00:04 +05:30
|
|
|
cal = date.get_calendar()
|
|
|
|
mod = date.get_modifier()
|
2006-02-04 03:33:53 +05:30
|
|
|
if date.get_modifier() == RelLib.Date.MOD_SPAN:
|
2006-05-23 05:26:57 +05:30
|
|
|
val = "FROM %s TO %s" % (
|
|
|
|
make_date(start,cal,mod),
|
|
|
|
make_date(date.get_stop_date(),cal,mod))
|
2006-02-04 03:33:53 +05:30
|
|
|
elif date.get_modifier() == RelLib.Date.MOD_RANGE:
|
2006-05-23 05:26:57 +05:30
|
|
|
val = "BET %s AND %s" % (
|
|
|
|
make_date(start,cal,mod),
|
|
|
|
make_date(date.get_stop_date(),cal,mod))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-09-17 09:00:04 +05:30
|
|
|
val = make_date(start,cal,mod)
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,val))
|
2005-07-09 01:54:54 +05:30
|
|
|
elif date.get_text():
|
|
|
|
self.writeln("%s %s" % (prefix,self.cnvtxt(date.get_text())))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_person_name(self,name,nick):
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.private and name.private:
|
|
|
|
return
|
|
|
|
firstName = self.cnvtxt("%s %s" % (name.get_first_name(),
|
|
|
|
name.get_patronymic())).strip()
|
2004-02-14 11:10:30 +05:30
|
|
|
surName = self.cnvtxt(name.get_surname())
|
2003-07-07 16:09:05 +05:30
|
|
|
surName = surName.replace('/','?')
|
2004-02-14 11:10:30 +05:30
|
|
|
surPref = self.cnvtxt(name.get_surname_prefix())
|
2003-07-07 16:09:05 +05:30
|
|
|
surPref = surPref.replace('/','?')
|
2004-02-14 11:10:30 +05:30
|
|
|
suffix = self.cnvtxt(name.get_suffix())
|
|
|
|
title = self.cnvtxt(name.get_title())
|
2002-10-20 19:55:16 +05:30
|
|
|
if suffix == "":
|
2004-06-28 06:57:37 +05:30
|
|
|
if surPref == "":
|
2005-12-06 12:08:09 +05:30
|
|
|
self.writeln("1 NAME %s /%s/" % (firstName,surName))
|
2002-12-04 10:28:07 +05:30
|
|
|
else:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.writeln("1 NAME %s /%s %s/" % (firstName,surPref,surName))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-06-28 06:57:37 +05:30
|
|
|
if surPref == "":
|
2005-12-06 12:08:09 +05:30
|
|
|
self.writeln("1 NAME %s /%s/ %s" % (firstName,surName,suffix))
|
2002-12-04 10:28:07 +05:30
|
|
|
else:
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("1 NAME %s /%s %s/ %s" % (firstName,surPref,
|
|
|
|
surName,suffix))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if firstName:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 GIVN %s" % firstName)
|
2002-12-04 10:28:07 +05:30
|
|
|
if self.prefix:
|
|
|
|
if surPref:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('2 SPFX %s' % surPref)
|
2002-12-30 06:12:47 +05:30
|
|
|
if surName:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 SURN %s" % surName)
|
2002-12-04 10:28:07 +05:30
|
|
|
else:
|
|
|
|
if surPref:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 SURN %s %s" % (surPref,surName))
|
2002-12-14 10:37:09 +05:30
|
|
|
elif surName:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 SURN %s" % surName)
|
2002-12-04 10:28:07 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_suffix():
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 NSFX %s" % suffix)
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_title():
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 NPFX %s" % title)
|
2002-12-30 06:12:47 +05:30
|
|
|
if nick:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('2 NICK %s' % nick)
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in name.get_note_list():
|
|
|
|
self.write_long_text("NOTE", 2, self.cnvtxt(note))
|
2004-02-14 11:10:30 +05:30
|
|
|
for srcref in name.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_source_ref(2,srcref)
|
|
|
|
|
|
|
|
def write_source_ref(self,level,ref):
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.private and ref.private:
|
|
|
|
return
|
|
|
|
|
|
|
|
src_handle = ref.get_reference_handle()
|
|
|
|
|
|
|
|
if src_handle == None:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2003-01-03 08:49:50 +05:30
|
|
|
|
2006-05-23 05:26:57 +05:30
|
|
|
src = self.db.get_source_from_handle(src_handle)
|
|
|
|
if self.private and src.private:
|
|
|
|
return
|
|
|
|
|
|
|
|
self.slist.add(src_handle)
|
|
|
|
|
2003-01-03 08:49:50 +05:30
|
|
|
if self.source_refs:
|
2006-05-23 05:26:57 +05:30
|
|
|
# Reference to the source
|
|
|
|
self.writeln("%d SOUR @%s@" % (level,src.get_gramps_id()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if ref.get_page() != "":
|
2007-04-18 07:42:40 +05:30
|
|
|
sep = "\n%d CONT " % (level+2)
|
|
|
|
page_text = self.cnvtxt(ref.get_page().replace('\n',sep))
|
|
|
|
self.writeln('%d PAGE %s' % (level+1, page_text))
|
2006-06-17 00:08:06 +05:30
|
|
|
conf = ref.get_confidence_level()
|
2006-10-25 01:00:24 +05:30
|
|
|
# Cap the maximum level
|
|
|
|
conf = min(conf,RelLib.SourceRef.CONF_VERY_HIGH)
|
2007-01-03 08:07:34 +05:30
|
|
|
if conf != RelLib.SourceRef.CONF_NORMAL and conf != -1:
|
2006-06-17 00:08:06 +05:30
|
|
|
self.write_long_text("QUAY",level+1, str(quay_map[conf]))
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
ref_text = ref.get_text()
|
2005-03-23 05:29:51 +05:30
|
|
|
if ref_text != "" or not ref.get_date_object().is_empty():
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('%d DATA' % (level+1))
|
2003-01-03 08:49:50 +05:30
|
|
|
if ref_text != "":
|
2003-01-26 10:41:35 +05:30
|
|
|
self.write_long_text("TEXT",level+2,self.cnvtxt(ref_text))
|
2003-01-03 08:49:50 +05:30
|
|
|
pfx = "%d DATE" % (level+2)
|
2005-03-23 05:29:51 +05:30
|
|
|
self.print_date(pfx,ref.get_date_object())
|
2003-01-03 08:49:50 +05:30
|
|
|
else:
|
2006-05-23 05:26:57 +05:30
|
|
|
# Inline source
|
|
|
|
|
2003-01-03 08:49:50 +05:30
|
|
|
# We put title, page, and date on the SOUR line.
|
2003-01-08 10:28:00 +05:30
|
|
|
# Not using CONC and CONT because GeneWeb does not support these.
|
2003-01-03 08:49:50 +05:30
|
|
|
# TEXT and NOTE will be ignored by GeneWeb, but we can't
|
2003-01-08 10:28:00 +05:30
|
|
|
# output paragaphs in SOUR without CONT.
|
2005-01-11 10:02:26 +05:30
|
|
|
txt = ""
|
2006-05-23 05:26:57 +05:30
|
|
|
if src.get_title():
|
|
|
|
txt = src.get_title() + ". "
|
2004-02-14 11:10:30 +05:30
|
|
|
if ref.get_page():
|
|
|
|
txt = txt + ref.get_page() + ". "
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("%d SOUR %s" % (level,self.cnvtxt(txt)))
|
2005-03-23 05:29:51 +05:30
|
|
|
if not ref.get_date_object().is_empty():
|
|
|
|
self.print_date("", ref.get_date_object())
|
2006-05-23 05:26:57 +05:30
|
|
|
ref_text = ref.get_text()
|
|
|
|
if ref_text:
|
2003-01-26 10:41:35 +05:30
|
|
|
self.write_long_text("TEXT",level+1,self.cnvtxt(ref_text))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in ref.get_note_list():
|
|
|
|
self.write_long_text("NOTE", level+1, self.cnvtxt(note))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
def write_photo(self,photo,level):
|
|
|
|
photo_obj_id = photo.get_reference_handle()
|
|
|
|
photo_obj = self.db.get_object_from_handle(photo_obj_id)
|
|
|
|
if photo_obj:
|
|
|
|
mime = photo_obj.get_mime_type()
|
2006-06-15 22:16:12 +05:30
|
|
|
if mime2ged.has_key(mime):
|
|
|
|
form = mime2ged[mime]
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
form = mime
|
|
|
|
path = photo_obj.get_path ()
|
|
|
|
imgdir = os.path.join(self.dirname,self.images_path)
|
|
|
|
if not os.path.isfile(path):
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
if not os.path.isdir(imgdir):
|
|
|
|
os.makedirs(imgdir)
|
|
|
|
except:
|
|
|
|
return
|
|
|
|
basename = os.path.basename(path)
|
|
|
|
dest = os.path.join (imgdir, basename)
|
|
|
|
if dest != path:
|
|
|
|
try:
|
|
|
|
shutil.copyfile(path, dest)
|
|
|
|
shutil.copystat(path, dest)
|
|
|
|
except (IOError,OSError),msg:
|
|
|
|
msg2 = _("Could not create %s") % dest
|
|
|
|
WarningDialog(msg2,str(msg))
|
|
|
|
return
|
|
|
|
|
|
|
|
self.writeln('%d OBJE' % level)
|
|
|
|
if form:
|
|
|
|
self.writeln('%d FORM %s' % (level+1, form) )
|
|
|
|
self.writeln('%d TITL %s' % (level+1, photo_obj.get_description()))
|
|
|
|
basename = os.path.basename (path)
|
|
|
|
self.writeln('%d FILE %s' % (level+1,os.path.join(self.images_path,
|
|
|
|
basename)))
|
2007-04-18 07:42:40 +05:30
|
|
|
for note in photo_obj.get_note_list():
|
|
|
|
self.write_long_text("NOTE", level+1, self.cnvtxt(note))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
def write_place(self,place,level):
|
2006-05-23 05:26:57 +05:30
|
|
|
if self.private and place.private:
|
|
|
|
return
|
2005-12-06 12:08:09 +05:30
|
|
|
place_name = place.get_title()
|
2006-05-23 05:26:57 +05:30
|
|
|
self.writeln("%d PLAC %s" %
|
|
|
|
(level,self.cnvtxt(place_name).replace('\r',' ')))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def prefn(self,person):
|
2004-07-12 05:23:02 +05:30
|
|
|
match = _get_int.search(person.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
if match:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 REFN %d' % int(match.groups()[0]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def frefn(self,family):
|
|
|
|
match = _get_int.search(family.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
if match:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 REFN %d' % int(match.groups()[0]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-01 10:34:22 +05:30
|
|
|
def exportData(database,filename,person,option_box,callback=None):
|
2004-07-11 05:01:28 +05:30
|
|
|
ret = 0
|
|
|
|
try:
|
2006-03-01 11:46:36 +05:30
|
|
|
gw = GedcomWriter(database,person,0,filename,option_box,callback)
|
2004-07-14 07:14:04 +05:30
|
|
|
ret = gw.export_data(filename)
|
2007-04-18 07:42:40 +05:30
|
|
|
# except AttributeError, msg:
|
|
|
|
# RunDatabaseRepair(msg)
|
2006-12-11 09:40:46 +05:30
|
|
|
except Errors.DatabaseError, msg:
|
2005-12-06 12:08:09 +05:30
|
|
|
ErrorDialog(_("Export failed"),str(msg))
|
2004-07-11 05:01:28 +05:30
|
|
|
return ret
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-02-20 04:03:24 +05:30
|
|
|
_title = _('GE_DCOM')
|
2004-07-11 05:01:28 +05:30
|
|
|
_description = _('GEDCOM is used to transfer data between genealogy programs. '
|
2004-07-14 07:14:04 +05:30
|
|
|
'Most genealogy software will accept a GEDCOM file as input. ')
|
2004-07-11 11:33:07 +05:30
|
|
|
_config = (_('GEDCOM export options'),GedcomWriterOptionBox)
|
2004-07-11 05:01:28 +05:30
|
|
|
_filename = 'ged'
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-11 06:42:06 +05:30
|
|
|
from PluginUtils import register_export
|
2004-07-11 05:01:28 +05:30
|
|
|
register_export(exportData,_title,_description,_config,_filename)
|