GrampsType support for FamilyRelations, Events

svn: r6371
This commit is contained in:
Don Allingham 2006-04-19 22:59:33 +00:00
parent 41b4119796
commit 41a9e9205c
28 changed files with 359 additions and 427 deletions

View File

@ -1,3 +1,32 @@
2006-04-19 Don Allingham <don@gramps-project.org>
* src/DataViews/_FamilyView.py: GrampsType support
* src/DataViews/_PedigreeView.py: GrampsType support
* src/GrampsDb/_ReadGedcom.py: GrampsType support
* src/GrampsDb/_GrampsDbBase.py: GrampsType support
* src/GrampsDb/_ReadXML.py: GrampsType support
* src/GrampsDb/_ConstXML.py: GrampsType support
* src/GrampsDb/_GrampsBSDDB.py: GrampsType support
* src/RelLib/_Family.py: GrampsType support
* src/RelLib/_Event.py: GrampsType support
* src/Editors/_EditEventRef.py: GrampsType support
* src/Editors/_EditFamily.py: GrampsType support
* src/Editors/_EditEvent.py: GrampsType support
* src/plugins/ImportvCard.py: GrampsType support
* src/plugins/GraphViz.py: GrampsType support
* src/plugins/Check.py: GrampsType support
* src/plugins/FamilyGroup.py: GrampsType support
* src/plugins/ExportVCalendar.py: GrampsType support
* src/plugins/Verify.py: GrampsType support
* src/DisplayModels.py: GrampsType support
* src/DisplayTabs.py: GrampsType support
* src/GrampsWidgets.py: GrampsType support
* src/SubstKeywords.py: GrampsType support
* src/Utils.py: GrampsType support
* src/ScratchPad.py: GrampsType support
* src/GenericFilter.py: GrampsType support
* src/PluginUtils/_ReportUtils.py: GrampsType support
* src/SelectEvent.py: GrampsType support
2006-04-19 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/TestcaseGenerator.py: Use the new types

View File

@ -602,8 +602,7 @@ class FamilyView(PageView.PersonNavView):
for event_ref in family.get_event_ref_list():
handle = event_ref.ref
event = self.dbstate.db.get_event_from_handle(handle)
etype = event.get_type()
if etype[0] == RelLib.Event.MARRIAGE:
if int(event.get_type()) == RelLib.EventType.MARRIAGE:
self.write_event_ref(_('Marriage'), event)
value = True
return value

View File

@ -358,7 +358,7 @@ class FormattingHelper:
text = ""
for event_ref in family.get_event_ref_list():
event = self.db.get_event_from_handle(event_ref.ref)
if event and event.get_type()[0] == RelLib.Event.MARRIAGE:
if event and int(event.get_type) == RelLib.EventType.MARRIAGE:
if line_count < 3:
return DateHandler.get_date(event)
(i,s) = event.get_type()
@ -1599,10 +1599,10 @@ def build_detail_string(db,person):
else:
for event_ref in person.get_event_ref_list():
event = db.get_event_from_handle(event_ref.ref)
if event and event.get_type()[0] == RelLib.Event.BAPTISM:
if event and int(event.get_type()) == RelLib.EventType.BAPTISM:
detail_text += format_event(db, _BAPT, event)
break
if event and event.get_type()[0] == RelLib.Event.CHRISTEN:
if event and int(event.get_type()) == RelLib.EventType.CHRISTEN:
detail_text += format_event(db, _CHRI, event)
break
@ -1613,10 +1613,10 @@ def build_detail_string(db,person):
else:
for event_ref in person.get_event_ref_list():
event = db.get_event_from_handle(event_ref.ref)
if event and event.get_type()[0] == RelLib.Event.BURIAL:
if event and int(event.get_type()) == RelLib.EventType.BURIAL:
detail_text += format_event(db, _BURI, event)
break
if event and event.get_type()[0] == RelLib.Event.CREMATION:
if event and int(event.get_type()) == RelLib.EventType.CREMATION:
detail_text += format_event(db, _CREM, event)
break

View File

@ -452,7 +452,7 @@ class FamilyModel(BaseModel):
return u""
def column_type(self,data):
return Utils.format_family_relation(data[5])
return str(RelLib.FamilyRelType(data[5]))
def column_id(self,data):
return unicode(data[1])
@ -608,7 +608,7 @@ class EventModel(BaseModel):
return u''
def column_type(self,data):
return Utils.format_event(data[2])
return str(RelLib.EventType(data[2]))
def column_id(self,data):
return unicode(data[1])

View File

@ -669,10 +669,10 @@ class EventEmbedList(EmbeddedList):
pass
def default_type(self):
return (RelLib.EventRef.FAMILY, '')
return RelLib.EventType(RelLib.EventType.MARRIAGE)
def default_role(self):
return (RelLib.Event.MARRIAGE, '')
return (RelLib.EventRef.FAMILY, '')
def add_button_clicked(self, obj):
try:
@ -744,13 +744,14 @@ class PersonEventEmbedList(EventEmbedList):
for event_ref in ref_list:
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
type_list.append(event.get_type()[0])
type_list.append(int(event.get_type()))
for etype in [RelLib.Event.BIRTH, RelLib.Event.DEATH]:
etype = event.get_type()
for etype in [RelLib.EventType.BIRTH, RelLib.EventType.DEATH]:
if etype not in type_list:
return (etype, '')
return RelLib.EventType(etype)
else:
return (RelLib.Event.BIRTH, '')
return RelLib.EventType(RelLib.EventType.BIRTH)
def get_ref_editor(self):
from Editors import EditEventRef
@ -763,9 +764,9 @@ class PersonEventEmbedList(EventEmbedList):
for ref in self.orig_data:
event = self.dbstate.db.get_event_from_handle(ref.ref)
if birth_ref == None and event.get_type()[0] == RelLib.Event.BIRTH:
if birth_ref == None and int(event.get_type()) == RelLib.EventType.BIRTH:
birth_ref = ref
elif death_ref == None and event.get_type()[0] == RelLib.Event.DEATH:
elif death_ref == None and int(event.get_type()) == RelLib.EventType.DEATH:
death_ref = ref
else:
new_list.append(ref)
@ -1965,7 +1966,7 @@ class EventRefModel(gtk.ListStore):
for event_ref in event_list:
event = db.get_event_from_handle(event_ref.ref)
self.append(row=[
self.column_type(event),
str(event.get_type()),
event.get_description(),
event.get_gramps_id(),
self.column_date(event_ref),
@ -1974,9 +1975,6 @@ class EventRefModel(gtk.ListStore):
event_ref
])
def column_type(self, event):
return Utils.format_event(event.get_type())
def column_role(self, event_ref):
return Utils.format_event_role(event_ref.get_role())
@ -2217,13 +2215,7 @@ class BackRefModel(gtk.ListStore):
name = p.get_description()
handle = p.handle
if not name:
etype = p.get_type()
if etype[0] == RelLib.Event.CUSTOM:
name = etype[1]
elif Utils.personal_events.has_key(etype[0]):
name = Utils.personal_events[etype[0]]
else:
name = Utils.family_events[etype[0]]
name = str(p.get_type())
elif dtype == 'Place':
p = self.db.get_place_from_handle(ref[1])
name = p.get_title()

View File

