Updates for dynamic GEDCOM, and drag/drop

svn: r608
This commit is contained in:
Don Allingham 2001-12-05 02:02:14 +00:00
parent 1d7204e7d9
commit c78037f9f9
14 changed files with 696 additions and 119 deletions

View File

@ -218,7 +218,6 @@ fi
AC_SUBST(P21_INCLUDES)
if test "$PYTHON22" != ""; then
INTLLIBS="${INTLLIBS}intl22.so "
py_prefix=`$PYTHON22 -c "import sys; print sys.prefix"`
py_exec_prefix=`$PYTHON22 -c "import sys; print sys.exec_prefix"`
P22_INCLUDES="-I${py_prefix}/include/python2.2"

View File

@ -54,6 +54,7 @@ rm -rf $RPM_BUILD_ROOT
%{prefix}/share/pixmaps/gramps.png
%{prefix}/share/locale/*/LC_MESSAGES/gramps.mo
%{prefix}/share/gramps/*.py
%{prefix}/share/gramps/data/*.xml
%{prefix}/share/gramps/*.pyo
%{prefix}/share/gramps/*.so
%{prefix}/share/gramps/*.glade

View File

@ -50,7 +50,7 @@ _fmonth = [
_fmonth2num = {
"vend" : 0, "brum" : 1, "frim" : 2, "nivo" : 3, "pluv" : 4,
"vent" : 5, "germ" : 6, "flor" : 7, "prai" : 8, "mess" : 9,
"ther" :10, "fruc" :11, "extr" : 12,"nivô" : 3 }
"ther" :10, "fruc" :11, "extr" : 12,"comp" :12, "nivô" : 3 }
_hmonth = [
"Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI",
@ -341,7 +341,7 @@ class SingleDate:
"after" : after,
"before" : before }
modifiers = "(" + \
modifiers = '(' + \
_("abt\.?") + '|' + \
_("about") + '|' + \
_("est\.?") + '|' + \
@ -350,12 +350,8 @@ class SingleDate:
_("before") + '|' + \
_("after") + '|' + \
_("aft\.?") + '|' + \
_("bef\.?") + '|' + \
"abt" + '|' + \
"aft" + '|' + \
"after" + '|' + \
"before" + '|' + \
"bef" + ')'
_("bef\.?") + \
'|abt|aft|after|before|bef)'
start = "^\s*" + modifiers + "?\s*"
@ -487,7 +483,7 @@ class SingleDate:
retval = "%d %s %d" % (self.day,month,self.year)
if self.mode == SingleDate.about:
retval = "ABT %s" % retval
retval = "ABOUT %s" % retval
elif self.mode == SingleDate.before:
retval = "BEFORE" + " " + retval
elif self.mode == SingleDate.after:
@ -573,7 +569,7 @@ class SingleDate:
retval = "%d %s %d" % (self.day,string.upper(month[0:3]),self.year)
if self.mode == SingleDate.about:
retval = "%s %s" % (_("ABT"),retval)
retval = "%s %s" % (_("ABOUT"),retval)
elif self.mode == SingleDate.before:
retval = "%s %s" % (_("BEFORE"),retval)
elif self.mode == SingleDate.after:
@ -601,7 +597,7 @@ class SingleDate:
retval = "%d. %s %d" % (self.day,month,self.year)
if self.mode == SingleDate.about:
retval = "%s %s" % (_("ABT"),retval)
retval = "%s %s" % (_("ABOUT"),retval)
elif self.mode == SingleDate.before:
retval = "%s %s" % (_("BEFORE"),retval)
elif self.mode == SingleDate.after:
@ -628,7 +624,7 @@ class SingleDate:
retval = "%02d%s%02d%s%04d" % (self.month+1,sep,self.day,sep,self.year)
if self.mode == SingleDate.about:
retval = "%s %s" % (_("ABT"),retval)
retval = "%s %s" % (_("ABOUT"),retval)
elif self.mode == SingleDate.before:
retval = "%s %s" % (_("BEFORE"),retval)
elif self.mode == SingleDate.after:
@ -657,7 +653,7 @@ class SingleDate:
retval = "%02d%s%02d%s%02d" % (self.year,sep,self.month+1,sep,self.day)
if self.mode == SingleDate.about:
retval = "%s %s" % (_("ABT"),retval)
retval = "%s %s" % (_("ABOUT"),retval)
if self.mode == SingleDate.before:
retval = "%s %s" % (_("BEFORE"),retval)
@ -696,7 +692,7 @@ class SingleDate:
retval = "%02d%s%02d%s%04d" % (self.day,sep,self.month+1,sep,self.year)
if self.mode == SingleDate.about:
retval = "%s %s" % (_("ABT"),retval)
retval = "%s %s" % (_("ABOUT"),retval)
if self.mode == SingleDate.before:
retval = "%s %s" % (_("BEFORE"),retval)
elif self.mode == SingleDate.after:

View File

@ -24,6 +24,7 @@
#
#-------------------------------------------------------------------------
import string
import pickle
#-------------------------------------------------------------------------
#
@ -56,6 +57,11 @@ _temple_names = const.lds_temple_codes.keys()
_temple_names.sort()
_temple_names = [""] + _temple_names
pycode_tgts = [('url', 0, 0),
('pevent', 0, 1),
('pattr', 0, 2),
('paddr', 0, 3)]
#-------------------------------------------------------------------------
#
# EditPerson class
@ -220,6 +226,8 @@ class EditPerson:
self.attr_list.set_column_visibility(2,Config.show_detail)
self.addr_list.set_column_visibility(2,Config.show_detail)
self.event_list = self.get_widget("eventList")
if Config.display_attr:
self.get_widget("user_label").set_text(Config.attr_name)
val = ""
@ -308,7 +316,10 @@ class EditPerson:
index = 0
hist = 0
for fam in [person.getMainFamily()] + person.getAltFamilyList():
flist = [person.getMainFamily()]
for (fam,mrel,frel) in person.getAltFamilyList():
flist.append(fam)
for fam in flist:
if fam == None:
continue
f = fam.getFather()
@ -331,7 +342,27 @@ class EditPerson:
hist = index
self.ldsseal_fam.set_menu(myMenu)
self.ldsseal_fam.set_history(hist)
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,GDK.ACTION_COPY)
self.event_list.drag_source_set(GDK.BUTTON1_MASK, pycode_tgts, GDK.ACTION_COPY)
self.event_list.connect('drag_data_get', self.ev_source_drag_data_get)
self.event_list.connect('drag_data_received', self.ev_dest_drag_data_received)
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,GDK.ACTION_COPY)
self.web_list.drag_source_set(GDK.BUTTON1_MASK, pycode_tgts, GDK.ACTION_COPY)
self.web_list.connect('drag_data_get', self.url_source_drag_data_get)
self.web_list.connect('drag_data_received', self.url_dest_drag_data_received)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,GDK.ACTION_COPY)
self.attr_list.drag_source_set(GDK.BUTTON1_MASK, pycode_tgts, GDK.ACTION_COPY)
self.attr_list.connect('drag_data_get', self.at_source_drag_data_get)
self.attr_list.connect('drag_data_received', self.at_dest_drag_data_received)
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,GDK.ACTION_COPY)
self.addr_list.drag_source_set(GDK.BUTTON1_MASK, pycode_tgts, GDK.ACTION_COPY)
self.addr_list.connect('drag_data_get', self.ad_source_drag_data_get)
self.addr_list.connect('drag_data_received', self.ad_dest_drag_data_received)
# draw lists
self.redraw_event_list()
self.redraw_attr_list()
@ -340,6 +371,113 @@ class EditPerson:
self.redraw_url_list()
self.window.show()
def ev_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
exec 'mytype = "%s"' % data[0]
exec 'person = "%s"' % data[1]
if person == self.person.getId() or mytype != 'pevent':
return
foo = pickle.loads(data[2]);
for src in foo.getSourceRefList():
base = src.getBase()
newbase = self.db.findSourceNoMap(base.getId())
src.setBase(newbase)
place = foo.getPlace()
if place:
foo.setPlace(self.db.findPlaceNoMap(place.getId()))
self.elist.append(foo)
self.lists_changed = 1
self.redraw_event_list()
def ev_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('pevent',self.person.getId(),pickled));
selection_data.set(selection_data.target, bits_per, data)
def url_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
exec 'mytype = "%s"' % data[0]
exec 'person = "%s"' % data[1]
if person == self.person.getId() or mytype != 'url':
return
foo = pickle.loads(data[2]);
self.ulist.append(foo)
self.lists_changed = 1
self.redraw_url_list()
def url_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('url',self.person.getId(),pickled));
selection_data.set(selection_data.target, bits_per, data)
def at_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
exec 'mytype = "%s"' % data[0]
exec 'person = "%s"' % data[1]
if person == self.person.getId() or mytype != 'pattr':
return
foo = pickle.loads(data[2]);
for src in foo.getSourceRefList():
base = src.getBase()
newbase = self.db.findSourceNoMap(base.getId())
src.setBase(newbase)
self.alist.append(foo)
self.lists_changed = 1
self.redraw_attr_list()
def at_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('pattr',self.person.getId(),pickled));
selection_data.set(selection_data.target, bits_per, data)
def ad_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
exec 'mytype = "%s"' % data[0]
exec 'person = "%s"' % data[1]
if person == self.person.getId() or mytype != 'paddr':
return
foo = pickle.loads(data[2]);
for src in foo.getSourceRefList():
base = src.getBase()
newbase = self.db.findSourceNoMap(base.getId())
src.setBase(newbase)
self.plist.append(foo)
self.lists_changed = 1
self.redraw_addr_list()
def ad_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('paddr',self.person.getId(),pickled));
selection_data.set(selection_data.target, bits_per, data)
def menu_changed(self,obj):
self.ldsfam = obj.get_data("f")

View File

@ -18,11 +18,15 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import pickle
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
import GDK
import libglade
#-------------------------------------------------------------------------
@ -40,6 +44,8 @@ import ImageSelect
from intl import gettext
_ = gettext
pycode_tgts = [('url', 0, 0)]
#-------------------------------------------------------------------------
#
# Constants
@ -142,9 +148,37 @@ class EditPlace:
self.top_window.get_widget("add_photo").set_sensitive(0)
self.top_window.get_widget("delete_photo").set_sensitive(0)
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,GDK.ACTION_COPY)
self.web_list.drag_source_set(GDK.BUTTON1_MASK, pycode_tgts, GDK.ACTION_COPY)
self.web_list.connect('drag_data_get', self.url_source_drag_data_get)
self.web_list.connect('drag_data_received', self.url_dest_drag_data_received)
self.redraw_url_list()
self.redraw_location_list()
def url_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
exec 'mytype = "%s"' % data[0]
exec 'place = "%s"' % data[1]
if place == self.place.getId() or mytype != 'url':
return
foo = pickle.loads(data[2]);
self.ulist.append(foo)
self.lists_changed = 1
self.redraw_url_list()
def url_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('url',self.place.getId(),pickled));
selection_data.set(selection_data.target, bits_per, data)
def update_lists(self):
self.place.setUrlList(self.ulist)
self.place.set_alternate_locations(self.llist)

229
gramps/src/GedcomInfo.py Normal file
View File

@ -0,0 +1,229 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import const
from latin_utf8 import utf8_to_latin
u2l = utf8_to_latin
ADOPT_NONE = 0
ADOPT_EVENT = 1
ADOPT_FTW = 2
ADOPT_LEGACY = 3
ADOPT_PEDI = 4
ADOPT_STD = 5
CONC_OK = 0
CONC_BROKEN = 1
ALT_NAME_NONE = 0
ALT_NAME_STD = 1
ALT_NAME_ALIAS = 2
ALT_NAME_AKA = 3
ALT_NAME_EVENT_AKA = 4
CALENDAR_NO = 0
CALENDAR_YES = 1
OBJE_NO = 0
OBJE_YES = 1
RESIDENCE_ADDR = 0
RESIDENCE_PLAC = 1
#-------------------------------------------------------------------------
#
# XML parser
#
#-------------------------------------------------------------------------
import xml.parsers.expat
class GedcomDescription:
def __init__(self,name):
self.name = name
self.dest = ""
self.adopt = ADOPT_STD
self.conc = CONC_OK
self.altname = ALT_NAME_STD
self.cal = CALENDAR_YES
self.obje = OBJE_YES
self.resi = RESIDENCE_ADDR
self.gramps2tag_map = {}
self.tag2gramps_map = {}
def set_dest(self,val):
self.dest = val
def get_dest(self):
return self.dest
def set_adopt(self,val):
self.adopt = val
def get_adopt(self):
return self.adopt
def set_conc(self,val):
self.conc = val
def get_conc(self):
return self.conc
def set_alt_name(self,val):
self.altname = val
def get_alt_name(self):
return self.altname
def set_alt_calendar(self,val):
self.cal = val
def get_alt_calendar(self):
return self.cal
def set_obje(self,val):
self.obje = val
def get_obje(self):
return self.obje
def set_resi(self,val):
self.resi = val
def get_resi(self):
return self.resi
def add_tag_value(self,tag,value):
self.gramps2tag_map[value] = tag
self.tag2gramps_map[tag] = value
def gramps2tag(self,key):
if self.gramps2tag_map.has_key(key):
return self.gramps2tag_map[key]
return ""
def tag2gramps(self,key):
if self.tag2gramps_map.has_key(key):
return self.tag2gramps_map[key]
return key
class GedcomInfoDB:
def __init__(self):
self.map = {}
self.standard = GedcomDescription("GEDCOM 5.5 standard")
self.standard.set_dest("GEDCOM 5.5")
try:
file = "%s/gedcom.xml" % const.dataDir
f = open(file,"r")
except:
return
try:
parser = GedInfoParser(self)
parser.parse(f)
f.close()
except:
pass
def add_description(self,name,obj):
self.map[name] = obj
def get_description(self,name):
if self.map.has_key(name):
return self.map[name]
return self.standard
def get_from_source_tag(self,name):
for k in self.map.keys():
val = self.map[k]
if val.get_dest() == name:
return val
return self.standard
def get_name_list(self):
mylist = self.map.keys()
mylist.sort()
return ["GEDCOM 5.5 standard"] + mylist
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class GedInfoParser:
def __init__(self,parent):
self.parent = parent
self.current = None
def parse(self,file):
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = self.startElement
p.ParseFile(file)
def startElement(self,tag,attrs):
tag = u2l(tag)
if tag == "target":
name = u2l(attrs['name'])
self.current = GedcomDescription(name)
self.parent.add_description(name,self.current)
elif tag == "dest":
self.current.set_dest(u2l(attrs['val']))
elif tag == "adopt":
val = u2l(attrs['val'])
if val == 'none':
self.current.set_adopt(ADOPT_NONE)
elif val == 'event':
self.current.set_adopt(ADOPT_EVENT)
elif val == 'ftw':
self.current.set_adopt(ADOPT_FTW)
elif val == 'legacy':
self.current.set_adopt(ADOPT_LEGACY)
elif val == 'pedigree':
self.current.set_adopt(ADOPT_PEDI)
elif tag == "conc":
if u2l(attrs['val']) == 'broken':
self.current.set_conc(CONC_BROKEN)
elif tag == "alternate_names":
val = u2l(attrs['val'])
if val == 'none':
self.current.set_alt_name(ALT_NAME_NONE)
elif val == 'event_aka':
self.current.set_alt_name(ALT_NAME_EVENT_AKA)
elif val == 'alias':
self.current.set_alt_name(ALT_NAME_ALIAS)
elif val == 'aka':
self.current.set_alt_name(ALT_NAME_AKA)
elif tag == "calendars":
if u2l(attrs['val']) == 'no':
self.current.set_alt_calendar(CALENDAR_NO)
elif tag == "event":
self.current.add_tag_value(u2l(attrs['tag']),u2l(attrs['value']))
elif tag == "object_support":
if u2l(attrs['val']) == 'no':
self.current.set_obje(OBJE_NO)
elif tag == "residence":
if u2l(attrs['val']) == 'place':
self.current.set_resi(RESIDENCE_PLAC)
if __name__ == "__main__":
g = GedcomInfoDB()
print g.get_name_list()
o = g.get_description("Family Tree Maker")
for key in o.gramps2tag_map.keys():
print key,o.gramps2tag(key)

View File

@ -18,11 +18,15 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import pickle
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
import GDK
from gnome.ui import *
import libglade
@ -45,6 +49,9 @@ _temple_names = const.lds_temple_codes.keys()
_temple_names.sort()
_temple_names = [""] + _temple_names
pycode_tgts = [('fevent', 0, 0),
('fattr', 0, 1)]
#-------------------------------------------------------------------------
#
# Marriage class
@ -135,6 +142,16 @@ class Marriage:
else:
self.lds_temple.entry.set_text("")
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,GDK.ACTION_COPY)
self.event_list.drag_source_set(GDK.BUTTON1_MASK, pycode_tgts, GDK.ACTION_COPY)
self.event_list.connect('drag_data_get', self.ev_source_drag_data_get)
self.event_list.connect('drag_data_received', self.ev_dest_drag_data_received)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,GDK.ACTION_COPY)
self.attr_list.drag_source_set(GDK.BUTTON1_MASK, pycode_tgts, GDK.ACTION_COPY)
self.attr_list.connect('drag_data_get', self.at_source_drag_data_get)
self.attr_list.connect('drag_data_received', self.at_dest_drag_data_received)
# set notes data
self.notes_field.set_point(0)
self.notes_field.insert_defaults(family.getNote())
@ -148,6 +165,63 @@ class Marriage:
self.redraw_attr_list()
top_window.show()
def ev_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
exec 'mytype = "%s"' % data[0]
exec 'family = "%s"' % data[1]
if family == self.family.getId() or mytype != 'fevent':
return
foo = pickle.loads(data[2]);
for src in foo.getSourceRefList():
base = src.getBase()
newbase = self.db.findSourceNoMap(base.getId())
src.setBase(newbase)
place = foo.getPlace()
if place:
foo.setPlace(self.db.findPlaceNoMap(place.getId()))
self.elist.append(foo)
self.lists_changed = 1
self.redraw_event_list()
def ev_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('fevent',self.family.getId(),pickled));
selection_data.set(selection_data.target, bits_per, data)
def at_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
exec 'mytype = "%s"' % data[0]
exec 'family = "%s"' % data[1]
if family == self.family.getId() or mytype != 'fattr':
return
foo = pickle.loads(data[2]);
for src in foo.getSourceRefList():
base = src.getBase()
newbase = self.db.findSourceNoMap(base.getId())
src.setBase(newbase)
self.alist.append(foo)
self.lists_changed = 1
self.redraw_attr_list()
def at_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('fattr',self.family.getId(),pickled));
selection_data.set(selection_data.target, bits_per, data)
#-------------------------------------------------------------------------
#
#

View File

@ -209,6 +209,7 @@ personalConstantEvents = {
"Baptism" : "BAPM",
"Bar Mitzvah" : "BARM",
"Bas Mitzvah" : "BASM",
"Blessing" : "BLES",
"Burial" : "BURI",
"Cause Of Death" : "CAUS",
"Ordination" : "ORID",
@ -216,16 +217,18 @@ personalConstantEvents = {
"Christening" : "CHR" ,
"Confirmation" : "CONF",
"Cremation" : "CREM",
"Degree" : "_DEG",
"Degree" : "",
"Divorce Filing" : "DIVF",
"Education" : "EDUC",
"Elected" : "_ELEC",
"Elected" : "",
"Emigration" : "EMIG",
"First Communion" : "FCOM",
"Graduation" : "GRAD",
"Medical Information" : "_MDCL",
"Military Service" : "_MILT",
"Medical Information" : "",
"Military Service" : "",
"Naturalization" : "NATU",
"Nobility Title" : "TITL",
"Number of Marriages" : "NMR",
"Immigration" : "IMMI",
"Occupation" : "OCCU",
"Probate" : "PROB",
@ -244,6 +247,7 @@ _pe_e2l = {
"Baptism" : _("Baptism"),
"Bar Mitzvah" : _("Bar Mitzvah"),
"Bas Mitzvah" : _("Bas Mitzvah"),
"Blessing" : _("Blessing"),
"Burial" : _("Burial"),
"Cause Of Death" : _("Cause Of Death"),
"Census" : _("Census"),
@ -261,6 +265,8 @@ _pe_e2l = {
"Medical Information" : _("Medical Information"),
"Military Service" : _("Military Service"),
"Naturalization" : _("Naturalization"),
"Nobility Title" : _("Nobility Title"),
"Number of Marriages" : _("Number of Marriages"),
"Occupation" : _("Occupation"),
"Ordination" : _("Ordination"),
"Probate" : _("Probate"),
@ -273,7 +279,9 @@ _pe_e2l = {
_pe_l2e = {}
for a in _pe_e2l.keys():
_pe_l2e[_pe_e2l[a]] = a
val = _pe_e2l[a]
if val:
_pe_l2e[val] = a
#-------------------------------------------------------------------------
#

View File

@ -3,7 +3,7 @@ exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@/@PACKAGE@
INSTALL = @INSTALL@
data = ${datadir}
data = ${datadir}/data
pycomp = ${srcdir}/py-compile
@SET_MAKE@
@ -11,6 +11,8 @@ pycomp = ${srcdir}/py-compile
all:
install:
${INSTALL} -d ${data}
${INSTALL} gedcom.xml ${data}
uninstall:

107
gramps/src/data/gedcom.xml Normal file
View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<targets>
<target name="Brother's Keeper">
<dest val="BROSKEEP"/>
<adopt val="none"/>
<conc val="standard"/>
<alternate_names val="none"/>
<calendar val="no"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
<target name="Family Origins">
<dest val="FamilyOrigins"/>
<adopt val="event"/>
<conc val="broken"/>
<alternate_names val="event_aka"/>
<calendar val="no"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
<target name="Family Tree Maker">
<dest val="FTW"/>
<adopt val="ftw"/>
<conc val="broken"/>
<alternate_names val="alias"/>
<calendar val="no"/>
<extended_events>
<event tag="_DEG" value="Degree"/>
<event tag="_ELEC" value="Elected"/>
<event tag="_MDCL" value="Medical Information"/>
<event tag="_MILT" value="Military Service"/>
</extended_events>
<object_support val="no"/>
<residence val="place"/>
</target>
<target name="Ftree">
<dest val=""/>
<adopt val="none"/>
<conc val="broken"/>
<alternate_names val="none"/>
<calendar val="no"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
<target name="GeneWeb">
<dest val=""/>
<adopt val="event_extended"/>
<conc val="standard"/>
<alternate_names val="none"/>
<calendar val="yes"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
<target name="Legacy">
<dest val="Legacy"/>
<adopt val="legacy"/>
<conc val="broken"/>
<alternate_names val="standard"/>
<calendar val="no"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
<target name="Personal Ancestral File">
<dest val="PAF"/>
<adopt val="pedigree"/>
<conc val="standard"/>
<alternate_names val="aka"/>
<calendar val="no"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
<target name="Reunion">
<dest val="REUNION"/>
<adopt val="none"/>
<conc val="broken"/>
<alternate_names val="none"/>
<calendar val="no"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
<target name="Visual Genealogie">
<dest val=""/>
<adopt val="none"/>
<conc val="broken"/>
<alternate_names val="none"/>
<calendar val="no"/>
<extended_events>
</extended_events>
<object_support val="no"/>
<residence val="address"/>
</target>
</targets>

View File

@ -40,8 +40,18 @@ import gtk
import gnome.ui
import libglade
import xml.parsers.expat
_ = intl.gettext
#-------------------------------------------------------------------------
#
# Unicode to latin conversion
#
#-------------------------------------------------------------------------
from latin_utf8 import utf8_to_latin
u2l = utf8_to_latin
#------------------------------------------------------------------------
#
#
@ -264,8 +274,7 @@ class ComplexFilterFile:
self.fname = name
try:
f = open(self.fname)
parser = make_parser()
parser.setContentHandler(ComplexFilterParser(self))
parser = ComplexFilterParser(self)
parser.parse(f)
f.close()
except IOError:
@ -295,25 +304,32 @@ class ComplexFilterFile:
f.write('</filterlist>\n')
f.close()
class ComplexFilterParser(handler.ContentHandler):
class ComplexFilterParser:
def __init__(self,parent):
self.parent = parent
self.curfilter = []
self.curname = ""
def parse(self,f):
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = self.startElement
p.EndElementHandler = self.endElement
p.ParseFile(f)
def startElement(self,tag,attrs):
tag = u2l(tag)
if tag == "complex_filter":
self.curname = attrs['name']
self.curname = u2l(attrs['name'])
self.curfilter = []
elif tag == "filter":
name = attrs['name']
qual = attrs['text']
name = u2l(attrs['name'])
qual = u2l(attrs['text'])
invert = int(attrs['invert'])
f = Filter.make_filter_from_name(name,qual,invert)
self.curfilter.append(f)
def endElement(self,tag):
if tag == "complex_filter":
if u2l(tag) == "complex_filter":
self.parent.filters[self.curname] = self.curfilter
#------------------------------------------------------------------------

View File

@ -25,6 +25,8 @@ import Date
import latin_ansel
import latin_utf8
import intl
from GedcomInfo import *
_ = intl.gettext
import os
@ -163,6 +165,8 @@ class GedcomParser:
self.fmap = {}
self.smap = {}
self.nmap = {}
self.gedmap = GedcomInfoDB()
self.gedsource = None
self.dir_path = os.path.dirname(file)
self.localref = 0
self.placemap = {}
@ -634,7 +638,11 @@ class GedcomParser:
self.parse_person_attr(attr,2)
continue
else:
event.setName(matches[1])
val = self.gedsource.tag2gramps(matches[1])
if val:
event.setName(val)
else:
event.setName(matches[1])
self.parse_person_event(event,2)
if matches[2] != None:
@ -899,7 +907,11 @@ class GedcomParser:
if ged2gramps.has_key(matches[2]):
name = ged2gramps[matches[2]]
else:
name = matches[2]
val = self.gedsource.tag2gramps(matches[2])
if val:
name = val
else:
name = matches[2]
event.setName(name)
elif matches[1] == "DATE":
foo = self.extract_date(matches[2])
@ -1054,7 +1066,11 @@ class GedcomParser:
if ged2gramps.has_key(matches[2]):
name = ged2gramps[matches[2]]
else:
name = matches[2]
val = self.gedsource.tag2gramps(matches[2])
if val:
name = val
else:
name = matches[2]
attr.setName(name)
elif matches[1] == ["CAUS", "DATE","TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]:
self.ignore_sub_junk(level+1)
@ -1098,9 +1114,6 @@ class GedcomParser:
attr.setNote(note)
def parse_family_event(self,event,level):
global ged2fam
global ged2gramps
while 1:
matches = self.get_next()
if int(matches[0]) < level:
@ -1286,7 +1299,7 @@ class GedcomParser:
self.index = self.index + 1
def parse_header_source(self):
genby = ""
while 1:
matches = self.get_next()
@ -1296,12 +1309,11 @@ class GedcomParser:
elif matches[1] == "SOUR":
if self.created_obj.get_text() == "":
self.update(self.created_obj,matches[2])
if matches[2] in self.broken_conc_list:
self.broken_conc = 1
else:
self.broken_conc = 0
self.gedsource = self.gedmap.get_from_source_tag(matches[2])
self.broken_conc = self.gedsource.get_conc()
if matches[2] == "FTW":
self.is_ftw = 1
genby = matches[2]
elif matches[1] == "NAME":
self.update(self.created_obj,matches[2])
elif matches[1] == "VERS":
@ -1315,7 +1327,9 @@ class GedcomParser:
elif matches[1] == "SUBN":
pass
elif matches[1] == "DEST":
pass
if genby == "GRAMPS":
self.gedsource = self.gedmap.get_from_source_tag(matches[2])
self.broken_conc = self.gedsource.get_conc()
elif matches[1] == "FILE":
self.ignore_sub_junk(2)
elif matches[1] == "COPR":

View File

@ -34,56 +34,10 @@ import gtk
import gnome.ui
import libglade
from GedcomInfo import *
from latin_ansel import latin_to_ansel
from latin_utf8 import latin_to_utf8
#-------------------------------------------------------------------------
#
# GEDCOM feature support
#
#-------------------------------------------------------------------------
_ADOP_NONE = 0
_ADOP_EVENT = 1
_ADOP_FTW = 2
_ADOP_LEGACY = 3
_ADOP_PEDI = 4
_ADOP_EVEXT = 5
_CONC_OK = 0
_CONC_BROKEN = 1
_ALT_NONE = 0
_ALT_STD = 1
_ALT_ALIAS = 2
_ALT_AKA = 3
_ALT_EVAKA = 4
_CAL_NO = 0
_CAL_YES = 1
_EVEN_NONE = 0
_EVEN_GED = 1
_EVEN_FTW = 2
_OBJE_NO = 0
_OBJE_YES = 1
_RESI_ADDR = 0
_RESI_PLAC = 1
targets = [
("Standard GEDCOM 5.5","GEDCOM 5.5",_ADOP_EVEXT,_CONC_OK,_ALT_STD,_CAL_YES,_EVEN_GED,_OBJE_YES,_RESI_ADDR),
("Brother's Keeper","BROSKEEP",_ADOP_NONE,_CONC_OK,_ALT_NONE,_CAL_NO,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
("Family Origins","FamilyOrigins",_ADOP_EVENT,_CONC_BROKEN,_ALT_EVAKA,_CAL_NO,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
("Family Tree Maker","FTW",_ADOP_FTW,_CONC_BROKEN,_ALT_ALIAS,_CAL_NO,_EVEN_FTW,_OBJE_NO,_RESI_PLAC),
("Ftree","",_ADOP_NONE,_CONC_BROKEN,_ALT_NONE,_CAL_NO,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
("GeneWeb","",_ADOP_EVEXT,_CONC_OK,_ALT_NONE,_CAL_YES,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
("Legacy","Legacy",_ADOP_LEGACY,_CONC_BROKEN,_ALT_STD,_CAL_NO,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
("Personal Ancestral File","PAF",_ADOP_PEDI,_CONC_OK,_ALT_AKA,_CAL_NO,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
("Reunion", "REUNION", _ADOP_NONE,_CONC_BROKEN,_ALT_NONE,_CAL_NO,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
("Visual Genealogie","",_ADOP_NONE,_CONC_BROKEN,_ALT_NONE,_CAL_NO,_EVEN_GED,_OBJE_NO,_RESI_ADDR),
]
#-------------------------------------------------------------------------
#
# Calendar month names
@ -96,7 +50,7 @@ _hmonth = [
_fmonth = [
"", "VEND", "BRUM", "FRIM", "NIVO", "PLUV", "VENT",
"GERM", "FLOR", "PRAI", "MESS", "THER", "FRUC", "EXTR"]
"GERM", "FLOR", "PRAI", "MESS", "THER", "FRUC", "COMP"]
_month = [
"", "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
@ -336,7 +290,6 @@ def make_date(subdate,mmap):
retval = "BEF %s" % retval
elif mode == Date.SingleDate.after:
retval = "AFT %s" % retval
return retval
def fmtline(text,limit,level):
@ -424,7 +377,7 @@ class GedcomWriter:
self.plist = []
self.slist = []
self.flist = []
self.adopt = _ADOP_EVENT
self.adopt = ADOPT_EVENT
self.fidval = 0
self.fidmap = {}
self.pidval = 0
@ -466,12 +419,15 @@ class GedcomWriter:
filter_obj.set_menu(myMenu)
self.filter_menu = myMenu
gedmap = GedcomInfoDB()
target_obj = self.topDialog.get_widget("target")
myMenu = gtk.GtkMenu()
for (name,dest,adopt,conc,alt,cal,even,obje,resi) in targets:
for name in gedmap.get_name_list():
menuitem = gtk.GtkMenuItem(name)
myMenu.append(menuitem)
menuitem.set_data("data",(dest,adopt,conc,alt,cal,even,obje,resi))
data = gedmap.get_description(name)
menuitem.set_data("data",data)
menuitem.show()
target_obj.set_menu(myMenu)
@ -486,7 +442,17 @@ class GedcomWriter:
filter = self.filter_menu.get_active().get_data("filter")
act_tgt = self.target_menu.get_active()
(self.dest,self.adopt,self.conc,self.altname,self.cal,self.even,self.obje,self.resi) = act_tgt.get_data("data")
self.target_ged = act_tgt.get_data("data")
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()
if self.topDialog.get_widget("ansel").get_active():
self.cnvtxt = latin_to_ansel
@ -620,17 +586,13 @@ class GedcomWriter:
if self.private and event.getPrivacy():
continue
name = event.getName()
val = ""
if const.familyConstantEvents.has_key(name):
val = const.familyConstantEvents[name]
if val[0] == '_' and self.even != _EVEN_FTW:
val = ''
else:
val = ""
if val == "":
val = self.target_ged.gramps2tag(name)
if val != "":
if self.even == _EVEN_NONE:
continue
self.g.write("1 %s %s\n" % (self.cnvtxt(val),
self.cnvtxt(event.getDescription())))
else:
@ -641,7 +603,7 @@ class GedcomWriter:
for person in family.getChildList():
self.g.write("1 CHIL @%s@\n" % self.pid(person.getId()))
if self.adopt == _ADOP_FTW:
if self.adopt == ADOPT_FTW:
if person.getMainFamily() == family:
self.g.write('2 _FREL Natural\n')
self.g.write('2 _MREL Natural\n')
@ -651,7 +613,7 @@ class GedcomWriter:
self.g.write('2 _FREL %s\n' % f[2])
self.g.write('2 _MREL %s\n' % f[1])
break
if self.adopt == _ADOP_LEGACY:
if self.adopt == ADOPT_LEGACY:
for f in person.getAltFamilyList():
if f[0] == family:
self.g.write('2 _STAT %s\n' % f[2])
@ -691,7 +653,7 @@ class GedcomWriter:
self.write_person_name(person.getPrimaryName(),person.getNickName())
if self.altname == _ALT_STD:
if self.altname == ALT_NAME_STD:
for name in person.getAlternateNames():
self.write_person_name(name,"")
@ -728,14 +690,13 @@ class GedcomWriter:
if self.private and event.getPrivacy():
continue
name = event.getName()
val = ""
if const.personalConstantEvents.has_key(name):
val = const.personalConstantEvents[name]
if val[0] == '_' and self.even != _EVEN_FTW:
val = ''
else:
val = ""
if val == "":
val = self.target_ged.gramps2tag(name)
if self.adopt == _ADOP_EVENT and val == "ADOP":
if self.adopt == ADOPT_EVENT and val == "ADOP":
ad = 1
self.g.write('1 ADOP\n')
fam = None
@ -754,8 +715,6 @@ class GedcomWriter:
else:
self.g.write('3 ADOP HUSB\n')
elif val != "" :
if self.even == _EVEN_NONE:
continue
self.g.write("1 %s %s\n" % (self.cnvtxt(val),\
self.cnvtxt(event.getDescription())))
else:
@ -764,7 +723,7 @@ class GedcomWriter:
self.dump_event_stats(event)
if self.adopt == _ADOP_EVENT and ad == 0 and len(person.getAltFamilyList()) != 0:
if self.adopt == ADOPT_EVENT and ad == 0 and len(person.getAltFamilyList()) != 0:
self.g.write('1 ADOP\n')
fam = None
for f in person.getAltFamilyList():
@ -837,7 +796,7 @@ class GedcomWriter:
for family in person.getAltFamilyList():
self.g.write("1 FAMC @%s@\n" % self.fid(family[0].getId()))
if self.adopt == _ADOP_PEDI:
if self.adopt == ADOPT_PEDI:
if string.lower(family[1]) == "adopted":
self.g.write("2 PEDI Adopted\n")
@ -858,7 +817,7 @@ class GedcomWriter:
self.write_long_text("NOTE",1,person.getNote())
def write_long_text(self,tag,level,note):
if self.conc == _CONC_OK:
if self.conc == CONC_OK:
self.write_conc_ok(tag,level,note)
else:
self.write_conc_broken(tag,level,note)
@ -956,7 +915,7 @@ class GedcomWriter:
val = make_date(start,_month)
self.g.write("%s %s\n" % (prefix,val))
else:
if self.cal == _CAL_YES:
if self.cal == CALENDAR_YES:
(mlist,cal) = _calmap[date.get_calendar()]
if date.isRange():
stop = date.get_stop_date()

View File

@ -74,7 +74,7 @@ def reverse_name_sort(list):
#
#-------------------------------------------------------------------------
def fast_birth_sort(list):
nlist = map(build_sort_birth,list)
nlist = map(build_sort_event,list)
nlist.sort()
return map(lambda(key,x): x, nlist)
@ -84,7 +84,7 @@ def fast_birth_sort(list):
#
#-------------------------------------------------------------------------
def reverse_birth_sort(list):
nlist = map(build_sort_birth,list)
nlist = map(build_sort_event,list)
nlist.sort()
nlist.reverse()
return map(lambda(key,x): x, nlist)
@ -95,7 +95,7 @@ def reverse_birth_sort(list):
#
#-------------------------------------------------------------------------
def fast_death_sort(list):
nlist = map(build_sort_death,list)
nlist = map(build_sort_event,list)
nlist.sort()
return map(lambda(key,x): x, nlist)
@ -105,7 +105,7 @@ def fast_death_sort(list):
#
#-------------------------------------------------------------------------
def reverse_death_sort(list):
nlist = map(build_sort_death,list)
nlist = map(build_sort_event,list)
nlist.sort()
nlist.reverse()
return map(lambda(key,x): x, nlist)