2004-09-25 04:12:21 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2004 Martin Hawlisch
|
2008-01-15 14:46:45 +05:30
|
|
|
# Copyright (C) 2004-2006, 2008 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2009-04-10 16:11:28 +05:30
|
|
|
# Copyright (C) 2009 Gary Burton
|
2004-09-25 04:12:21 +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
|
|
|
|
#
|
2009-02-24 08:22:06 +05:30
|
|
|
# $Id$
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2008-01-17 03:12:05 +05:30
|
|
|
"Export to GeneWeb."
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard Python Modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2006-03-05 10:01:24 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Set up logging
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".WriteGeneWeb")
|
|
|
|
|
2004-09-25 04:12:21 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2009-04-17 00:59:40 +05:30
|
|
|
from Filters import GenericFilter, Rules, build_filter_model
|
2008-01-15 14:46:45 +05:30
|
|
|
#import const
|
2004-09-25 04:12:21 +05:30
|
|
|
import Utils
|
|
|
|
from QuestionDialog import ErrorDialog
|
2008-11-04 09:42:51 +05:30
|
|
|
from gen.plug import PluginManager, ExportPlugin
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2009-04-17 00:59:40 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2009-05-15 01:45:59 +05:30
|
|
|
# GeneWebWriterOptionBox class
|
2004-09-25 04:12:21 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-05-21 22:49:50 +05:30
|
|
|
class GeneWebWriterOptionBox(object):
|
2004-09-25 04:12:21 +05:30
|
|
|
"""
|
|
|
|
Create a VBox with the option widgets and define methods to retrieve
|
2008-01-17 03:12:05 +05:30
|
|
|
the options.
|
|
|
|
|
2004-09-25 04:12:21 +05:30
|
|
|
"""
|
2008-01-15 14:46:45 +05:30
|
|
|
def __init__(self, person):
|
2004-09-25 04:12:21 +05:30
|
|
|
self.person = person
|
|
|
|
|
|
|
|
def get_option_box(self):
|
|
|
|
self.restrict = 1
|
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.topDialog = Glade()
|
2009-04-17 00:59:40 +05:30
|
|
|
self.topDialog.connect_signals({
|
2004-09-25 04:12:21 +05:30
|
|
|
"on_restrict_toggled": self.on_restrict_toggled
|
|
|
|
})
|
|
|
|
|
2009-04-17 00:59:40 +05:30
|
|
|
self.filters = self.topDialog.get_object("filter")
|
2004-09-25 04:12:21 +05:30
|
|
|
self.copy = 0
|
|
|
|
|
2006-05-03 06:32:54 +05:30
|
|
|
all = GenericFilter()
|
2004-09-25 04:12:21 +05:30
|
|
|
all.set_name(_("Entire Database"))
|
2006-05-03 11:59:07 +05:30
|
|
|
all.add_rule(Rules.Person.Everyone([]))
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2006-10-11 10:29:26 +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") %
|
|
|
|
self.person.get_primary_name().get_name())
|
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]))
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2006-05-03 06:32:54 +05:30
|
|
|
ans = GenericFilter()
|
2005-07-09 01:54:54 +05:30
|
|
|
ans.set_name(_("Ancestors of %s") %
|
|
|
|
self.person.get_primary_name().get_name())
|
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]))
|
2004-09-25 04:12:21 +05:30
|
|
|
|
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") %
|
2004-09-25 04:12:21 +05:30
|
|
|
self.person.get_primary_name().get_name())
|
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()]))
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2008-02-03 08:20:09 +05:30
|
|
|
the_filters += [des, ans, com]
|
2006-10-11 10:29:26 +05:30
|
|
|
|
|
|
|
from Filters import CustomFilters
|
|
|
|
the_filters.extend(CustomFilters.get_filters('Person'))
|
2009-04-17 00:59:40 +05:30
|
|
|
self.filter_menu = build_filter_model(the_filters)
|
|
|
|
self.filters.set_model(self.filter_menu)
|
|
|
|
self.filters.set_active(0)
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2009-04-17 00:59:40 +05:30
|
|
|
the_box = self.topDialog.get_object('vbox1')
|
|
|
|
the_parent = self.topDialog.get_object('dialog-vbox1')
|
2004-09-25 04:12:21 +05:30
|
|
|
the_parent.remove(the_box)
|
2009-05-15 01:45:59 +05:30
|
|
|
self.topDialog.toplevel.destroy()
|
2004-09-25 04:12:21 +05:30
|
|
|
return the_box
|
|
|
|
|
2008-01-15 14:46:45 +05:30
|
|
|
def on_restrict_toggled(self, restrict):
|
2004-09-25 04:12:21 +05:30
|
|
|
active = restrict.get_active ()
|
2009-04-17 00:59:40 +05:30
|
|
|
for x in [self.topDialog.get_object("living"),
|
2009-04-30 09:19:03 +05:30
|
|
|
self.topDialog.get_object("notes")]:
|
2008-07-04 22:57:51 +05:30
|
|
|
x.set_sensitive(active)
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
def parse_options(self):
|
2009-04-17 00:59:40 +05:30
|
|
|
self.restrict = self.topDialog.get_object("restrict").get_active()
|
2004-09-25 04:12:21 +05:30
|
|
|
self.living = (self.restrict and
|
2009-04-17 00:59:40 +05:30
|
|
|
self.topDialog.get_object("living").get_active())
|
2004-09-25 04:12:21 +05:30
|
|
|
self.exclnotes = (self.restrict and
|
2009-04-17 00:59:40 +05:30
|
|
|
self.topDialog.get_object("notes").get_active())
|
|
|
|
self.cfilter = self.filter_menu[self.filters.get_active()][1]
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2009-04-17 00:59:40 +05:30
|
|
|
self.images = self.topDialog.get_object ("images").get_active ()
|
2004-09-25 04:12:21 +05:30
|
|
|
if self.images:
|
2009-04-17 00:59:40 +05:30
|
|
|
images_path = self.topDialog.get_object ("images_path")
|
2004-09-25 04:12:21 +05:30
|
|
|
self.images_path = unicode(images_path.get_text ())
|
|
|
|
else:
|
|
|
|
self.images_path = ""
|
|
|
|
|
2009-05-21 22:49:50 +05:30
|
|
|
class GeneWebWriter(object):
|
2008-11-04 09:42:51 +05:30
|
|
|
def __init__(self, database, filename="", option_box=None,
|
2008-01-15 14:46:45 +05:30
|
|
|
callback=None):
|
2004-09-25 04:12:21 +05:30
|
|
|
self.db = database
|
|
|
|
self.option_box = option_box
|
|
|
|
self.filename = filename
|
2006-05-10 01:08:15 +05:30
|
|
|
self.callback = callback
|
2008-07-14 21:17:15 +05:30
|
|
|
if callable(self.callback): # callback is really callable
|
2006-05-10 01:08:15 +05:30
|
|
|
self.update = self.update_real
|
|
|
|
else:
|
|
|
|
self.update = self.update_empty
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
self.plist = {}
|
|
|
|
self.flist = {}
|
|
|
|
|
|
|
|
self.persons_details_done = []
|
|
|
|
self.persons_notes_done = []
|
|
|
|
self.person_ids = {}
|
|
|
|
|
|
|
|
if not option_box:
|
2008-11-04 09:42:51 +05:30
|
|
|
self.restrict = 0
|
|
|
|
self.copy = 0
|
|
|
|
self.images = 0
|
2004-09-25 04:12:21 +05:30
|
|
|
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.copy = self.option_box.copy
|
|
|
|
self.images = self.option_box.images
|
|
|
|
self.images_path = self.option_box.images_path
|
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
if not option_box.cfilter.is_empty():
|
|
|
|
self.db = gen.proxy.FilterProxyDb(self.db, option_box.cfilter)
|
|
|
|
|
|
|
|
for p in self.db.get_person_handles(sort_handles=False):
|
|
|
|
self.plist[p] = 1
|
|
|
|
|
|
|
|
self.flist = {}
|
|
|
|
for key in self.plist:
|
|
|
|
p = self.db.get_person_from_handle(key)
|
|
|
|
for family_handle in p.get_family_handle_list():
|
|
|
|
self.flist[family_handle] = 1
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
# remove families that dont contain father AND mother
|
|
|
|
# because GeneWeb requires both to be present
|
|
|
|
templist = self.flist
|
|
|
|
self.flist = {}
|
|
|
|
for family_handle in templist:
|
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
if family:
|
|
|
|
father_handle = family.get_father_handle()
|
|
|
|
mother_handle = family.get_mother_handle()
|
|
|
|
if father_handle and mother_handle:
|
|
|
|
self.flist[family_handle] = 1
|
|
|
|
|
|
|
|
|
2006-05-10 01:08:15 +05:30
|
|
|
def update_empty(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_real(self):
|
|
|
|
self.count += 1
|
|
|
|
newval = int(100*self.count/self.total)
|
|
|
|
if newval != self.oldval:
|
|
|
|
self.callback(newval)
|
|
|
|
self.oldval = newval
|
|
|
|
|
2008-01-15 14:46:45 +05:30
|
|
|
def writeln(self, text):
|
2004-09-25 04:12:21 +05:30
|
|
|
self.g.write(self.iso8859('%s\n' % (text)))
|
|
|
|
|
2005-02-20 00:35:48 +05:30
|
|
|
def export_data(self):
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2005-02-20 00:35:48 +05:30
|
|
|
self.dirname = os.path.dirname (self.filename)
|
2004-09-25 04:12:21 +05:30
|
|
|
try:
|
2008-01-15 14:46:45 +05:30
|
|
|
self.g = open(self.filename, "w")
|
2004-09-25 04:12:21 +05:30
|
|
|
except IOError,msg:
|
2005-02-20 00:35:48 +05:30
|
|
|
msg2 = _("Could not create %s") % self.filename
|
2008-01-15 14:46:45 +05:30
|
|
|
ErrorDialog(msg2, str(msg))
|
|
|
|
return False
|
2004-09-25 04:12:21 +05:30
|
|
|
except:
|
2005-02-20 00:35:48 +05:30
|
|
|
ErrorDialog(_("Could not create %s") % self.filename)
|
2008-01-15 14:46:45 +05:30
|
|
|
return False
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
if len(self.flist) < 1:
|
|
|
|
ErrorDialog(_("No families matched by selected filter"))
|
2008-01-15 14:46:45 +05:30
|
|
|
return False
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-05-10 01:08:15 +05:30
|
|
|
self.count = 0
|
2006-05-10 01:15:18 +05:30
|
|
|
self.oldval = 0
|
2006-05-10 01:08:15 +05:30
|
|
|
self.total = len(self.flist)
|
2004-09-25 04:12:21 +05:30
|
|
|
for key in self.flist:
|
|
|
|
self.write_family(key)
|
|
|
|
self.writeln("")
|
|
|
|
|
|
|
|
self.g.close()
|
2008-01-15 14:46:45 +05:30
|
|
|
return True
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2008-01-15 14:46:45 +05:30
|
|
|
def write_family(self, family_handle):
|
2004-09-25 04:12:21 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
if family:
|
2006-05-10 01:08:15 +05:30
|
|
|
self.update()
|
2004-09-25 04:12:21 +05:30
|
|
|
father_handle = family.get_father_handle()
|
|
|
|
if father_handle:
|
|
|
|
father = self.db.get_person_from_handle(father_handle)
|
|
|
|
mother_handle = family.get_mother_handle()
|
|
|
|
if mother_handle:
|
|
|
|
mother = self.db.get_person_from_handle(mother_handle)
|
2009-04-17 00:59:40 +05:30
|
|
|
self.writeln("fam %s %s +%s %s %s" %
|
|
|
|
(self.get_ref_name(father),
|
|
|
|
self.get_full_person_info_fam(father),
|
|
|
|
self.get_wedding_data(family),
|
|
|
|
self.get_ref_name(mother),
|
|
|
|
self.get_full_person_info_fam(mother)
|
|
|
|
)
|
|
|
|
)
|
2004-09-25 04:12:21 +05:30
|
|
|
self.write_witness( family)
|
|
|
|
self.write_sources( family.get_source_references())
|
|
|
|
self.write_children( family, father)
|
|
|
|
self.write_notes( family, father, mother)
|
|
|
|
if not (self.restrict and self.exclnotes):
|
2007-07-20 17:33:35 +05:30
|
|
|
notelist = family.get_note_list()
|
|
|
|
note = ""
|
|
|
|
for notehandle in notelist:
|
|
|
|
noteobj = self.db.get_note_from_handle(notehandle)
|
2009-04-17 00:59:40 +05:30
|
|
|
note += noteobj.get() + " "
|
2004-09-25 04:12:21 +05:30
|
|
|
if note and note != "":
|
|
|
|
note = note.replace('\n\r',' ')
|
|
|
|
note = note.replace('\r\n',' ')
|
|
|
|
note = note.replace('\n',' ')
|
|
|
|
note = note.replace('\r',' ')
|
|
|
|
self.writeln("comm %s" % note)
|
|
|
|
|
2008-01-15 14:46:45 +05:30
|
|
|
def write_witness(self, family):
|
2006-05-10 01:08:15 +05:30
|
|
|
# FIXME: witnesses are not in events anymore
|
|
|
|
return
|
|
|
|
|
2004-09-25 04:12:21 +05:30
|
|
|
if self.restrict:
|
|
|
|
return
|
2006-05-10 01:08:15 +05:30
|
|
|
event_ref_list = family.get_event_ref_list()
|
|
|
|
for event_ref in event_ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
2008-06-02 06:29:14 +05:30
|
|
|
if event.type == gen.lib.EventType.MARRIAGE:
|
2004-09-25 04:12:21 +05:30
|
|
|
w_list = event.get_witness_list()
|
|
|
|
if w_list:
|
|
|
|
for witness in w_list:
|
2007-10-08 22:11:39 +05:30
|
|
|
if witness and witness.type == gen.lib.Event.ID:
|
2009-04-17 00:59:40 +05:30
|
|
|
person = self.db.get_person_from_handle(
|
|
|
|
witness.get_value())
|
2004-09-25 04:12:21 +05:30
|
|
|
if person:
|
|
|
|
gender = ""
|
2007-10-08 22:11:39 +05:30
|
|
|
if person.get_gender() == gen.lib.Person.MALE:
|
2004-09-25 04:12:21 +05:30
|
|
|
gender = "h"
|
2007-10-08 22:11:39 +05:30
|
|
|
elif person.get_gender() == gen.lib.Person.FEMALE:
|
2004-09-25 04:12:21 +05:30
|
|
|
gender = "f"
|
2009-04-17 00:59:40 +05:30
|
|
|
self.writeln("wit %s %s %s" %
|
|
|
|
(gender,
|
|
|
|
self.get_ref_name(person),
|
|
|
|
self.get_full_person_info_fam(person)
|
|
|
|
)
|
|
|
|
)
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
def write_sources(self,reflist):
|
|
|
|
if self.restrict and self.exclnotes:
|
|
|
|
return
|
|
|
|
|
|
|
|
if reflist:
|
2008-01-06 01:40:26 +05:30
|
|
|
for sr in reflist:
|
2006-05-23 05:26:57 +05:30
|
|
|
sbase = sr.get_reference_handle()
|
2004-09-25 04:12:21 +05:30
|
|
|
if sbase:
|
|
|
|
source = self.db.get_source_from_handle(sbase)
|
|
|
|
if source:
|
2009-04-17 00:59:40 +05:30
|
|
|
self.writeln( "src %s" %
|
|
|
|
(self.rem_spaces(source.get_title()))
|
|
|
|
)
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
def write_children(self,family, father):
|
|
|
|
father_lastname = father.get_primary_name().get_surname()
|
2006-05-10 01:08:15 +05:30
|
|
|
child_ref_list = family.get_child_ref_list()
|
|
|
|
if child_ref_list:
|
2004-09-25 04:12:21 +05:30
|
|
|
self.writeln("beg")
|
2006-05-10 01:08:15 +05:30
|
|
|
for child_ref in child_ref_list:
|
|
|
|
child = self.db.get_person_from_handle(child_ref.ref)
|
2004-09-25 04:12:21 +05:30
|
|
|
if child:
|
|
|
|
gender = ""
|
2007-10-08 22:11:39 +05:30
|
|
|
if child.get_gender() == gen.lib.Person.MALE:
|
2004-09-25 04:12:21 +05:30
|
|
|
gender = "h"
|
2007-10-08 22:11:39 +05:30
|
|
|
elif child.get_gender() == gen.lib.Person.FEMALE:
|
2004-09-25 04:12:21 +05:30
|
|
|
gender = "f"
|
2009-04-17 00:59:40 +05:30
|
|
|
self.writeln("- %s %s %s" %
|
|
|
|
(gender,
|
|
|
|
self.get_child_ref_name(child, father_lastname),
|
|
|
|
self.get_full_person_info_child(child)
|
|
|
|
)
|
|
|
|
)
|
2004-09-25 04:12:21 +05:30
|
|
|
self.writeln("end")
|
|
|
|
|
|
|
|
def write_notes(self,family, father, mother):
|
|
|
|
if self.restrict and self.exclnotes:
|
|
|
|
return
|
|
|
|
|
|
|
|
self.write_note_of_person(father)
|
|
|
|
self.write_note_of_person(mother)
|
2006-05-10 01:08:15 +05:30
|
|
|
child_ref_list = family.get_child_ref_list()
|
|
|
|
if child_ref_list:
|
|
|
|
for child_ref in child_ref_list:
|
|
|
|
child = self.db.get_person_from_handle(child_ref.ref)
|
2004-09-25 04:12:21 +05:30
|
|
|
if child:
|
|
|
|
self.write_note_of_person(child)
|
2006-05-10 01:08:15 +05:30
|
|
|
# FIXME: witnesses do not exist in events anymore
|
|
|
|
## event_ref_list = family.get_event_ref_list()
|
|
|
|
## for event_ref in event_ref_list:
|
|
|
|
## event = self.db.get_event_from_handle(event_ref.ref)
|
2007-10-08 22:11:39 +05:30
|
|
|
## if int(event.get_type()) == gen.lib.EventType.MARRIAGE:
|
2006-05-10 01:08:15 +05:30
|
|
|
## w_list = event.get_witness_list()
|
|
|
|
## if w_list:
|
|
|
|
## for witness in w_list:
|
2007-10-08 22:11:39 +05:30
|
|
|
## if witness and witness.type == gen.lib.Event.ID:
|
2006-05-10 01:08:15 +05:30
|
|
|
## person = self.db.get_person_from_handle(witness.get_value())
|
|
|
|
## if person:
|
|
|
|
## self.write_note_of_person(person)
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
def write_note_of_person(self,person):
|
|
|
|
if self.persons_notes_done.count(person.get_handle()) == 0:
|
|
|
|
self.persons_notes_done.append(person.get_handle())
|
2007-07-20 17:33:35 +05:30
|
|
|
|
|
|
|
notelist = person.get_note_list()
|
|
|
|
note = ""
|
|
|
|
for notehandle in notelist:
|
|
|
|
noteobj = self.db.get_note_from_handle(notehandle)
|
2008-11-04 09:42:51 +05:30
|
|
|
note += noteobj.get()
|
2007-07-20 17:33:35 +05:30
|
|
|
note += " "
|
|
|
|
|
2004-09-25 04:12:21 +05:30
|
|
|
if note and note != "":
|
|
|
|
self.writeln("")
|
|
|
|
self.writeln("notes %s" % self.get_ref_name(person))
|
|
|
|
self.writeln("beg")
|
|
|
|
self.writeln(note)
|
|
|
|
self.writeln("end notes")
|
|
|
|
|
|
|
|
def get_full_person_info(self, person):
|
|
|
|
if self.restrict:
|
|
|
|
return "0 "
|
|
|
|
|
|
|
|
retval = ""
|
|
|
|
|
|
|
|
b_date = "0"
|
|
|
|
b_place = ""
|
2006-05-10 01:08:15 +05:30
|
|
|
birth_ref = person.get_birth_ref()
|
|
|
|
if birth_ref:
|
|
|
|
birth = self.db.get_event_from_handle(birth_ref.ref)
|
2004-09-25 04:12:21 +05:30
|
|
|
if birth:
|
|
|
|
b_date = self.format_date( birth.get_date_object())
|
|
|
|
place_handle = birth.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
b_place = place.get_title()
|
|
|
|
|
2004-10-08 09:29:55 +05:30
|
|
|
if Utils.probably_alive(person,self.db):
|
2004-09-25 04:12:21 +05:30
|
|
|
d_date = ""
|
|
|
|
else:
|
|
|
|
d_date = "0"
|
|
|
|
d_place = ""
|
2006-05-10 01:08:15 +05:30
|
|
|
death_ref = person.get_death_ref()
|
|
|
|
if death_ref:
|
|
|
|
death = self.db.get_event_from_handle(death_ref.ref)
|
2004-09-25 04:12:21 +05:30
|
|
|
if death:
|
|
|
|
d_date = self.format_date( death.get_date_object())
|
|
|
|
place_handle = death.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
d_place = place.get_title()
|
|
|
|
|
|
|
|
retval = retval + "%s " % b_date
|
|
|
|
if b_place != "":
|
|
|
|
retval = retval + "#bp %s " % self.rem_spaces(b_place)
|
|
|
|
retval = retval + "%s " % d_date
|
|
|
|
if d_place != "":
|
|
|
|
retval = retval + "#dp %s " % self.rem_spaces(d_place)
|
|
|
|
return retval
|
|
|
|
|
|
|
|
def get_full_person_info_fam(self, person):
|
2008-01-17 03:12:05 +05:30
|
|
|
"""Output full person data of a family member.
|
|
|
|
|
|
|
|
This is only done if the person is not listed as a child.
|
|
|
|
|
|
|
|
"""
|
2004-09-25 04:12:21 +05:30
|
|
|
retval = ""
|
|
|
|
if self.persons_details_done.count(person.get_handle()) == 0:
|
|
|
|
is_child = 0
|
|
|
|
pf_list = person.get_parent_family_handle_list()
|
|
|
|
if pf_list:
|
2006-05-10 01:08:15 +05:30
|
|
|
for family_handle in pf_list:
|
2008-07-17 23:40:32 +05:30
|
|
|
if family_handle in self.flist:
|
2004-09-25 04:12:21 +05:30
|
|
|
is_child = 1
|
|
|
|
if is_child == 0:
|
|
|
|
self.persons_details_done.append(person.get_handle())
|
|
|
|
retval = self.get_full_person_info(person)
|
|
|
|
return retval
|
|
|
|
|
|
|
|
|
|
|
|
def get_full_person_info_child(self, person):
|
2008-01-17 03:12:05 +05:30
|
|
|
"""Output full person data for a child, if not printed somewhere else."""
|
2004-09-25 04:12:21 +05:30
|
|
|
retval = ""
|
|
|
|
if self.persons_details_done.count(person.get_handle()) == 0:
|
|
|
|
self.persons_details_done.append(person.get_handle())
|
|
|
|
retval = self.get_full_person_info(person)
|
|
|
|
return retval
|
|
|
|
|
2004-10-26 08:50:38 +05:30
|
|
|
def rem_spaces(self,str):
|
|
|
|
return str.replace(' ','_')
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
def get_ref_name(self,person):
|
|
|
|
surname = self.rem_spaces( person.get_primary_name().get_surname())
|
2008-02-02 16:07:51 +05:30
|
|
|
firstname = _("Living")
|
2009-04-17 00:59:40 +05:30
|
|
|
if not (Utils.probably_alive(person,self.db) and \
|
|
|
|
self.restrict and self.living):
|
2004-09-25 04:12:21 +05:30
|
|
|
firstname = self.rem_spaces( person.get_primary_name().get_first_name())
|
2008-07-17 23:40:32 +05:30
|
|
|
if person.get_handle() not in self.person_ids:
|
2004-09-25 04:12:21 +05:30
|
|
|
self.person_ids[person.get_handle()] = len(self.person_ids)
|
2009-04-17 00:59:40 +05:30
|
|
|
return "%s %s.%d" % (surname, firstname,
|
|
|
|
self.person_ids[person.get_handle()])
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
def get_child_ref_name(self,person,father_lastname):
|
|
|
|
surname = self.rem_spaces( person.get_primary_name().get_surname())
|
2008-02-02 16:07:51 +05:30
|
|
|
firstname = _("Living")
|
2009-04-17 00:59:40 +05:30
|
|
|
if not (Utils.probably_alive(person,self.db) and \
|
|
|
|
self.restrict and self.living):
|
2004-09-25 04:12:21 +05:30
|
|
|
firstname = self.rem_spaces( person.get_primary_name().get_first_name())
|
2008-07-17 23:40:32 +05:30
|
|
|
if person.get_handle() not in self.person_ids:
|
2004-09-25 04:12:21 +05:30
|
|
|
self.person_ids[person.get_handle()] = len(self.person_ids)
|
2009-04-17 00:59:40 +05:30
|
|
|
ret = "%s.%d" % (firstname, self.person_ids[person.get_handle()])
|
|
|
|
if surname != father_lastname: ret += " " + surname
|
2004-09-25 04:12:21 +05:30
|
|
|
return ret
|
|
|
|
|
|
|
|
def get_wedding_data(self,family):
|
|
|
|
ret = "";
|
2006-05-10 01:08:15 +05:30
|
|
|
event_ref_list = family.get_event_ref_list()
|
2004-09-25 04:12:21 +05:30
|
|
|
m_date = ""
|
|
|
|
m_place = ""
|
|
|
|
m_source = ""
|
|
|
|
married = 0
|
|
|
|
eng_date = ""
|
|
|
|
eng_place = ""
|
|
|
|
eng_source = ""
|
2006-05-10 01:08:15 +05:30
|
|
|
engaged = 0
|
2004-09-25 04:12:21 +05:30
|
|
|
div_date = ""
|
|
|
|
divorced = 0
|
2006-05-10 01:08:15 +05:30
|
|
|
for event_ref in event_ref_list:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
2007-10-08 22:11:39 +05:30
|
|
|
if event.get_type() == gen.lib.EventType.MARRIAGE:
|
2004-09-25 04:12:21 +05:30
|
|
|
married = 1
|
|
|
|
m_date = self.format_date( event.get_date_object())
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
m_place = place.get_title()
|
|
|
|
m_source = self.get_primary_source( event.get_source_references())
|
2007-10-08 22:11:39 +05:30
|
|
|
if event.get_type() == gen.lib.EventType.ENGAGEMENT:
|
2006-05-10 01:08:15 +05:30
|
|
|
engaged = 1
|
2004-09-25 04:12:21 +05:30
|
|
|
eng_date = self.format_date( event.get_date_object())
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
eng_place = place.get_title()
|
|
|
|
eng_source = self.get_primary_source( event.get_source_references())
|
2007-10-08 22:11:39 +05:30
|
|
|
if event.get_type() == gen.lib.EventType.DIVORCE:
|
2004-09-25 04:12:21 +05:30
|
|
|
divorced = 1
|
|
|
|
div_date = self.format_date( event.get_date_object())
|
|
|
|
if married == 1:
|
|
|
|
if m_date != "":
|
|
|
|
ret = ret + m_date
|
|
|
|
ret = ret + " "
|
|
|
|
|
|
|
|
if m_place != "":
|
|
|
|
ret = ret + "#mp %s " % self.rem_spaces( m_place)
|
|
|
|
|
|
|
|
if m_source != "":
|
|
|
|
ret = ret + "#ms %s " % self.rem_spaces( m_source)
|
2006-05-10 01:08:15 +05:30
|
|
|
elif engaged == 1:
|
2004-09-25 04:12:21 +05:30
|
|
|
"""Geneweb only supports either Marriage or engagement"""
|
|
|
|
if eng_date != "":
|
|
|
|
ret = ret + eng_date
|
|
|
|
ret = ret + " "
|
|
|
|
|
|
|
|
if eng_place != "":
|
|
|
|
ret = ret + "#mp %s " % self.rem_spaces( m_place)
|
|
|
|
|
|
|
|
if eng_source != "":
|
|
|
|
ret = ret + "#ms %s " % self.rem_spaces( m_source)
|
|
|
|
else:
|
2007-10-08 22:11:39 +05:30
|
|
|
if family.get_relationship() != gen.lib.FamilyRelType.MARRIED:
|
2004-09-25 04:12:21 +05:30
|
|
|
"""Not married or engaged"""
|
|
|
|
ret = ret + " #nm "
|
|
|
|
|
|
|
|
if divorced == 1:
|
|
|
|
if div_date != "":
|
|
|
|
ret = ret + "-%s " %div_date
|
|
|
|
else:
|
|
|
|
ret = ret + "-0 "
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def get_primary_source(self,reflist):
|
|
|
|
ret = ""
|
|
|
|
if reflist:
|
|
|
|
for sr in reflist:
|
2006-05-23 05:26:57 +05:30
|
|
|
sbase = sr.get_reference_handle()
|
2004-09-25 04:12:21 +05:30
|
|
|
if sbase:
|
|
|
|
source = self.db.get_source_from_handle(sbase)
|
|
|
|
if source:
|
|
|
|
if ret != "":
|
|
|
|
ret = ret + ", "
|
|
|
|
ret = ret + source.get_title()
|
|
|
|
return ret
|
|
|
|
|
2008-01-15 14:46:45 +05:30
|
|
|
def format_single_date(self, subdate, cal, mode):
|
2004-09-25 04:12:21 +05:30
|
|
|
retval = ""
|
2008-01-15 14:46:45 +05:30
|
|
|
(day, month, year, sl) = subdate
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
cal_type = ""
|
2007-10-08 22:11:39 +05:30
|
|
|
if cal == gen.lib.Date.CAL_HEBREW:
|
2004-10-26 08:50:38 +05:30
|
|
|
cal_type = "H"
|
2007-10-08 22:11:39 +05:30
|
|
|
elif cal == gen.lib.Date.CAL_FRENCH:
|
2004-10-26 08:50:38 +05:30
|
|
|
cal_type = "F"
|
2007-10-08 22:11:39 +05:30
|
|
|
elif cal == gen.lib.Date.CAL_JULIAN:
|
2004-10-26 08:50:38 +05:30
|
|
|
cal_type = "J"
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
mode_prefix = ""
|
2007-10-08 22:11:39 +05:30
|
|
|
if mode == gen.lib.Date.MOD_ABOUT:
|
2004-09-25 04:12:21 +05:30
|
|
|
mode_prefix = "~"
|
2007-10-08 22:11:39 +05:30
|
|
|
elif mode == gen.lib.Date.MOD_BEFORE:
|
2004-09-25 04:12:21 +05:30
|
|
|
mode_prefix = "<"
|
2007-10-08 22:11:39 +05:30
|
|
|
elif mode == gen.lib.Date.MOD_AFTER:
|
2004-09-25 04:12:21 +05:30
|
|
|
mode_prefix = ">"
|
|
|
|
|
|
|
|
if year > 0:
|
|
|
|
if month > 0:
|
|
|
|
if day > 0:
|
|
|
|
retval = "%s%s/%s/%s%s" % (mode_prefix,day,month,year,cal_type)
|
|
|
|
else:
|
|
|
|
retval = "%s%s/%s%s" % (mode_prefix,month,year,cal_type)
|
|
|
|
else:
|
|
|
|
retval = "%s%s%s" % (mode_prefix,year,cal_type)
|
|
|
|
return retval
|
|
|
|
|
|
|
|
|
|
|
|
def format_date(self,date):
|
|
|
|
retval = ""
|
2007-12-20 10:40:24 +05:30
|
|
|
if date.get_modifier() == gen.lib.Date.MOD_TEXTONLY:
|
|
|
|
retval = "0(%s)" % self.rem_spaces(date.get_text())
|
2004-09-25 04:12:21 +05:30
|
|
|
elif not date.is_empty():
|
|
|
|
mod = date.get_modifier()
|
|
|
|
cal = cal = date.get_calendar()
|
2007-10-08 22:11:39 +05:30
|
|
|
if mod == gen.lib.Date.MOD_SPAN or mod == gen.lib.Date.MOD_RANGE:
|
2006-02-04 03:33:53 +05:30
|
|
|
retval = "%s..%s" % (
|
|
|
|
self.format_single_date(date.get_start_date(), cal,mod),
|
|
|
|
self.format_single_date(date.get_stop_date(),cal,mod))
|
2004-09-25 04:12:21 +05:30
|
|
|
else:
|
|
|
|
retval = self.format_single_date(date.get_start_date(),cal,mod)
|
|
|
|
return retval
|
|
|
|
|
|
|
|
def iso8859(self,s):
|
2005-12-06 12:08:09 +05:30
|
|
|
return s.encode('iso-8859-1','xmlcharrefreplace')
|
2004-09-25 04:12:21 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-11-04 09:42:51 +05:30
|
|
|
def exportData(database, filename, option_box=None, callback=None):
|
|
|
|
gw = GeneWebWriter(database, filename, option_box, callback)
|
2008-01-15 14:46:45 +05:30
|
|
|
return gw.export_data()
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
#------------------------------------------------------------------------
|
2004-09-25 04:12:21 +05:30
|
|
|
#
|
2008-11-04 09:42:51 +05:30
|
|
|
# Register with the plugin system
|
2004-09-25 04:12:21 +05:30
|
|
|
#
|
2008-11-04 09:42:51 +05:30
|
|
|
#------------------------------------------------------------------------
|
2004-09-25 04:12:21 +05:30
|
|
|
_description = _('GeneWeb is a web based genealogy program.')
|
2008-01-15 14:46:45 +05:30
|
|
|
_config = (_('GeneWeb export options'), GeneWebWriterOptionBox)
|
2004-09-25 04:12:21 +05:30
|
|
|
|
2008-05-19 00:54:28 +05:30
|
|
|
pmgr = PluginManager.get_instance()
|
2008-11-04 09:42:51 +05:30
|
|
|
plugin = ExportPlugin(name = _('_GeneWeb'),
|
|
|
|
description = _description,
|
|
|
|
export_function = exportData,
|
|
|
|
extension = "gw",
|
|
|
|
config = _config )
|
2009-02-24 08:22:06 +05:30
|
|
|
pmgr.register_plugin(plugin)
|