@ -131,12 +131,10 @@ class EditEvent(EditPrimary):
self.top.get_widget("private"),
self.obj, self.db.readonly)
self.event_menu = MonitoredType(
self.event_menu = MonitoredDataType(
self.top.get_widget("personal_events"),
self.obj.set_type,
self.obj.get_type,
self.get_base_events(),
RelLib.Event.CUSTOM,
custom_values=self.get_custom_events())
self.date_field = MonitoredDate(
@ -180,13 +178,7 @@ class EditEvent(EditPrimary):
def build_menu_names(self,event):
if event:
if event.get_type()[0] == RelLib.Event.CUSTOM:
event_name = event.get_type()[1]
else:
try:
event_name = Utils.personal_events[event.get_type()[0]]
except:
event_name = Utils.family_events[event.get_type()[0]]
event_name = str(event.get_type())
submenu_label = _('Event: %s') % event_name
else:
submenu_label = _('New Event')

View File

@ -59,10 +59,6 @@ from _EditReference import EditReference
# Constants
#
#-------------------------------------------------------------------------
total_events = dict(Utils.personal_events)
for event_type in Utils.family_events.keys():
if not total_events.has_key(event_type):
total_events[event_type] = Utils.family_events[event_type]
#-------------------------------------------------------------------------
#
@ -95,7 +91,8 @@ class EditEventRef(EditReference):
return Utils.personal_events
def get_custom_events(self):
return [ (RelLib.Event.CUSTOM,val) for val in self.dbstate.db.get_person_event_types()]
return [ (RelLib.EventType.CUSTOM,val) \
for val in self.dbstate.db.get_person_event_types()]
def _connect_signals(self):
self.define_ok_button(self.top.get_widget('ok'),self.ok_clicked)
@ -136,12 +133,10 @@ class EditEventRef(EditReference):
self.get_roles(),
RelLib.EventRef.CUSTOM)
self.event_menu = MonitoredType(
self.event_menu = MonitoredDataType(
self.top.get_widget("eer_type_combo"),
self.source.set_type,
self.source.get_type,
self.get_event_types(),
RelLib.Event.CUSTOM,
custom_values=self.get_custom_events())
self.date_check = MonitoredDate(
@ -187,13 +182,7 @@ class EditEventRef(EditReference):
def build_menu_names(self,eventref):
if self.source:
if self.source.get_type()[0] == RelLib.Event.CUSTOM:
event_name = self.source.get_type()[1]
else:
try:
event_name = Utils.personal_events[self.source.get_type()[0]]
except:
event_name = Utils.family_events[self.source.get_type()[0]]
event_name = str(self.source.get_type())
submenu_label = _('Event: %s') % event_name
else:
submenu_label = _('New Event')
@ -246,7 +235,7 @@ class EditFamilyEventRef(EditEventRef):
return Utils.family_events
def get_custom_events(self):
return [ (RelLib.Event.CUSTOM,val) for val in self.dbstate.db.get_family_event_types()]
return [ RelLib.EventType((RelLib.EventType.CUSTOM,val)) for val in self.dbstate.db.get_family_event_types()]
#-------------------------------------------------------------------------

View File

@ -409,12 +409,11 @@ class EditFamily(EditPrimary):
self.obj.get_gramps_id,
self.db.readonly)
self.data_type = MonitoredType(
self.data_type = MonitoredDataType(
self.top.get_widget('marriage_type'),
self.obj.set_relationship,
self.obj.get_relationship,
dict(Utils.family_relations),
RelLib.Family.CUSTOM)
)
def load_data(self):
fhandle = self.obj.get_father_handle()

View File

@ -1649,7 +1649,7 @@ class IsWitness(Rule):
wlist = event.get_witness_list()
if wlist:
for w in wlist:
if w.get_type()[0] == RelLib.Event.ID:
if int(w.get_type()) == RelLib.Event.ID:
self.map.append(w.get_value())

View File

@ -32,57 +32,57 @@ import RelLib
# Collection of standard types for various kinds of objects
#
#-------------------------------------------------------------------------
events = (
# Family events
(RelLib.Event.UNKNOWN , "Unknown"),
(RelLib.Event.MARRIAGE , "Marriage"),
(RelLib.Event.MARR_SETTL , "Marriage Settlement"),
(RelLib.Event.MARR_LIC , "Marriage License"),
(RelLib.Event.MARR_CONTR , "Marriage Contract"),
(RelLib.Event.MARR_BANNS , "Marriage Banns"),
(RelLib.Event.ENGAGEMENT , "Engagement"),
(RelLib.Event.DIVORCE , "Divorce"),
(RelLib.Event.DIV_FILING , "Divorce Filing"),
(RelLib.Event.ANNULMENT , "Annulment"),
(RelLib.Event.MARR_ALT , "Alternate Marriage"),
# Personal events
(RelLib.Event.UNKNOWN , "Unknown"),
(RelLib.Event.ADOPT , "Adopted"),
(RelLib.Event.BIRTH , "Birth"),
(RelLib.Event.DEATH , "Death"),
(RelLib.Event.ADULT_CHRISTEN , "Adult Christening"),
(RelLib.Event.BAPTISM , "Baptism"),
(RelLib.Event.BAR_MITZVAH , "Bar Mitzvah"),
(RelLib.Event.BAS_MITZVAH , "Bas Mitzvah"),
(RelLib.Event.BLESS , "Blessing"),
(RelLib.Event.BURIAL , "Burial"),
(RelLib.Event.CAUSE_DEATH , "Cause Of Death"),
(RelLib.Event.CENSUS , "Census"),
(RelLib.Event.CHRISTEN , "Christening"),
(RelLib.Event.CONFIRMATION , "Confirmation"),
(RelLib.Event.CREMATION , "Cremation"),
(RelLib.Event.DEGREE , "Degree"),
(RelLib.Event.DIV_FILING , "Divorce Filing"),
(RelLib.Event.EDUCATION , "Education"),
(RelLib.Event.ELECTED , "Elected"),
(RelLib.Event.EMIGRATION , "Emigration"),
(RelLib.Event.FIRST_COMMUN , "First Communion"),
(RelLib.Event.IMMIGRATION , "Immigration"),
(RelLib.Event.GRADUATION , "Graduation"),
(RelLib.Event.MED_INFO , "Medical Information"),
(RelLib.Event.MILITARY_SERV , "Military Service"),
(RelLib.Event.NATURALIZATION , "Naturalization"),
(RelLib.Event.NOB_TITLE , "Nobility Title"),
(RelLib.Event.NUM_MARRIAGES , "Number of Marriages"),
(RelLib.Event.OCCUPATION , "Occupation"),
(RelLib.Event.ORDINATION , "Ordination"),
(RelLib.Event.PROBATE , "Probate"),
(RelLib.Event.PROPERTY , "Property"),
(RelLib.Event.RELIGION , "Religion"),
(RelLib.Event.RESIDENCE , "Residence"),
(RelLib.Event.RETIREMENT , "Retirement"),
(RelLib.Event.WILL , "Will"),
)
# events = (
# # Family events
# (RelLib.Event.UNKNOWN , "Unknown"),
# (RelLib.Event.MARRIAGE , "Marriage"),
# (RelLib.Event.MARR_SETTL , "Marriage Settlement"),
# (RelLib.Event.MARR_LIC , "Marriage License"),
# (RelLib.Event.MARR_CONTR , "Marriage Contract"),
# (RelLib.Event.MARR_BANNS , "Marriage Banns"),
# (RelLib.Event.ENGAGEMENT , "Engagement"),
# (RelLib.Event.DIVORCE , "Divorce"),
# (RelLib.Event.DIV_FILING , "Divorce Filing"),
# (RelLib.Event.ANNULMENT , "Annulment"),
# (RelLib.Event.MARR_ALT , "Alternate Marriage"),
# # Personal events
# (RelLib.Event.UNKNOWN , "Unknown"),
# (RelLib.Event.ADOPT , "Adopted"),
# (RelLib.Event.BIRTH , "Birth"),
# (RelLib.Event.DEATH , "Death"),
# (RelLib.Event.ADULT_CHRISTEN , "Adult Christening"),
# (RelLib.Event.BAPTISM , "Baptism"),
# (RelLib.Event.BAR_MITZVAH , "Bar Mitzvah"),
# (RelLib.Event.BAS_MITZVAH , "Bas Mitzvah"),
# (RelLib.Event.BLESS , "Blessing"),
# (RelLib.Event.BURIAL , "Burial"),
# (RelLib.Event.CAUSE_DEATH , "Cause Of Death"),
# (RelLib.Event.CENSUS , "Census"),
# (RelLib.Event.CHRISTEN , "Christening"),
# (RelLib.Event.CONFIRMATION , "Confirmation"),
# (RelLib.Event.CREMATION , "Cremation"),
# (RelLib.Event.DEGREE , "Degree"),
# (RelLib.Event.DIV_FILING , "Divorce Filing"),
# (RelLib.Event.EDUCATION , "Education"),
# (RelLib.Event.ELECTED , "Elected"),
# (RelLib.Event.EMIGRATION , "Emigration"),
# (RelLib.Event.FIRST_COMMUN , "First Communion"),
# (RelLib.Event.IMMIGRATION , "Immigration"),
# (RelLib.Event.GRADUATION , "Graduation"),
# (RelLib.Event.MED_INFO , "Medical Information"),
# (RelLib.Event.MILITARY_SERV , "Military Service"),
# (RelLib.Event.NATURALIZATION , "Naturalization"),
# (RelLib.Event.NOB_TITLE , "Nobility Title"),
# (RelLib.Event.NUM_MARRIAGES , "Number of Marriages"),
# (RelLib.Event.OCCUPATION , "Occupation"),
# (RelLib.Event.ORDINATION , "Ordination"),
# (RelLib.Event.PROBATE , "Probate"),
# (RelLib.Event.PROPERTY , "Property"),
# (RelLib.Event.RELIGION , "Religion"),
# (RelLib.Event.RESIDENCE , "Residence"),
# (RelLib.Event.RETIREMENT , "Retirement"),
# (RelLib.Event.WILL , "Will"),
# )
attributes = (
(RelLib.Attribute.UNKNOWN , "Unknown"),
@ -166,7 +166,7 @@ marker_types = (
# mapping from the tuple collection to the appropriate CUSTOM integer
custom_types = {
events : RelLib.Event.CUSTOM,
# events : RelLib.Event.CUSTOM,
attributes : RelLib.Attribute.CUSTOM,
# family_relations : RelLib.Family.CUSTOM,
# name_types : RelLib.NameType.CUSTOM,

View File

@ -1451,52 +1451,52 @@ class GrampsBSDDB(GrampsDbBase):
# Event upgrade
event_conversion = {
"Alternate Marriage" : (Event.MARR_ALT,""),
"Annulment" : (Event.ANNULMENT,""),
"Divorce" : (Event.DIVORCE,""),
"Engagement" : (Event.ENGAGEMENT,""),
"Marriage Banns" : (Event.MARR_BANNS,""),
"Marriage Contract" : (Event.MARR_CONTR,""),
"Marriage License" : (Event.MARR_LIC,""),
"Marriage Settlement" : (Event.MARR_SETTL,""),
"Marriage" : (Event.MARRIAGE,""),
"Adopted" : (Event.ADOPT,""),
"Birth" : (Event.BIRTH,""),
"Alternate Birth" : (Event.BIRTH,""),
"Death" : (Event.DEATH,""),
"Alternate Death" : (Event.DEATH,""),
"Adult Christening" : (Event.ADULT_CHRISTEN,""),
"Baptism" : (Event.BAPTISM,""),
"Bar Mitzvah" : (Event.BAR_MITZVAH,""),
"Bas Mitzvah" : (Event.BAS_MITZVAH,""),
"Blessing" : (Event.BLESS,""),
"Burial" : (Event.BURIAL,""),
"Cause Of Death" : (Event.CAUSE_DEATH,""),
"Census" : (Event.CENSUS,""),
"Christening" : (Event.CHRISTEN,""),
"Confirmation" : (Event.CONFIRMATION,""),
"Cremation" : (Event.CREMATION,""),
"Degree" : (Event.DEGREE,""),
"Divorce Filing" : (Event.DIV_FILING,""),
"Education" : (Event.EDUCATION,""),
"Elected" : (Event.ELECTED,""),
"Emigration" : (Event.EMIGRATION,""),
"First Communion" : (Event.FIRST_COMMUN,""),
"Immigration" : (Event.IMMIGRATION,""),
"Graduation" : (Event.GRADUATION,""),
"Medical Information" : (Event.MED_INFO,""),
"Military Service" : (Event.MILITARY_SERV,""),
"Naturalization" : (Event.NATURALIZATION,""),
"Nobility Title" : (Event.NOB_TITLE,""),
"Number of Marriages" : (Event.NUM_MARRIAGES,""),
"Occupation" : (Event.OCCUPATION,""),
"Ordination" : (Event.ORDINATION,""),
"Probate" : (Event.PROBATE,""),
"Property" : (Event.PROPERTY,""),
"Religion" : (Event.RELIGION,""),
"Residence" : (Event.RESIDENCE,""),
"Retirement" : (Event.RETIREMENT,""),
"Will" : (Event.WILL,""),
"Alternate Marriage" : (EventType.MARR_ALT,""),
"Annulment" : (EventType.ANNULMENT,""),
"Divorce" : (EventType.DIVORCE,""),
"Engagement" : (EventType.ENGAGEMENT,""),
"Marriage Banns" : (EventType.MARR_BANNS,""),
"Marriage Contract" : (EventType.MARR_CONTR,""),
"Marriage License" : (EventType.MARR_LIC,""),
"Marriage Settlement" : (EventType.MARR_SETTL,""),
"Marriage" : (EventType.MARRIAGE,""),
"Adopted" : (EventType.ADOPT,""),
"Birth" : (EventType.BIRTH,""),
"Alternate Birth" : (EventType.BIRTH,""),
"Death" : (EventType.DEATH,""),
"Alternate Death" : (EventType.DEATH,""),
"Adult Christening" : (EventType.ADULT_CHRISTEN,""),
"Baptism" : (EventType.BAPTISM,""),
"Bar Mitzvah" : (EventType.BAR_MITZVAH,""),
"Bas Mitzvah" : (EventType.BAS_MITZVAH,""),
"Blessing" : (EventType.BLESS,""),
"Burial" : (EventType.BURIAL,""),
"Cause Of Death" : (EventType.CAUSE_DEATH,""),
"Census" : (EventType.CENSUS,""),
"Christening" : (EventType.CHRISTEN,""),
"Confirmation" : (EventType.CONFIRMATION,""),
"Cremation" : (EventType.CREMATION,""),
"Degree" : (EventType.DEGREE,""),
"Divorce Filing" : (EventType.DIV_FILING,""),
"Education" : (EventType.EDUCATION,""),
"Elected" : (EventType.ELECTED,""),
"Emigration" : (EventType.EMIGRATION,""),
"First Communion" : (EventType.FIRST_COMMUN,""),
"Immigration" : (EventType.IMMIGRATION,""),
"Graduation" : (EventType.GRADUATION,""),
"Medical Information" : (EventType.MED_INFO,""),
"Military Service" : (EventType.MILITARY_SERV,""),
"Naturalization" : (EventType.NATURALIZATION,""),
"Nobility Title" : (EventType.NOB_TITLE,""),
"Number of Marriages" : (EventType.NUM_MARRIAGES,""),
"Occupation" : (EventType.OCCUPATION,""),
"Ordination" : (EventType.ORDINATION,""),
"Probate" : (EventType.PROBATE,""),
"Property" : (EventType.PROPERTY,""),
"Religion" : (EventType.RELIGION,""),
"Residence" : (EventType.RESIDENCE,""),
"Retirement" : (EventType.RETIREMENT,""),
"Will" : (EventType.WILL,""),
}
# Turns out that a lof ot events have duplicate gramps IDs
@ -1526,9 +1526,9 @@ class GrampsBSDDB(GrampsDbBase):
if event_conversion.has_key(old_type):
new_type = event_conversion[old_type]
else:
new_type = (Event.CUSTOM,old_type)
new_type = (EventType.CUSTOM,old_type)
else:
new_type = (Event.UNKNOWN,"")
new_type = (EventType.UNKNOWN,"")
event.type = new_type
# Cover attributes contained in MediaRefs

View File

@ -445,13 +445,13 @@ class GrampsDbBase(GrampsDBCallback):
transaction, change_time)
def commit_personal_event(self, event, transaction, change_time=None):
if event.type[0] == Event.CUSTOM:
self.individual_event_names.add(event.type[1])
if event.type.is_custom():
self.individual_event_names.add(str(event.type))
self.commit_event(event, transaction, change_time)
def commit_family_event(self, event, transaction, change_time=None):
if event.type[0] == Event.CUSTOM:
self.family_event_names.add(event.type[1])
if event.type.is_custom():
self.family_event_names.add(str(event.type))
self.commit_event(event, transaction, change_time)
def commit_event(self, event, transaction, change_time=None):
@ -875,8 +875,8 @@ class GrampsDbBase(GrampsDBCallback):
Adds an Event to the database, assigning internal IDs if they have
not already been defined.
"""
if event.type[0] == Event.CUSTOM:
self.individual_event_names.add(event.type[1])
if event.type.is_custom():
self.individual_event_names.add(str(event.type))
return self.add_event(event, transaction)
def add_family_event(self, event, transaction):
@ -884,8 +884,8 @@ class GrampsDbBase(GrampsDBCallback):
Adds an Event to the database, assigning internal IDs if they have
not already been defined.
"""
if event.type[0] == Event.CUSTOM:
self.family_event_names.add(event.type[1])
if event.type.is_custom():
self.family_event_names.add(str(event.type))
return self.add_event(event, transaction)
def add_place(self, place, transaction):

View File

@ -1142,20 +1142,20 @@ class GedcomParser:
event = RelLib.Event()
event.set_gramps_id(self.emapper.find_next())
try:
event.set_type((ged2fam[matches[3]],''))
event.set_type(RelLib.EventType(ged2fam[matches[3]]))
except:
if ged2fam_custom.has_key(matches[3]):
event.set_type((RelLib.Event.CUSTOM,ged2fam_custom[matches[3]]))
event.set_type(RelLib.EventType((RelLib.EventType.CUSTOM,ged2fam_custom[matches[3]])))
elif matches[3]:
event.set_type((RelLib.Event.CUSTOM,matches[3]))
event.set_type(RelLib.EventType((RelLib.EventType.CUSTOM,matches[3])))
else:
event.set_type((RelLib.Event.UNKNOWN,''))
event.set_type((RelLib.EventType(RelLib.EventType.UNKNOWN)))
if matches[2] and not event.get_description():
event.set_description(matches[2])
self.parse_family_event(event,2)
if event.get_type()[0] == RelLib.Event.MARRIAGE:
if int(event.get_type()) == RelLib.EventType.MARRIAGE:
self.family.set_relationship((RelLib.Family.MARRIED,''))
if event.get_type()[0] != RelLib.Event.CUSTOM:
if int(event.get_type()) != RelLib.EventType.CUSTOM:
if not event.get_description():
text = _event_family_str % {
'event_name' : Utils.family_events[event.get_type()[0]],
@ -1456,15 +1456,15 @@ class GedcomParser:
self.backup()
break
elif matches[1] == TOKEN_TYPE:
if event.get_type() == (RelLib.Event.CUSTOM,""):
if event.get_type().is_custom():
if ged2gramps.has_key(matches[2]):
name = (ged2gramps[matches[2]],'')
name = RelLib.EventType(ged2gramps[matches[2]])
else:
val = self.gedsource.tag2gramps(matches[2])
if val:
name = (RelLib.Event.CUSTOM,val)
name = RelLib.EventType((RelLib.EventType.CUSTOM,val))
else:
name = (RelLib.Event.CUSTOM,matches[3])
name = RelLib.EventType((RelLib.EventType.CUSTOM,matches[3]))
event.set_type(name)
else:
event.set_description(matches[2])
@ -1477,7 +1477,7 @@ class GedcomParser:
elif matches[1] == TOKEN_PLAC:
val = matches[2]
n = event.get_type()
if self.is_ftw and n[0] in [RelLib.Event.OCCUPATION,RelLib.Event.DEGREE]:
if self.is_ftw and int(n) in [RelLib.EventType.OCCUPATION,RelLib.EventType.DEGREE]:
event.set_description(val)
self.ignore_sub_junk(level+1)
else:
@ -1628,8 +1628,8 @@ class GedcomParser:
break
elif matches[1] == TOKEN_TYPE:
etype = event.get_type()
if etype[0] == RelLib.Event.CUSTOM:
event.set_type((RelLib.Event.CUSTOM,matches[2]))
if etype.is_custom() == RelLib.EventType.CUSTOM:
event.set_type(RelLib.EventType((RelLib.EventType.CUSTOM,matches[2])))
else:
note = 'Status = %s\n' % matches[2]
elif matches[1] == TOKEN_DATE:
@ -1727,13 +1727,13 @@ class GedcomParser:
if len(data) == 1:
name = RelLib.Name(person.primary_name)
name.set_surname(data[0])
name.set_type((RelLib.Name.MARRIED,''))
name.set_type(RelLib.NameType.MARRIED)
person.add_alternate_name(name)
elif len(data) > 1:
name = RelLib.Name()
name.set_surname(data[-1])
name.set_first_name(' '.join(data[0:-1]))
name.set_type((RelLib.Name.MARRIED,''))
name.set_type(RelLib.NameType.MARRIED)
person.add_alternate_name(name)
def parse_header_head(self):
@ -2166,7 +2166,7 @@ class GedcomParser:
event.set_gramps_id(self.emapper.find_next())
if matches[2]:
event.set_description(matches[2])
event.set_type((RelLib.Event.BIRTH,""))
event.set_type(RelLib.EventType((RelLib.EventType.BIRTH,"")))
self.parse_person_event(event,2)
person_event_name(event,state.person)
@ -2184,7 +2184,7 @@ class GedcomParser:
def func_person_adop(self,matches,state):
event = RelLib.Event()
event.set_gramps_id(self.emapper.find_next())
event.set_type((RelLib.Event.ADOPT,''))
event.set_type(RelLib.EventType(RelLib.EventType.ADOPT))
self.parse_adopt_event(event,2)
person_event_name(event,state.person)
self.db.add_event(event, self.trans)
@ -2199,7 +2199,7 @@ class GedcomParser:
event.set_gramps_id(self.emapper.find_next())
if matches[2]:
event.set_description(matches[2])
event.set_type((RelLib.Event.DEATH,""))
event.set_type(RelLib.EventTypeType.DEATH)
self.parse_person_event(event,2)
person_event_name(event,state.person)
@ -2221,9 +2221,9 @@ class GedcomParser:
event.set_description(matches[2])
self.parse_person_event(event,2)
(t,n) = event.get_type()
if t == RelLib.Event.CUSTOM and n in self.attrs:
if t == RelLib.EventType.CUSTOM and n in self.attrs:
attr = RelLib.Attribute()
attr.set_type((RelLib.Event.CUSTOM,self.gedattr[n]))
attr.set_type((RelLib.EventType.CUSTOM,self.gedattr[n]))
attr.set_value(event.get_description())
state.person.add_attribute(attr)
else:
@ -2274,9 +2274,9 @@ class GedcomParser:
event.set_gramps_id(self.emapper.find_next())
val = self.gedsource.tag2gramps(n)
if val:
event.set_type((RelLib.Event.CUSTOM,val))
event.set_type(RelLib.EventType((RelLib.EventType.CUSTOM,val)))
else:
event.set_type((RelLib.Event.CUSTOM,n))
event.set_type(RelLib.EventType((RelLib.EventType.CUSTOM,n)))
self.parse_person_event(event,2)
if matches[2]:
@ -2450,10 +2450,10 @@ class GedcomParser:
return matches[2]
def person_event_name(event,person):
if event.get_type()[0] != RelLib.Event.CUSTOM:
if event.get_type().is_custom():
if not event.get_description():
text = _event_person_str % {
'event_name' : Utils.personal_events[event.get_type()[0]],
'event_name' : str(event.get_type()),
'person' : NameDisplay.displayer.display(person),
}
event.set_description(text)

View File

@ -747,8 +747,8 @@ class GrampsParser:
# person or family objects.
self.event = RelLib.Event()
self.event.handle = Utils.create_id()
self.event.type = _ConstXML.tuple_from_xml(_ConstXML.events,
attrs['type'])
self.event.type = RelLib.EventType()
self.event.type.set_from_xml_str(attrs['type'])
self.db.add_event(self.event,self.trans)
else:
# This is new event, with ID and handle already existing
@ -777,9 +777,9 @@ class GrampsParser:
self.family.add_event_ref(self.eventref)
elif self.person:
event.personal = True
if event.type[0] == RelLib.Event.BIRTH:
if int(event.type) == RelLib.EventType.BIRTH:
self.person.birth_ref = self.eventref
elif event.type[0] == RelLib.Event.DEATH:
elif int(event.type) == RelLib.EventType.DEATH:
self.person.death_ref = self.eventref
else:
self.person.add_event_ref(self.eventref)
@ -1412,9 +1412,9 @@ class GrampsParser:
ref.ref = self.event.handle
ref.private = self.event.private
ref.role = (RelLib.EventRef.PRIMARY,'')
if self.event.type[0] == RelLib.Event.BIRTH:
if int(self.event.type) == RelLib.EventType.BIRTH:
self.person.birth_ref = ref
elif self.event.type[0] == RelLib.Event.DEATH:
elif int(self.event.type) == RelLib.EventType.DEATH:
self.person.death_ref = ref
else:
self.person.add_event_ref(ref)

View File

@ -356,6 +356,7 @@ class MonitoredDataType:
val = get_val()
if val:
default = int(val)
print val, default
else:
default = None
@ -382,7 +383,9 @@ class MonitoredDataType:
self.sel.set_values(self.get_val())
def on_change(self, obj):
self.set_val(self.fix_value(self.sel.get_values()))
value = self.fix_value(self.sel.get_values())
self.set_val(value)
print value, self.get_val()
class MonitoredMenu:

View File

@ -1799,7 +1799,7 @@ def find_spouse(person,family):
def find_marriage(database,family):
for event_ref in family.get_event_ref_list():
event = database.get_event_from_handle(event_ref.ref)
if event and event.get_type() == RelLib.Event.MARRIAGE:
if event and int(event.get_type()) == RelLib.EventType.MARRIAGE:
return event
return None
@ -1989,7 +1989,7 @@ def buried_str(database,person,person_name=None,empty_date="",empty_place=""):
burial = None
for event_ref in person.get_event_ref_list():
event = database.get_event_from_handle(event_ref.ref)
if event and event.get_type() == RelLib.Event.BURIAL:
if event and int(event.get_type()) == RelLib.Event.BURIAL:
burial = event
break

View File

@ -42,6 +42,7 @@ from _NoteBase import NoteBase
from _MediaBase import MediaBase
from _DateBase import DateBase
from _PlaceBase import PlaceBase
from _EventType import EventType
#-------------------------------------------------------------------------
#
@ -57,53 +58,6 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
such as a birth, death, or marriage.
"""
UNKNOWN = -1
CUSTOM = 0
MARRIAGE = 1
MARR_SETTL = 2
MARR_LIC = 3
MARR_CONTR = 4
MARR_BANNS = 5
ENGAGEMENT = 6
DIVORCE = 7
DIV_FILING = 8
ANNULMENT = 9
MARR_ALT = 10
ADOPT = 11
BIRTH = 12
DEATH = 13
ADULT_CHRISTEN = 14
BAPTISM = 15
BAR_MITZVAH = 16
BAS_MITZVAH = 17
BLESS = 18
BURIAL = 19
CAUSE_DEATH = 20
CENSUS = 21
CHRISTEN = 22
CONFIRMATION = 23
CREMATION = 24
DEGREE = 25
EDUCATION = 26
ELECTED = 27
EMIGRATION = 28
FIRST_COMMUN = 29
IMMIGRATION = 30
GRADUATION = 31
MED_INFO = 32
MILITARY_SERV = 33
NATURALIZATION = 34
NOB_TITLE = 35
NUM_MARRIAGES = 36
OCCUPATION = 37
ORDINATION = 38
PROBATE = 39
PROPERTY = 40
RELIGION = 41
RESIDENCE = 42
RETIREMENT = 43
WILL = 44
def __init__(self,source=None):
"""
Creates a new Event instance, copying from the source if present
@ -125,7 +79,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
self.cause = source.cause
else:
self.description = ""
self.type = (Event.CUSTOM,"")
self.type = EventType()
self.cause = ""
def serialize(self):
@ -144,7 +98,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
be considered persistent.
@rtype: tuple
"""
return (self.handle, self.gramps_id, self.type,
return (self.handle, self.gramps_id, self.type.serialize(),
DateBase.serialize(self),
self.description, self.place, self.cause,
SourceBase.serialize(self),
@ -161,11 +115,12 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
Person object
@type data: tuple
"""
(self.handle, self.gramps_id, self.type, date,
(self.handle, self.gramps_id, the_type, date,
self.description, self.place, self.cause,
source_list, note, media_list,
self.change, self.marker, self.private) = data
self.type.unserialize(the_type)
DateBase.unserialize(self,date)
MediaBase.unserialize(self,media_list)
SourceBase.unserialize(self,source_list)
@ -191,7 +146,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.description,self.type[1],self.cause,self.gramps_id]
return [self.description,str(self.type),self.cause,self.gramps_id]
#return [self.description,self.type[1],self.cause,
# self.get_date(),self.gramps_id]
@ -251,7 +206,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
description = self.description
cause = self.cause
the_type = self.type
return (the_type == (Event.CUSTOM,"") and date.is_empty()
return (the_type == Event.CUSTOM and date.is_empty()
and not place and not description and not cause)
def are_equal(self,other):
@ -266,8 +221,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
if other == None:
other = Event (None)
if self.type[0] != other.type[0] or \
(self.type[0] == Event.CUSTOM and self.type[1] != other.type[1]) or\
if self.type != other.type or \
((self.place or other.place) and (self.place != other.place)) or \
self.description != other.description or self.cause != other.cause \
or self.private != other.private or \
@ -308,17 +262,10 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
@param the_type: Type to assign to the Event
@type the_type: tuple
"""
if not type(the_type) == tuple:
warn( "set_type now takes a tuple", DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
if the_type in range(-1,45):
the_type = (the_type,'')
else:
the_type = (Event.CUSTOM,the_type)
assert(type(the_type[0]) == int)
assert(type(the_type[1]) == unicode or type(the_type[1]) == str)
self.type = the_type
if type(the_type) == tuple:
self.type = EventType(the_type)
else:
self.type = the_type
def get_type(self):
"""

View File

@ -89,7 +89,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
self.father_handle = None
self.mother_handle = None
self.child_ref_list = []
self.type = (FamilyRelType.MARRIED,'')
self.type = FamilyRelType(FamilyRelType.MARRIED)
self.event_ref_list = []
self.lds_seal = None
self.complete = 0
@ -117,7 +117,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
return (self.handle, self.gramps_id, self.father_handle,
self.mother_handle,
[cr.serialize() for cr in self.child_ref_list],
self.type,
self.type.serialize(),
[er.serialize() for er in self.event_ref_list],
MediaBase.serialize(self),
AttributeBase.serialize(self),
@ -132,10 +132,11 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
back into the data in a Family structure.
"""
(self.handle, self.gramps_id, self.father_handle, self.mother_handle,
child_ref_list, self.type, event_ref_list, media_list,
child_ref_list, the_type, event_ref_list, media_list,
attribute_list, lds_seal_list, source_list, note,
self.change, self.marker, self.private) = data
self.type.unserialize(the_type)
self.event_ref_list = [EventRef().unserialize(er)
for er in event_ref_list]
self.child_ref_list = [ChildRef().unserialize(cr)
@ -300,20 +301,11 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
between the father and mother of the relationship.
@type relationship_type: tuple
"""
if not isinstance(relationship_type,FamilyRelType):
if relationship_type in [FamilyRelType.MARRIED,
FamilyRelType.UNMARRIED,
FamilyRelType.CIVIL_UNION,
FamilyRelType.UNKNOWN,
FamilyRelType.CUSTOM]:
warn( "set_relationship now takes a FamilyRelType instance",
DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
relationship_type = FamilyRelType(relationship_type)
else:
assert type(relationship_type) == tuple
self.type = relationship_type
if type(relationship_type) == tuple:
self.type = FamilyRelType(relationship_type)
else:
self.type = relationship_type
return
def get_relationship(self):
"""

View File

@ -450,12 +450,7 @@ class ScratchPadEventRef(ScratchPadGrampsTypeWrapper):
base = self._db.get_event_from_handle(self._obj.ref)
self._title = base.get_description()
value = base.get_type()
if value == RelLib.Event.CUSTOM:
self._value = value[1]
else:
self._value = Utils.personal_events[value[0]]
self._value = str(base.get_type())
def tooltip(self):
return ""

View File

@ -99,12 +99,7 @@ class SelectEvent:
for handle in self.db.get_event_handles():
event = self.db.get_event_from_handle(handle)
desc = event.get_description()
etype = event.get_type()
if etype[0] == RelLib.Event.CUSTOM \
or not Utils.personal_events.has_key(etype[0]):
name = etype[1]
else:
name = Utils.personal_events[etype[0]]
name = str(event.get_type())
the_id = event.get_gramps_id()
date = DateHandler.get_date(event)
self.model.add([desc, the_id, name, date], handle)

View File

@ -118,7 +118,7 @@ class SubstKeywords:
if not e_ref:
continue
e = database.get_event_from_handle(e_ref.ref)
if e.get_type() == RelLib.Event.MARRIAGE:
if int(e.get_type()) == RelLib.EventType.MARRIAGE:
self.m = DateHandler.get_date(e)
mplace_handle = e.get_place_handle()
if mplace_handle:

View File

@ -81,76 +81,76 @@ confidence = {
def format_confidence( type):
return confidence.get(type[0],_("Invalid id %d ('%s')")%type)
family_events = {
RelLib.Event.UNKNOWN : _("Unknown"),
RelLib.Event.CUSTOM : _("Custom"),
RelLib.Event.MARRIAGE : _("Marriage"),
RelLib.Event.MARR_SETTL : _("Marriage Settlement"),
RelLib.Event.MARR_LIC : _("Marriage License"),
RelLib.Event.MARR_CONTR : _("Marriage Contract"),
RelLib.Event.MARR_BANNS : _("Marriage Banns"),
RelLib.Event.ENGAGEMENT : _("Engagement"),
RelLib.Event.DIVORCE : _("Divorce"),
RelLib.Event.DIV_FILING : _("Divorce Filing"),
RelLib.Event.ANNULMENT : _("Annulment"),
RelLib.Event.MARR_ALT : _("Alternate Marriage"),
}
def format_family_event( type):
if type[0] == RelLib.Event.CUSTOM:
return type[1]
return family_events.get(type[0],_("Invalid id %d ('%s')")%type)
# family_events = {
# RelLib.Event.UNKNOWN : _("Unknown"),
# RelLib.Event.CUSTOM : _("Custom"),
# RelLib.Event.MARRIAGE : _("Marriage"),
# RelLib.Event.MARR_SETTL : _("Marriage Settlement"),
# RelLib.Event.MARR_LIC : _("Marriage License"),
# RelLib.Event.MARR_CONTR : _("Marriage Contract"),
# RelLib.Event.MARR_BANNS : _("Marriage Banns"),
# RelLib.Event.ENGAGEMENT : _("Engagement"),
# RelLib.Event.DIVORCE : _("Divorce"),
# RelLib.Event.DIV_FILING : _("Divorce Filing"),
# RelLib.Event.ANNULMENT : _("Annulment"),
# RelLib.Event.MARR_ALT : _("Alternate Marriage"),
# }
# def format_family_event( type):
# if type[0] == RelLib.Event.CUSTOM:
# return type[1]
# return family_events.get(type[0],_("Invalid id %d ('%s')")%type)
personal_events = {
RelLib.Event.UNKNOWN : _("Unknown"),
RelLib.Event.CUSTOM : _("Custom"),
RelLib.Event.ADOPT : _("Adopted"),
RelLib.Event.BIRTH : _("Birth"),
RelLib.Event.DEATH : _("Death"),
RelLib.Event.ADULT_CHRISTEN : _("Adult Christening"),
RelLib.Event.BAPTISM : _("Baptism"),
RelLib.Event.BAR_MITZVAH : _("Bar Mitzvah"),
RelLib.Event.BAS_MITZVAH : _("Bas Mitzvah"),
RelLib.Event.BLESS : _("Blessing"),
RelLib.Event.BURIAL : _("Burial"),
RelLib.Event.CAUSE_DEATH : _("Cause Of Death"),
RelLib.Event.CENSUS : _("Census"),
RelLib.Event.CHRISTEN : _("Christening"),
RelLib.Event.CONFIRMATION : _("Confirmation"),
RelLib.Event.CREMATION : _("Cremation"),
RelLib.Event.DEGREE : _("Degree"),
RelLib.Event.DIV_FILING : _("Divorce Filing"),
RelLib.Event.EDUCATION : _("Education"),
RelLib.Event.ELECTED : _("Elected"),
RelLib.Event.EMIGRATION : _("Emigration"),
RelLib.Event.FIRST_COMMUN : _("First Communion"),
RelLib.Event.IMMIGRATION : _("Immigration"),
RelLib.Event.GRADUATION : _("Graduation"),
RelLib.Event.MED_INFO : _("Medical Information"),
RelLib.Event.MILITARY_SERV : _("Military Service"),
RelLib.Event.NATURALIZATION : _("Naturalization"),
RelLib.Event.NOB_TITLE : _("Nobility Title"),
RelLib.Event.NUM_MARRIAGES : _("Number of Marriages"),
RelLib.Event.OCCUPATION : _("Occupation"),
RelLib.Event.ORDINATION : _("Ordination"),
RelLib.Event.PROBATE : _("Probate"),
RelLib.Event.PROPERTY : _("Property"),
RelLib.Event.RELIGION : _("Religion"),
RelLib.Event.RESIDENCE : _("Residence"),
RelLib.Event.RETIREMENT : _("Retirement"),
RelLib.Event.WILL : _("Will")
}
def format_personal_event( type):
if type[0] == RelLib.Event.CUSTOM:
return type[1]
return personal_events.get(type[0],_("Invalid id %d ('%s')")%type)
# personal_events = {
# RelLib.Event.UNKNOWN : _("Unknown"),
# RelLib.Event.CUSTOM : _("Custom"),
# RelLib.Event.ADOPT : _("Adopted"),
# RelLib.Event.BIRTH : _("Birth"),
# RelLib.Event.DEATH : _("Death"),
# RelLib.Event.ADULT_CHRISTEN : _("Adult Christening"),
# RelLib.Event.BAPTISM : _("Baptism"),
# RelLib.Event.BAR_MITZVAH : _("Bar Mitzvah"),
# RelLib.Event.BAS_MITZVAH : _("Bas Mitzvah"),
# RelLib.Event.BLESS : _("Blessing"),
# RelLib.Event.BURIAL : _("Burial"),
# RelLib.Event.CAUSE_DEATH : _("Cause Of Death"),
# RelLib.Event.CENSUS : _("Census"),
# RelLib.Event.CHRISTEN : _("Christening"),
# RelLib.Event.CONFIRMATION : _("Confirmation"),
# RelLib.Event.CREMATION : _("Cremation"),
# RelLib.Event.DEGREE : _("Degree"),
# RelLib.Event.DIV_FILING : _("Divorce Filing"),
# RelLib.Event.EDUCATION : _("Education"),
# RelLib.Event.ELECTED : _("Elected"),
# RelLib.Event.EMIGRATION : _("Emigration"),
# RelLib.Event.FIRST_COMMUN : _("First Communion"),
# RelLib.Event.IMMIGRATION : _("Immigration"),
# RelLib.Event.GRADUATION : _("Graduation"),
# RelLib.Event.MED_INFO : _("Medical Information"),
# RelLib.Event.MILITARY_SERV : _("Military Service"),
# RelLib.Event.NATURALIZATION : _("Naturalization"),
# RelLib.Event.NOB_TITLE : _("Nobility Title"),
# RelLib.Event.NUM_MARRIAGES : _("Number of Marriages"),
# RelLib.Event.OCCUPATION : _("Occupation"),
# RelLib.Event.ORDINATION : _("Ordination"),
# RelLib.Event.PROBATE : _("Probate"),
# RelLib.Event.PROPERTY : _("Property"),
# RelLib.Event.RELIGION : _("Religion"),
# RelLib.Event.RESIDENCE : _("Residence"),
# RelLib.Event.RETIREMENT : _("Retirement"),
# RelLib.Event.WILL : _("Will")
# }
# def format_personal_event( type):
# if type[0] == RelLib.Event.CUSTOM:
# return type[1]
# return personal_events.get(type[0],_("Invalid id %d ('%s')")%type)
def format_event( type):
if type[0] == RelLib.Event.CUSTOM:
return type[1]
val = personal_events.get(type[0])
if not val:
val = family_events.get(type[0],_("Invalid id %d ('%s')")%type)
return val
# def format_event( type):
# if type[0] == RelLib.Event.CUSTOM:
# return type[1]
# val = personal_events.get(type[0])
# if not val:
# val = family_events.get(type[0],_("Invalid id %d ('%s')")%type)
# return val
personal_attributes = {
RelLib.Attribute.UNKNOWN : _("Unknown"),
@ -302,53 +302,53 @@ def format_marker_type( type):
#
#-------------------------------------------------------------------------
familyConstantEvents = {
RelLib.Event.ANNULMENT : "ANUL",
RelLib.Event.DIV_FILING : "DIVF",
RelLib.Event.DIVORCE : "DIV",
RelLib.Event.ENGAGEMENT : "ENGA",
RelLib.Event.MARR_BANNS : "MARB",
RelLib.Event.MARR_CONTR : "MARC",
RelLib.Event.MARR_LIC : "MARL",
RelLib.Event.MARR_SETTL : "MARS",
RelLib.Event.MARRIAGE : "MARR"
RelLib.EventType.ANNULMENT : "ANUL",
RelLib.EventType.DIV_FILING : "DIVF",
RelLib.EventType.DIVORCE : "DIV",
RelLib.EventType.ENGAGEMENT : "ENGA",
RelLib.EventType.MARR_BANNS : "MARB",
RelLib.EventType.MARR_CONTR : "MARC",
RelLib.EventType.MARR_LIC : "MARL",
RelLib.EventType.MARR_SETTL : "MARS",
RelLib.EventType.MARRIAGE : "MARR"
}
personalConstantEvents = {
RelLib.Event.ADOPT : "ADOP",
RelLib.Event.ADULT_CHRISTEN : "CHRA",
RelLib.Event.BIRTH : "BIRT",
RelLib.Event.DEATH : "DEAT",
RelLib.Event.BAPTISM : "BAPM",
RelLib.Event.BAR_MITZVAH : "BARM",
RelLib.Event.BAS_MITZVAH : "BASM",
RelLib.Event.BLESS : "BLES",
RelLib.Event.BURIAL : "BURI",
RelLib.Event.CAUSE_DEATH : "CAUS",
RelLib.Event.ORDINATION : "ORDI",
RelLib.Event.CENSUS : "CENS",
RelLib.Event.CHRISTEN : "CHR" ,
RelLib.Event.CONFIRMATION : "CONF",
RelLib.Event.CREMATION : "CREM",
RelLib.Event.DEGREE : "_DEG",
RelLib.Event.DIV_FILING : "DIVF",
RelLib.Event.EDUCATION : "EDUC",
RelLib.Event.ELECTED : "",
RelLib.Event.EMIGRATION : "EMIG",
RelLib.Event.FIRST_COMMUN : "FCOM",
RelLib.Event.GRADUATION : "GRAD",
RelLib.Event.MED_INFO : "_MDCL",
RelLib.Event.MILITARY_SERV : "_MILT",
RelLib.Event.NATURALIZATION : "NATU",
RelLib.Event.NOB_TITLE : "TITL",
RelLib.Event.NUM_MARRIAGES : "NMR",
RelLib.Event.IMMIGRATION : "IMMI",
RelLib.Event.OCCUPATION : "OCCU",
RelLib.Event.PROBATE : "PROB",
RelLib.Event.PROPERTY : "PROP",
RelLib.Event.RELIGION : "RELI",
RelLib.Event.RESIDENCE : "RESI",
RelLib.Event.RETIREMENT : "RETI",
RelLib.Event.WILL : "WILL",
RelLib.EventType.ADOPT : "ADOP",
RelLib.EventType.ADULT_CHRISTEN : "CHRA",
RelLib.EventType.BIRTH : "BIRT",
RelLib.EventType.DEATH : "DEAT",
RelLib.EventType.BAPTISM : "BAPM",
RelLib.EventType.BAR_MITZVAH : "BARM",
RelLib.EventType.BAS_MITZVAH : "BASM",
RelLib.EventType.BLESS : "BLES",
RelLib.EventType.BURIAL : "BURI",
RelLib.EventType.CAUSE_DEATH : "CAUS",
RelLib.EventType.ORDINATION : "ORDI",
RelLib.EventType.CENSUS : "CENS",
RelLib.EventType.CHRISTEN : "CHR" ,
RelLib.EventType.CONFIRMATION : "CONF",
RelLib.EventType.CREMATION : "CREM",
RelLib.EventType.DEGREE : "_DEG",
RelLib.EventType.DIV_FILING : "DIVF",
RelLib.EventType.EDUCATION : "EDUC",
RelLib.EventType.ELECTED : "",
RelLib.EventType.EMIGRATION : "EMIG",
RelLib.EventType.FIRST_COMMUN : "FCOM",
RelLib.EventType.GRADUATION : "GRAD",
RelLib.EventType.MED_INFO : "_MDCL",
RelLib.EventType.MILITARY_SERV : "_MILT",
RelLib.EventType.NATURALIZATION : "NATU",
RelLib.EventType.NOB_TITLE : "TITL",
RelLib.EventType.NUM_MARRIAGES : "NMR",
RelLib.EventType.IMMIGRATION : "IMMI",
RelLib.EventType.OCCUPATION : "OCCU",
RelLib.EventType.PROBATE : "PROB",
RelLib.EventType.PROPERTY : "PROP",
RelLib.EventType.RELIGION : "RELI",
RelLib.EventType.RESIDENCE : "RESI",
RelLib.EventType.RETIREMENT : "RETI",
RelLib.EventType.WILL : "WILL",
}
familyConstantAttributes = {
@ -843,8 +843,9 @@ def probably_alive(person,db,current_year=None,limit=0):
# These are fairly good indications that someone's not alive.
for ev_ref in person.event_ref_list:
ev = db.get_event_from_handle(ev_ref.ref)
if ev and ev.get_type()[0] in [RelLib.Event.CAUSE_DEATH, RelLib.Event.BURIAL,
RelLib.Event.CREMATION]:
if ev and int(ev.get_type())in [RelLib.EventType.CAUSE_DEATH,
RelLib.EventType.BURIAL,
RelLib.EventType.CREMATION]:
if not death_year:
death_year = ev.get_date_object().get_year()
if ev.get_date_object().get_start_date() != RelLib.Date.EMPTY:

View File

@ -552,9 +552,9 @@ class CheckIntegrity:
self.db.commit_person(person,self.trans)
self.invalid_events.append(key)
else:
if not birth.get_type()[0] == RelLib.Event.BIRTH:
if int(birth.get_type()) != RelLib.EventType.BIRTH:
# Birth event was not of the type "Birth"
birth.set_type((RelLib.Event.BIRTH,""))
birth.set_type(RelLib.EventType(RelLib.EventType.BIRTH))
self.db.commit_event(birth,self.trans)
self.invalid_birth_events.append(key)
death_ref = person.get_death_ref()
@ -568,9 +568,9 @@ class CheckIntegrity:
self.db.commit_person(person,self.trans)
self.invalid_events.append(key)
else:
if not death.get_type()[0] == RelLib.Event.DEATH:
if int(death.get_type()) != RelLib.EventType.DEATH:
# Death event was not of the type "Death"
death.set_type((RelLib.Event.DEATH,""))
death.set_type(RelLib.EventType(RelLib.EventType.DEATH))
self.db.commit_event(death,self.trans)
self.invalid_death_events.append(key)

View File

@ -208,7 +208,7 @@ class CalendarWriter:
if family:
for event_ref in family.get_event_ref_list():
event = self.db.get_event_from_handle(event_ref.ref)
if event.get_type()[0] == RelLib.Event.MARRIAGE:
if int(event.get_type()) == RelLib.EventType.MARRIAGE:
m_date = event.get_date_object()
place_handle = event.get_place_handle()
text = _("Marriage of %s") % Utils.family_name(family,self.db)

View File

@ -223,7 +223,7 @@ class FamilyGroup(Report.Report):
birth_ref = person.get_birth_ref()
birth = None
evtName = Utils.personal_events[RelLib.Event.BIRTH]
evtName = str(RelLib.EventType())
if birth_ref:
birth = self.database.get_event_from_handle(birth_ref.ref)
if birth or self.missingInfo:
@ -231,7 +231,7 @@ class FamilyGroup(Report.Report):
death_ref = person.get_death_ref()
death = None
evtName = Utils.personal_events[RelLib.Event.DEATH]
evtName = str(RelLib.EventType(RelLib.EventType.DEATH))
if death_ref:
death = self.database.get_event_from_handle(death_ref.ref)
if death or self.missingInfo:
@ -334,7 +334,7 @@ class FamilyGroup(Report.Report):
for event_ref in family_ref_list:
if event_ref:
event = self.database.get_event_from_handle(event_ref.ref)
if event.get_type()[0] == RelLib.Event.MARRIAGE:
if int(event.get_type()) == RelLib.EventType.MARRIAGE:
m = event
break
@ -348,14 +348,14 @@ class FamilyGroup(Report.Report):
self.doc.end_cell()
self.doc.end_row()
evtName = Utils.family_events[RelLib.Event.MARRIAGE]
evtName = str(RelLib.EventType(RelLib.EventType.MARRIAGE))
self.dump_parent_event(evtName,m)
for event_ref in family_ref_list:
if event_ref:
event = self.database.get_event_from_handle(event_ref.ref)
evtType = event.get_type()
if evtType[0] != RelLib.Event.MARRIAGE:
if int(evtType) != RelLib.EventType.MARRIAGE:
name = Utils.format_event( evtType )
self.dump_parent_event(name,event)
@ -462,7 +462,7 @@ class FamilyGroup(Report.Report):
for event_ref in family.get_event_ref_list():
if event_ref:
event = self.database.get_event_from_handle(event_ref.ref)
if event.get_type()[0] == RelLib.Event.MARRIAGE:
if int(event.get_type()) == RelLib.EventType.MARRIAGE:
m = event
break
@ -511,7 +511,7 @@ class FamilyGroup(Report.Report):
self.doc.end_row()
if m:
evtName = Utils.family_events[RelLib.Event.MARRIAGE]
evtName = str(RelLib.EventType(RelLib.EventType.MARRIAGE))
if index == families:
self.dump_child_event('FGR-TextChild2',evtName,m)
else:

View File

@ -351,7 +351,7 @@ class GraphViz:
for event_ref in fam.get_event_ref_list():
if event_ref:
event = self.database.get_event_from_handle(event_ref.ref)
if event.get_type() == RelLib.Event.MARRIAGE:
if int(event.get_type()) == RelLib.EventType.MARRIAGE:
m = event
break
else:

View File

@ -173,7 +173,7 @@ class VCardParser:
def add_name(self, fields, data):
data_fields = data.split(";")
name = RelLib.Name()
name.set_type("Also Known As")
name.set_type(RelLib.NameType(RelLib.NameType.AKA))
name.set_surname(data_fields[0])
name.set_first_name(data_fields[1])
if data_fields[2]:
@ -185,7 +185,7 @@ class VCardParser:
def add_title(self, fields, data):
name = RelLib.Name()
name.set_type("Also Known As")
name.set_type(RelLib.NameType(RelLib.NameType.AKA))
name.set_title(data)
self.person.add_alternate_name(name)
@ -206,7 +206,7 @@ class VCardParser:
def add_birthday(self, fields, data):
event = RelLib.Event()
event.set_name("Birth")
event.set_type(RelLib.EventType(RelLib.EventType.BIRTH))
self.db.add_event(event,self.trans)
self.person.set_birth_handle(event.get_handle())

View File

@ -244,10 +244,9 @@ class Verify(Tool.Tool, ManagedWindow.ManagedWindow):
if event_ref:
event_handle = event_ref.ref
event = self.db.get_event_from_handle(event_handle)
event_name = event.get_type()[0]
if event_name == RelLib.Event.BURIAL:
if int(event.get_type()) == RelLib.EventType.BURIAL:
buryear = self.get_year( event.get_handle() )
elif event_name == RelLib.Event.BAPTISM:
elif int(event.get_type()) == RelLib.EventType.BAPTISM:
bapyear = self.get_year( event.get_handle() )
if byear>0 and bapyear>0: