2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-03-11 09:58:17 +05:30
|
|
|
# Copyright (C) 2000-2004 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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import os
|
|
|
|
import string
|
|
|
|
import time
|
|
|
|
import re
|
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2003-12-02 08:05:49 +05:30
|
|
|
import gnome
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-01-15 10:55:50 +05:30
|
|
|
import RelLib
|
2002-12-30 06:12:47 +05:30
|
|
|
import GenericFilter
|
|
|
|
import const
|
|
|
|
import Utils
|
|
|
|
import Date
|
2003-01-08 10:28:00 +05:30
|
|
|
import Calendar
|
2003-01-10 10:51:32 +05:30
|
|
|
import Julian
|
|
|
|
import Hebrew
|
|
|
|
import FrenchRepublic
|
2003-01-15 10:55:50 +05:30
|
|
|
import GedcomInfo
|
2003-06-18 08:20:30 +05:30
|
|
|
import Errors
|
2003-01-19 11:55:20 +05:30
|
|
|
import ansel_utf8
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2003-03-21 09:55:55 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2002-12-30 06:12:47 +05:30
|
|
|
|
2003-07-16 00:47:17 +05:30
|
|
|
_title_string = _("Export to GEDCOM")
|
|
|
|
|
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):
|
|
|
|
return s.encode('iso-8859-1')
|
|
|
|
|
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 = {
|
2003-01-10 10:51:32 +05:30
|
|
|
Hebrew.Hebrew.NAME : (_hmonth, '@#HEBREW@'),
|
|
|
|
FrenchRepublic.FrenchRepublic.NAME : (_fmonth, '@#FRENCH R@'),
|
|
|
|
Julian.Julian.NAME : (_month, '@#JULIAN@'),
|
2002-10-20 19:55:16 +05:30
|
|
|
}
|
|
|
|
|
2002-12-29 11:14:35 +05:30
|
|
|
_caldef = {
|
2003-01-08 10:28:00 +05:30
|
|
|
Calendar.ABOUT : "ABT",
|
|
|
|
Calendar.BEFORE : "BEF",
|
|
|
|
Calendar.AFTER : "AFT",
|
2002-12-29 11:14:35 +05:30
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-07-28 07:59:07 +05:30
|
|
|
def add_familys_sources(db,family_handle,slist,private):
|
2004-08-11 22:30:38 +05:30
|
|
|
family = db.get_family_from_handle(family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in family.get_event_list():
|
|
|
|
if event_handle:
|
|
|
|
event = db.find_event_from_handle(event_handle)
|
2004-06-10 05:29:03 +05:30
|
|
|
if private and event.get_privacy():
|
|
|
|
continue
|
|
|
|
for source_ref in event.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
sbase = source_ref.get_base_handle()
|
2004-06-10 05:29:03 +05:30
|
|
|
if sbase != None and not slist.has_key(sbase):
|
|
|
|
slist[sbase] = 1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for attr in family.get_attribute_list():
|
|
|
|
if private and attr.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
for source_ref in attr.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
sbase = source_ref.get_base_handle()
|
|
|
|
if sbase != None and not slist.has_key(sbase.get_handle()):
|
|
|
|
slist[sbase.get_handle()] = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-06-10 05:29:03 +05:30
|
|
|
def add_persons_sources(db,person,slist,private):
|
2004-02-14 11:10:30 +05:30
|
|
|
elist = person.get_event_list()[:]
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
elist.append(person.get_birth_handle())
|
|
|
|
elist.append(person.get_death_handle())
|
|
|
|
for event_handle in elist:
|
|
|
|
if event_handle:
|
|
|
|
event = db.find_event_from_handle(event_handle)
|
2004-06-10 05:29:03 +05:30
|
|
|
if private and event.get_privacy():
|
|
|
|
continue
|
|
|
|
for source_ref in event.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
sbase = source_ref.get_base_handle()
|
2004-06-10 05:29:03 +05:30
|
|
|
if sbase != None and not slist.has_key(sbase):
|
|
|
|
slist[sbase] = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for event in person.get_address_list():
|
|
|
|
if private and event.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
for source_ref in event.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
sbase = source_ref.get_base_handle()
|
|
|
|
if sbase != None and not slist.has_key(sbase.get_handle()):
|
|
|
|
slist[sbase.get_handle()] = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for event in person.get_attribute_list():
|
|
|
|
if private and event.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
for source_ref in event.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
sbase = source_ref.get_base_handle()
|
|
|
|
if sbase != None and not slist.has_key(sbase.get_handle()):
|
|
|
|
slist[sbase.get_handle()] = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for name in person.get_alternate_names() + [person.get_primary_name()]:
|
|
|
|
if private and name.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
for source_ref in name.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
sbase = source_ref.get_base_handle()
|
2004-06-10 05:29:03 +05:30
|
|
|
if sbase != None and not slist.has_key(sbase):
|
|
|
|
slist[sbase] = 1
|
|
|
|
|
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
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def sortById(first,second):
|
2004-07-28 07:59:07 +05:30
|
|
|
fid = first.get_handle()
|
|
|
|
sid = second.get_handle()
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if fid == sid:
|
|
|
|
return 0
|
|
|
|
elif fid < sid:
|
|
|
|
return -1
|
|
|
|
else:
|
|
|
|
return 1
|
|
|
|
|
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
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-12-29 11:14:35 +05:30
|
|
|
def make_date(subdate):
|
2002-10-20 19:55:16 +05:30
|
|
|
retval = ""
|
2004-06-10 05:29:03 +05:30
|
|
|
day = subdate.get_day()
|
|
|
|
mon = subdate.get_month()
|
|
|
|
year = subdate.get_year()
|
|
|
|
mode = subdate.get_mode_val()
|
|
|
|
day_valid = subdate.get_day_valid()
|
|
|
|
mon_valid = subdate.get_month_valid()
|
|
|
|
year_valid = subdate.get_year_valid()
|
|
|
|
|
2003-01-10 10:51:32 +05:30
|
|
|
if _calmap.has_key(subdate.calendar.NAME):
|
|
|
|
(mmap,prefix) = _calmap[subdate.calendar.NAME]
|
2002-12-29 11:14:35 +05:30
|
|
|
else:
|
|
|
|
mmap = _month
|
|
|
|
prefix = ""
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if not day_valid:
|
|
|
|
try:
|
|
|
|
if not mon_valid:
|
2002-12-30 06:12:47 +05:30
|
|
|
retval = '%d' % year
|
2002-10-20 19:55:16 +05:30
|
|
|
elif not year_valid:
|
2002-12-29 11:14:35 +05:30
|
|
|
retval = '(%s)' % mmap[mon]
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2002-12-30 06:12:47 +05:30
|
|
|
retval = "%s %d" % (mmap[mon],year)
|
2002-10-20 19:55:16 +05:30
|
|
|
except IndexError:
|
|
|
|
print "Month index error - %d" % mon
|
2002-12-30 06:12:47 +05:30
|
|
|
retval = '%d' % year
|
2002-10-20 19:55:16 +05:30
|
|
|
elif not mon_valid:
|
2002-12-30 06:12:47 +05:30
|
|
|
retval = '%d' % year
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
try:
|
|
|
|
month = mmap[mon]
|
|
|
|
if not year_valid:
|
2002-12-29 11:14:35 +05:30
|
|
|
retval = "(%d %s)" % (day,month)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
retval = "%d %s %d" % (day,month,year)
|
|
|
|
except IndexError:
|
|
|
|
print "Month index error - %d" % mon
|
|
|
|
retval = str(year)
|
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-12-30 06:12:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-06-28 23:05:00 +05:30
|
|
|
def fmtline(text,limit,level,endl):
|
2002-10-20 19:55:16 +05:30
|
|
|
new_text = []
|
|
|
|
while len(text) > limit:
|
|
|
|
new_text.append(text[0:limit-1])
|
|
|
|
text = text[limit:]
|
|
|
|
if len(text) > 0:
|
|
|
|
new_text.append(text)
|
2003-06-28 23:05:00 +05:30
|
|
|
app = "%s%d CONC " % (endl,level+1)
|
2002-10-20 19:55:16 +05:30
|
|
|
return string.join(new_text,app)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def gedcom_date(date):
|
|
|
|
if date.range == 1:
|
|
|
|
s1 = ged_subdate(date.get_start_date())
|
|
|
|
s2 = ged_subdate(date.get_stop_date())
|
|
|
|
return "BET %s AND %s" % (s1,s2)
|
|
|
|
elif date.range == -1:
|
|
|
|
return "(%s)" % date.text
|
|
|
|
else:
|
|
|
|
return ged_subdate(date.start)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def ged_subdate(date):
|
|
|
|
if not date.getValid():
|
|
|
|
return ""
|
|
|
|
elif not date.getDayValid():
|
|
|
|
try:
|
|
|
|
if not date.getMonthValid():
|
|
|
|
retval = str(date.year)
|
|
|
|
elif not date.getYearValid():
|
|
|
|
retval = "(%s)" % Date.SingleDate.emname[date.month]
|
2004-07-14 07:14:04 +05:30
|
|
|
else:
|
2002-10-20 19:55:16 +05:30
|
|
|
retval = "%s %d" % (Date.SingleDate.emname[date.month],date.year)
|
|
|
|
except IndexError:
|
|
|
|
print "Month index error - %d" % date.month
|
|
|
|
retval = str(date.year)
|
|
|
|
elif not date.getMonthValid():
|
|
|
|
retval = str(date.year)
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
month = Date.SingleDate.emname[date.month]
|
|
|
|
if not date.getYearValid():
|
|
|
|
retval = "(%d %s)" % (date.day,month)
|
|
|
|
else:
|
|
|
|
retval = "%d %s %d" % (date.day,month,date.year)
|
|
|
|
except IndexError:
|
|
|
|
print "Month index error - %d" % date.month
|
|
|
|
retval = str(date.year)
|
|
|
|
|
|
|
|
if date.mode == Date.SingleDate.about:
|
|
|
|
retval = "ABT %s" % retval
|
|
|
|
|
|
|
|
if date.mode == Date.SingleDate.before:
|
|
|
|
retval = "BEF %s" % retval
|
|
|
|
elif date.mode == Date.SingleDate.after:
|
|
|
|
retval = "AFT %s" % retval
|
|
|
|
|
|
|
|
return retval
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def writeData(database,person):
|
|
|
|
try:
|
|
|
|
GedcomWriter(database,person)
|
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
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):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.restrict = 1
|
|
|
|
self.private = 1
|
2003-01-19 11:55:20 +05:30
|
|
|
self.cnvtxt = ansel_utf8.utf8_to_ansel
|
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
|
|
|
})
|
|
|
|
|
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
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
all = GenericFilter.GenericFilter()
|
|
|
|
all.set_name(_("Entire Database"))
|
|
|
|
all.add_rule(GenericFilter.Everyone([]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
des = GenericFilter.GenericFilter()
|
|
|
|
des.set_name(_("Descendants of %s") % self.person.get_primary_name().get_name())
|
2004-07-28 07:59:07 +05:30
|
|
|
des.add_rule(GenericFilter.IsDescendantOf([self.person.get_handle()]))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
ans = GenericFilter.GenericFilter()
|
|
|
|
ans.set_name(_("Ancestors of %s") % self.person.get_primary_name().get_name())
|
2004-07-28 07:59:07 +05:30
|
|
|
ans.add_rule(GenericFilter.IsAncestorOf([self.person.get_handle()]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
com = GenericFilter.GenericFilter()
|
|
|
|
com.set_name(_("People with common ancestor with %s") %
|
|
|
|
self.person.get_primary_name().get_name())
|
2004-07-28 07:59:07 +05:30
|
|
|
com.add_rule(GenericFilter.HasCommonAncestorWith([self.person.get_handle()]))
|
2002-11-12 09:42:18 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
self.filter_menu = GenericFilter.build_filter_menu([all,des,ans,com])
|
|
|
|
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
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
# glade_file = "%s/gedcomexport.glade" % os.path.dirname(__file__)
|
|
|
|
#
|
|
|
|
# self.exprogress = gtk.glade.XML(glade_file,"exportprogress","gramps")
|
|
|
|
# self.exprogress.signal_autoconnect({
|
|
|
|
# "on_close_clicked" : Utils.destroy_passed_object
|
|
|
|
# })
|
|
|
|
#
|
|
|
|
# Utils.set_titles(self.exprogress.get_widget('exportprogress'),
|
|
|
|
# self.exprogress.get_widget('title'),
|
|
|
|
# _('GEDCOM export'))
|
|
|
|
#
|
|
|
|
# self.fbar = self.exprogress.get_widget("fbar")
|
|
|
|
# self.pbar = self.exprogress.get_widget("pbar")
|
|
|
|
# self.sbar = self.exprogress.get_widget("sbar")
|
|
|
|
# self.progress = self.exprogress.get_widget('exportprogress')
|
|
|
|
#
|
|
|
|
# closebtn = self.exprogress.get_widget("close")
|
|
|
|
# closebtn.connect("clicked",Utils.destroy_passed_object)
|
|
|
|
# closebtn.set_sensitive(0)
|
|
|
|
#
|
|
|
|
# self.export_data(name)
|
|
|
|
# closebtn.set_sensitive(1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
class GedcomWriter:
|
|
|
|
def __init__(self,database,person,cl=0,filename="",option_box=None):
|
|
|
|
self.db = database
|
|
|
|
self.person = person
|
|
|
|
self.option_box = option_box
|
|
|
|
self.cl = cl
|
|
|
|
self.filename = filename
|
2003-12-02 08:05:49 +05:30
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
self.plist = {}
|
|
|
|
self.slist = {}
|
|
|
|
self.flist = {}
|
|
|
|
self.fidval = 0
|
|
|
|
self.fidmap = {}
|
|
|
|
self.sidval = 0
|
|
|
|
self.sidmap = {}
|
|
|
|
|
|
|
|
if not option_box:
|
|
|
|
self.cl_setup()
|
|
|
|
else:
|
|
|
|
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
|
2004-07-14 07:14:04 +05:30
|
|
|
self.images_path = self.option_box.images_path
|
2004-07-11 11:33:07 +05:30
|
|
|
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
|
|
|
|
|
|
|
|
if self.option_box.cfilter == None:
|
|
|
|
for p in self.db.get_person_keys():
|
|
|
|
self.plist[p] = 1
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
for p in self.option_box.cfilter.apply(self.db, self.db.get_person_keys()):
|
|
|
|
self.plist[p] = 1
|
|
|
|
except Errors.FilterError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
|
|
|
return
|
|
|
|
|
|
|
|
self.flist = {}
|
|
|
|
self.slist = {}
|
|
|
|
for key in self.plist.keys():
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.db.get_person_from_handle(key)
|
2004-07-11 11:33:07 +05:30
|
|
|
add_persons_sources(self.db,p,self.slist,self.option_box.private)
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in p.get_family_handle_list():
|
|
|
|
add_familys_sources(self.db,family_handle,self.slist,self.option_box.private)
|
|
|
|
self.flist[family_handle] = 1
|
2004-07-11 11:33:07 +05:30
|
|
|
|
2003-05-21 02:01:16 +05:30
|
|
|
def cl_setup(self):
|
|
|
|
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
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for p in self.db.get_person_keys():
|
2003-05-21 02:01:16 +05:30
|
|
|
self.plist[p] = 1
|
|
|
|
|
|
|
|
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
|
|
|
|
2003-05-21 02:01:16 +05:30
|
|
|
self.flist = {}
|
|
|
|
self.slist = {}
|
|
|
|
|
|
|
|
for key in self.plist.keys():
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.db.get_person_from_handle(key)
|
2004-06-10 05:29:03 +05:30
|
|
|
add_persons_sources(self.db,p,self.slist,self.private)
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in p.get_family_handle_list():
|
|
|
|
add_familys_sources(self.db,family_handle,self.slist,self.private)
|
|
|
|
self.flist[family_handle] = 1
|
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-11 11:33:07 +05:30
|
|
|
# self.progress.destroy()
|
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-11 11:33:07 +05:30
|
|
|
# self.progress.destroy()
|
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
|
|
|
|
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()
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("0 @SUBM@ SUBM")
|
2004-02-14 11:10:30 +05:30
|
|
|
owner = self.db.get_researcher()
|
|
|
|
if owner.get_name():
|
|
|
|
self.writeln("1 NAME %s" % self.cnvtxt(owner.get_name()))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 NAME Not Provided')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if owner.get_address():
|
2002-10-20 19:55:16 +05:30
|
|
|
cnt = 0
|
2004-02-14 11:10:30 +05:30
|
|
|
self.writeln("1 ADDR %s" % self.cnvtxt(owner.get_address()))
|
|
|
|
if owner.get_city():
|
|
|
|
self.writeln("2 CONT %s" % self.cnvtxt(owner.get_city()))
|
2002-10-20 19:55:16 +05:30
|
|
|
cnt = 1
|
2004-02-14 11:10:30 +05:30
|
|
|
if owner.get_state():
|
|
|
|
self.writeln("2 CONT %s" % self.cnvtxt(owner.get_state()))
|
2002-10-20 19:55:16 +05:30
|
|
|
cnt = 1
|
2004-02-14 11:10:30 +05:30
|
|
|
if owner.get_postal_code():
|
|
|
|
self.writeln("2 CONT %s" % self.cnvtxt(owner.get_postal_code()))
|
2002-10-20 19:55:16 +05:30
|
|
|
cnt = 1
|
2004-02-14 11:10:30 +05:30
|
|
|
if owner.get_country():
|
|
|
|
self.writeln("2 CONT %s" % self.cnvtxt(owner.get_country()))
|
2002-10-20 19:55:16 +05:30
|
|
|
cnt = 1
|
|
|
|
if cnt == 0:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('2 CONT Not Provided')
|
2004-02-14 11:10:30 +05:30
|
|
|
if owner.get_phone():
|
|
|
|
self.writeln("1 PHON %s" % self.cnvtxt(owner.get_phone()))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('1 ADDR Not Provided')
|
|
|
|
self.writeln('2 CONT Not Provided')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
pkeys = self.plist.keys()
|
|
|
|
pkeys.sort()
|
|
|
|
nump = float(len(self.plist))
|
|
|
|
index = 0.0
|
|
|
|
for key in pkeys:
|
2004-08-07 10:46:57 +05:30
|
|
|
self.write_person(self.db.get_person_from_handle(key))
|
2002-10-20 19:55:16 +05:30
|
|
|
index = index + 1
|
2004-07-11 11:33:07 +05:30
|
|
|
#if index%100 == 0 and not self.cl:
|
|
|
|
# self.pbar.set_fraction(index/nump)
|
|
|
|
# while(gtk.events_pending()):
|
|
|
|
# gtk.mainiteration()
|
|
|
|
# if not self.cl:
|
|
|
|
# self.pbar.set_fraction(1.0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.write_families()
|
2003-01-03 08:49:50 +05:30
|
|
|
if self.source_refs:
|
|
|
|
self.write_sources()
|
2004-07-11 11:33:07 +05:30
|
|
|
#else:
|
|
|
|
# if not self.cl:
|
|
|
|
# self.sbar.set_fraction(1.0)
|
2003-01-08 10:28:00 +05:30
|
|
|
|
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):
|
|
|
|
import time
|
|
|
|
|
|
|
|
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()
|
2003-06-28 23:05:00 +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):
|
|
|
|
import time
|
|
|
|
|
|
|
|
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):
|
|
|
|
nump = float(len(self.flist))
|
|
|
|
index = 0.0
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in self.flist.keys():
|
2004-08-11 22:30:38 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
father_alive = mother_alive = 0
|
2004-07-28 07:59:07 +05:30
|
|
|
self.writeln("0 @%s@ FAM" % self.fid(family_handle))
|
|
|
|
self.frefn(family_handle)
|
|
|
|
person_handle = family.get_father_handle()
|
|
|
|
if person_handle != None and self.plist.has_key(person_handle):
|
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-03-12 04:44:55 +05:30
|
|
|
father_alive = person.probably_alive(self.db)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
person_handle = family.get_mother_handle()
|
|
|
|
if person_handle != None and self.plist.has_key(person_handle):
|
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-03-12 04:44:55 +05:30
|
|
|
mother_alive = person.probably_alive(self.db)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if not self.restrict or ( not father_alive and not mother_alive ):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_ord("SLGS",family.get_lds_sealing(),1,const.lds_ssealing)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in family.get_event_list():
|
|
|
|
event = self.db.find_event_from_handle(event_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.private and event.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
name = event.get_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
val = ""
|
|
|
|
if const.familyConstantEvents.has_key(name):
|
|
|
|
val = const.familyConstantEvents[name]
|
|
|
|
if val == "":
|
|
|
|
val = self.target_ged.gramps2tag(name)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-12-30 06:12:47 +05:30
|
|
|
if val:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 %s %s" % (self.cnvtxt(val),
|
2004-02-14 11:10:30 +05:30
|
|
|
self.cnvtxt(event.get_description())))
|
2004-07-14 07:14:04 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.writeln("1 EVEN %s" % self.cnvtxt(event.get_description()))
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(name))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_event_stats(event)
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in family.get_child_handle_list():
|
|
|
|
if not self.plist.has_key(person_handle):
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
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
|
|
|
self.writeln("1 CHIL @%s@" % person.get_gramps_id())
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.adopt == GedcomInfo.ADOPT_FTW:
|
2004-07-28 07:59:07 +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:
|
2004-07-28 07:59:07 +05:30
|
|
|
for f in person.get_parent_family_handle_list():
|
|
|
|
if f[0] == family.get_handle():
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('2 _FREL %s' % f[2])
|
|
|
|
self.writeln('2 _MREL %s' % f[1])
|
2002-10-20 19:55:16 +05:30
|
|
|
break
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.adopt == GedcomInfo.ADOPT_LEGACY:
|
2004-07-28 07:59:07 +05:30
|
|
|
for f in person.get_parent_family_handle_list():
|
|
|
|
if f[0] == family.get_handle():
|
2004-06-10 05:29:03 +05:30
|
|
|
self.writeln('2 _STAT %s' % f[2])
|
|
|
|
break
|
|
|
|
|
2004-07-11 11:33:07 +05:30
|
|
|
# index = index + 1
|
|
|
|
# if index % 100 == 0 and not self.cl:
|
|
|
|
# self.fbar.set_fraction(index/nump)
|
|
|
|
# while(gtk.events_pending()):
|
|
|
|
# gtk.mainiteration()
|
|
|
|
#if not self.cl:
|
|
|
|
# self.fbar.set_fraction(1.0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_sources(self):
|
|
|
|
nump = float(len(self.slist))
|
|
|
|
index = 0.0
|
|
|
|
for key in self.slist.keys():
|
2004-08-07 10:46:57 +05:30
|
|
|
source = self.db.get_source_from_handle(key)
|
2004-07-28 07:59:07 +05:30
|
|
|
self.writeln("0 @%s@ SOUR" % self.sid(source.get_handle()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_title():
|
|
|
|
self.writeln("1 TITL %s" % fmtline(self.cnvtxt(source.get_title()),248,1,self.nl))
|
|
|
|
if source.get_author():
|
|
|
|
self.writeln("1 AUTH %s" % self.cnvtxt(source.get_author()))
|
|
|
|
if source.get_publication_info():
|
|
|
|
self.writeln("1 PUBL %s" % self.cnvtxt(source.get_publication_info()))
|
2004-06-10 05:29:03 +05:30
|
|
|
if source.get_abbreviation():
|
|
|
|
self.writeln("1 ABBR %s" % self.cnvtxt(source.get_abbreviation()))
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_note():
|
|
|
|
self.write_long_text("NOTE",1,self.cnvtxt(source.get_note()))
|
2002-10-20 19:55:16 +05:30
|
|
|
index = index + 1
|
2004-07-11 11:33:07 +05:30
|
|
|
# if index % 100 == 0 and not self.cl:
|
|
|
|
# self.sbar.set_fraction(index/nump)
|
|
|
|
# while(gtk.events_pending()):
|
|
|
|
# gtk.mainiteration()
|
|
|
|
# if not self.cl:
|
|
|
|
# self.sbar.set_fraction(1.0)
|
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-03-12 04:44:55 +05:30
|
|
|
restricted = self.restrict and person.probably_alive (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 ()
|
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")
|
2003-07-22 15:44:49 +05:30
|
|
|
nickname = ""
|
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
primaryname = person.get_primary_name ()
|
|
|
|
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)
|
2004-02-14 11:10:30 +05:30
|
|
|
primaryname.set_note ('')
|
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,"")
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if person.get_gender() == RelLib.Person.male:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 SEX M")
|
2004-07-14 07:14:04 +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:
|
2004-07-28 07:59:07 +05:30
|
|
|
birth_handle = person.get_birth_handle()
|
|
|
|
birth = self.db.find_event_from_handle(birth_handle)
|
|
|
|
if birth_handle and not (self.private and birth.get_privacy()):
|
|
|
|
if not birth.get_date_object().is_empty() or birth.get_place_handle():
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 BIRT")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_event_stats(birth)
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
death_handle = person.get_death_handle()
|
|
|
|
death = self.db.find_event_from_handle(death_handle)
|
|
|
|
if death_handle and not (self.private and death.get_privacy()):
|
|
|
|
if not death.get_date_object().is_empty() or death.get_place_handle():
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 DEAT")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_event_stats(death)
|
|
|
|
|
|
|
|
ad = 0
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_ord("BAPL",person.get_lds_baptism(),1,const.lds_baptism)
|
|
|
|
self.write_ord("ENDL",person.get_lds_endowment(),1,const.lds_baptism)
|
|
|
|
self.write_ord("SLGC",person.get_lds_sealing(),1,const.lds_csealing)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in person.get_event_list():
|
|
|
|
event = self.db.find_event_from_handle(event_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.private and event.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
name = event.get_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
val = ""
|
|
|
|
if const.personalConstantEvents.has_key(name):
|
|
|
|
val = const.personalConstantEvents[name]
|
|
|
|
if val == "":
|
|
|
|
val = self.target_ged.gramps2tag(name)
|
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
|
2004-07-28 07:59:07 +05:30
|
|
|
for f in person.get_parent_family_handle_list():
|
2004-06-10 05:29:03 +05:30
|
|
|
mrel = f[1].lower()
|
|
|
|
frel = f[2].lower()
|
2002-10-28 19:06:39 +05:30
|
|
|
if mrel=="adopted" or frel=="adopted":
|
2002-10-20 19:55:16 +05:30
|
|
|
fam = f[0]
|
|
|
|
break
|
|
|
|
if fam:
|
2004-07-28 07:59:07 +05:30
|
|
|
self.writeln('2 FAMC @%s@' % self.fid(fam.get_handle()))
|
2002-10-20 19:55:16 +05:30
|
|
|
if mrel == frel:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP BOTH')
|
2002-10-20 19:55:16 +05:30
|
|
|
elif mrel == "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-12-30 06:12:47 +05:30
|
|
|
elif val :
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 %s %s" % (self.cnvtxt(val),\
|
2004-02-14 11:10:30 +05:30
|
|
|
self.cnvtxt(event.get_description())))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.writeln("1 EVEN %s" % self.cnvtxt(event.get_description()))
|
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(event.get_name()))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_event_stats(event)
|
|
|
|
|
2004-07-28 07:59:07 +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
|
2004-07-28 07:59:07 +05:30
|
|
|
for f in person.get_parent_family_handle_list():
|
2004-06-10 05:29:03 +05:30
|
|
|
mrel = f[1].lower()
|
|
|
|
frel = f[2].lower()
|
2002-10-28 19:06:39 +05:30
|
|
|
if mrel=="adopted" or frel=="adopted":
|
2002-10-20 19:55:16 +05:30
|
|
|
fam = f[0]
|
|
|
|
break
|
|
|
|
if fam:
|
2004-07-28 07:59:07 +05:30
|
|
|
self.writeln('2 FAMC @%s@' % self.fid(fam.get_handle()))
|
2002-10-20 19:55:16 +05:30
|
|
|
if mrel == frel:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('3 ADOP BOTH')
|
2002-10-20 19:55:16 +05:30
|
|
|
elif mrel == "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
|
2004-02-14 11:10:30 +05:30
|
|
|
name = attr.get_type()
|
2004-06-10 05:29:03 +05:30
|
|
|
|
|
|
|
if name in ["AFN", "RFN", "_UID"]:
|
|
|
|
self.writeln("1 %s %s" % ( name, attr.get_value()))
|
|
|
|
continue
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if const.personalConstantAttributes.has_key(name):
|
|
|
|
val = const.personalConstantAttributes[name]
|
|
|
|
else:
|
|
|
|
val = ""
|
2002-12-30 06:12:47 +05:30
|
|
|
if val :
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 %s" % val)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("1 EVEN")
|
|
|
|
self.writeln("2 TYPE %s" % self.cnvtxt(name))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(attr.get_value()),'\r',' '))
|
|
|
|
if attr.get_note():
|
|
|
|
self.write_long_text("NOTE",2,self.cnvtxt(attr.get_note()))
|
|
|
|
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:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_long_text("ADDR",2,self.cnvtxt(addr.get_street()))
|
|
|
|
if addr.get_city():
|
|
|
|
self.writeln("3 CITY %s" % self.cnvtxt(addr.get_city()))
|
|
|
|
if addr.get_state():
|
|
|
|
self.writeln("3 STAE %s" % self.cnvtxt(addr.get_state()))
|
|
|
|
if addr.get_postal_code():
|
|
|
|
self.writeln("3 POST %s" % self.cnvtxt(addr.get_postal_code()))
|
|
|
|
if addr.get_country():
|
|
|
|
self.writeln("3 CTRY %s" % self.cnvtxt(addr.get_country()))
|
|
|
|
if addr.get_phone():
|
|
|
|
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:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(text),'\r',' '))
|
2004-02-14 11:10:30 +05:30
|
|
|
if addr.get_note():
|
|
|
|
self.write_long_text("NOTE",2,self.cnvtxt(addr.get_note()))
|
|
|
|
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 ()
|
2003-11-03 17:28:15 +05:30
|
|
|
else:
|
|
|
|
photos = []
|
|
|
|
|
|
|
|
for photo in photos:
|
2004-07-28 07:59:07 +05:30
|
|
|
photo_obj_id = photo.get_reference_handle()
|
2004-08-07 10:46:57 +05:30
|
|
|
photo_obj = self.db.get_object_from_handle(photo_obj_id)
|
2004-07-14 07:14:04 +05:30
|
|
|
if photo_obj and photo_obj.get_mime_type() == "image/jpeg":
|
2003-11-03 17:28:15 +05:30
|
|
|
self.writeln('1 OBJE')
|
2003-11-03 17:48:48 +05:30
|
|
|
self.writeln('2 FORM jpeg')
|
2004-07-14 07:14:04 +05:30
|
|
|
path = photo_obj.get_path ()
|
2003-11-03 17:28:15 +05:30
|
|
|
dirname = os.path.join (self.dirname, self.images_path)
|
|
|
|
basename = os.path.basename (path)
|
|
|
|
self.writeln('2 FILE %s' % os.path.join(self.images_path,
|
2004-06-10 05:29:03 +05:30
|
|
|
basename))
|
2003-11-03 17:28:15 +05:30
|
|
|
try:
|
|
|
|
os.mkdir (dirname)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
dest = os.path.join (dirname, basename)
|
|
|
|
try:
|
|
|
|
os.link (path, dest)
|
|
|
|
except OSError, e:
|
|
|
|
file (dest,
|
|
|
|
"wb").writelines (file (path,
|
|
|
|
"rb").xreadlines ())
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for family in person.get_parent_family_handle_list():
|
2004-06-10 05:29:03 +05:30
|
|
|
if self.flist.has_key(family[0]):
|
|
|
|
self.writeln("1 FAMC @%s@" % self.fid(family[0]))
|
2003-01-15 10:55:50 +05:30
|
|
|
if self.adopt == GedcomInfo.ADOPT_PEDI:
|
2004-06-10 05:29:03 +05:30
|
|
|
if family[1].lower() == "adopted":
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("2 PEDI Adopted")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
if family_handle != None and self.flist.has_key(family_handle):
|
|
|
|
self.writeln("1 FAMS @%s@" % self.fid(family_handle))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
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():
|
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:
|
2004-02-14 11:10:30 +05:30
|
|
|
if person.get_note():
|
|
|
|
self.write_long_text("NOTE",1,self.cnvtxt(person.get_note()))
|
2003-07-22 15:44:49 +05:30
|
|
|
|
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)
|
|
|
|
while ll > 0:
|
|
|
|
brkpt = 70
|
|
|
|
if ll > brkpt:
|
|
|
|
while (ll > brkpt and line[brkpt] in string.whitespace):
|
|
|
|
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)
|
|
|
|
while ll > 0:
|
|
|
|
brkpt = 70
|
|
|
|
if ll > brkpt:
|
|
|
|
while (ll > brkpt and line[brkpt] not in string.whitespace):
|
|
|
|
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 dump_event_stats(self,event):
|
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)
|
2004-07-28 07:59:07 +05:30
|
|
|
if event.get_place_handle():
|
2004-08-07 10:46:57 +05:30
|
|
|
place_name = self.db.get_place_from_handle(event.get_place_handle()).get_title()
|
2004-06-10 05:29:03 +05:30
|
|
|
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(place_name),'\r',' '))
|
2004-02-14 11:10:30 +05:30
|
|
|
if event.get_cause():
|
|
|
|
self.writeln("2 CAUS %s" % self.cnvtxt(event.get_cause()))
|
|
|
|
if event.get_note():
|
|
|
|
self.write_long_text("NOTE",2,self.cnvtxt(event.get_note()))
|
|
|
|
for srcref in event.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_source_ref(2,srcref)
|
|
|
|
|
|
|
|
def write_ord(self,name,ord,index,statlist):
|
|
|
|
if ord == None:
|
|
|
|
return
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln('%d %s' % (index,name))
|
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():
|
|
|
|
self.writeln('%d FAMC @%s@' % (index+1,self.fid(ord.get_family_handle().get_handle())))
|
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():
|
2004-08-07 10:46:57 +05:30
|
|
|
place_name = self.db.get_place_from_handle(ord.get_place_handle()).get_title()
|
2004-06-10 05:29:03 +05:30
|
|
|
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(place_name),'\r',' '))
|
2004-02-14 11:10:30 +05:30
|
|
|
if ord.get_status() != 0:
|
|
|
|
self.writeln("2 STAT %s" % self.cnvtxt(statlist[ord.get_status()]))
|
|
|
|
if ord.get_note():
|
|
|
|
self.write_long_text("NOTE",index+1,self.cnvtxt(ord.get_note()))
|
|
|
|
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()
|
2004-02-14 11:10:30 +05:30
|
|
|
val = date.get_text()
|
2003-07-07 16:27:11 +05:30
|
|
|
if val:
|
|
|
|
self.writeln("%s %s" % (prefix,self.cnvtxt(val)))
|
2004-02-14 11:10:30 +05:30
|
|
|
elif not date.is_empty ():
|
2004-06-10 05:29:03 +05:30
|
|
|
if date.is_range():
|
2002-12-29 11:14:35 +05:30
|
|
|
val = "FROM %s TO %s" % (make_date(start),
|
|
|
|
make_date(date.get_stop_date()))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2002-12-30 06:12:47 +05:30
|
|
|
val = make_date(start)
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%s %s" % (prefix,val))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_person_name(self,name,nick):
|
2004-02-14 11:10:30 +05:30
|
|
|
firstName = self.cnvtxt(name.get_first_name())
|
|
|
|
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 == "":
|
|
|
|
self.writeln("1 NAME %s/%s/" % (firstName,surName))
|
2002-12-04 10:28:07 +05:30
|
|
|
else:
|
2004-06-28 06:57:37 +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 == "":
|
|
|
|
self.writeln("1 NAME %s/%s/%s" % (firstName,surName,suffix))
|
2002-12-04 10:28:07 +05:30
|
|
|
else:
|
2004-06-28 06:57:37 +05:30
|
|
|
self.writeln("1 NAME %s/%s %s/%s" % (firstName,surPref,surName,suffix))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_first_name():
|
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)
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_note():
|
|
|
|
self.write_long_text("NOTE",2,self.cnvtxt(name.get_note()))
|
|
|
|
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):
|
2004-07-28 07:59:07 +05:30
|
|
|
if ref.get_base_handle() == None:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2003-01-03 08:49:50 +05:30
|
|
|
|
|
|
|
if self.source_refs:
|
2003-06-28 23:05:00 +05:30
|
|
|
self.writeln("%d SOUR @%s@" %
|
2004-07-28 07:59:07 +05:30
|
|
|
(level,self.sid(ref.get_base_handle())))
|
2004-02-14 11:10:30 +05:30
|
|
|
if ref.get_page() != "":
|
|
|
|
self.write_long_text("PAGE",level+1,self.cnvtxt(ref.get_page()))
|
2004-06-10 05:29:03 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
ref_text = ref.get_text()
|
|
|
|
if ref_text != "" or not ref.get_date().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)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.print_date(pfx,ref.get_date())
|
2003-01-03 08:49:50 +05:30
|
|
|
else:
|
|
|
|
# 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.
|
2004-07-28 07:59:07 +05:30
|
|
|
sbase = ref.get_base_handle()
|
2004-02-14 11:10:30 +05:30
|
|
|
if sbase and sbase.get_title():
|
|
|
|
txt = sbase.get_title() + ". "
|
2003-01-03 08:49:50 +05:30
|
|
|
else:
|
|
|
|
txt = ""
|
2004-02-14 11:10:30 +05:30
|
|
|
if ref.get_page():
|
|
|
|
txt = txt + ref.get_page() + ". "
|
2003-01-03 08:49:50 +05:30
|
|
|
self.g.write("%d SOUR %s" % (level,self.cnvtxt(txt)))
|
2004-02-14 11:10:30 +05:30
|
|
|
if not ref.get_date().is_empty():
|
|
|
|
self.print_date("", ref.get_date())
|
2003-01-03 08:49:50 +05:30
|
|
|
else:
|
2004-06-10 05:29:03 +05:30
|
|
|
self.writeln("")
|
2004-02-14 11:10:30 +05:30
|
|
|
if ref.get_text():
|
|
|
|
ref_text = ref.get_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
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if ref.get_comments():
|
|
|
|
self.write_long_text("NOTE",level+1,self.cnvtxt(ref.get_comments()))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def fid(self,id):
|
|
|
|
return id
|
2004-06-10 05:29:03 +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
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def frefn(self,family_handle):
|
|
|
|
match = _get_int.search(family_handle)
|
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
|
|
|
|
|
|
|
def sid(self,id):
|
|
|
|
if self.sidmap.has_key(id):
|
|
|
|
return self.sidmap[id]
|
|
|
|
else:
|
|
|
|
val = "S%05d" % self.sidval
|
|
|
|
self.sidval = self.sidval + 1
|
|
|
|
self.sidmap[id] = val
|
|
|
|
return val
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-07-11 11:33:07 +05:30
|
|
|
def exportData(database,filename,person,option_box):
|
2004-07-11 05:01:28 +05:30
|
|
|
ret = 0
|
|
|
|
try:
|
2004-07-11 11:33:07 +05:30
|
|
|
gw = GedcomWriter(database,person,0,filename,option_box)
|
2004-07-14 07:14:04 +05:30
|
|
|
ret = gw.export_data(filename)
|
2004-07-11 05:01:28 +05:30
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
return ret
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
_title = _('GE_DCOM 5.5')
|
|
|
|
_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
|
|
|
#option_box = GedcomWriterOptionBox()
|
|
|
|
_config = (_('GEDCOM export options'),GedcomWriterOptionBox)
|
2004-07-11 05:01:28 +05:30
|
|
|
_filename = 'ged'
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-11 05:01:28 +05:30
|
|
|
from Plugins import register_export
|
|
|
|
register_export(exportData,_title,_description,_config,_filename)
|