GrampsType support for FamilyRelations, Events

svn: r6371
This commit is contained in:
Don Allingham 2006-04-19 22:59:33 +00:00
parent ea3f1d727a
commit 86caffe6bd
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> 2006-04-19 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/TestcaseGenerator.py: Use the new types * 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(): for event_ref in family.get_event_ref_list():
handle = event_ref.ref handle = event_ref.ref
event = self.dbstate.db.get_event_from_handle(handle) event = self.dbstate.db.get_event_from_handle(handle)
etype = event.get_type() if int(event.get_type()) == RelLib.EventType.MARRIAGE:
if etype[0] == RelLib.Event.MARRIAGE:
self.write_event_ref(_('Marriage'), event) self.write_event_ref(_('Marriage'), event)
value = True value = True
return value return value

View File

@ -358,7 +358,7 @@ class FormattingHelper:
text = "" text = ""
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
event = self.db.get_event_from_handle(event_ref.ref) 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: if line_count < 3:
return DateHandler.get_date(event) return DateHandler.get_date(event)
(i,s) = event.get_type() (i,s) = event.get_type()
@ -1599,10 +1599,10 @@ def build_detail_string(db,person):
else: else:
for event_ref in person.get_event_ref_list(): for event_ref in person.get_event_ref_list():
event = db.get_event_from_handle(event_ref.ref) 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) detail_text += format_event(db, _BAPT, event)
break 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) detail_text += format_event(db, _CHRI, event)
break break
@ -1613,10 +1613,10 @@ def build_detail_string(db,person):
else: else:
for event_ref in person.get_event_ref_list(): for event_ref in person.get_event_ref_list():
event = db.get_event_from_handle(event_ref.ref) 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) detail_text += format_event(db, _BURI, event)
break 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) detail_text += format_event(db, _CREM, event)
break break

View File

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

View File

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

View File

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

View File

@ -59,10 +59,6 @@ from _EditReference import EditReference
# Constants # 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 return Utils.personal_events
def get_custom_events(self): 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): def _connect_signals(self):
self.define_ok_button(self.top.get_widget('ok'),self.ok_clicked) self.define_ok_button(self.top.get_widget('ok'),self.ok_clicked)
@ -136,12 +133,10 @@ class EditEventRef(EditReference):
self.get_roles(), self.get_roles(),
RelLib.EventRef.CUSTOM) RelLib.EventRef.CUSTOM)
self.event_menu = MonitoredType( self.event_menu = MonitoredDataType(
self.top.get_widget("eer_type_combo"), self.top.get_widget("eer_type_combo"),
self.source.set_type, self.source.set_type,
self.source.get_type, self.source.get_type,
self.get_event_types(),
RelLib.Event.CUSTOM,
custom_values=self.get_custom_events()) custom_values=self.get_custom_events())
self.date_check = MonitoredDate( self.date_check = MonitoredDate(
@ -187,13 +182,7 @@ class EditEventRef(EditReference):
def build_menu_names(self,eventref): def build_menu_names(self,eventref):
if self.source: if self.source:
if self.source.get_type()[0] == RelLib.Event.CUSTOM: event_name = str(self.source.get_type())
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]]
submenu_label = _('Event: %s') % event_name submenu_label = _('Event: %s') % event_name
else: else:
submenu_label = _('New Event') submenu_label = _('New Event')
@ -246,7 +235,7 @@ class EditFamilyEventRef(EditEventRef):
return Utils.family_events return Utils.family_events
def get_custom_events(self): 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.obj.get_gramps_id,
self.db.readonly) self.db.readonly)
self.data_type = MonitoredType( self.data_type = MonitoredDataType(
self.top.get_widget('marriage_type'), self.top.get_widget('marriage_type'),
self.obj.set_relationship, self.obj.set_relationship,
self.obj.get_relationship, self.obj.get_relationship,
dict(Utils.family_relations), )
RelLib.Family.CUSTOM)
def load_data(self): def load_data(self):
fhandle = self.obj.get_father_handle() fhandle = self.obj.get_father_handle()

View File

@ -1649,7 +1649,7 @@ class IsWitness(Rule):
wlist = event.get_witness_list() wlist = event.get_witness_list()
if wlist: if wlist:
for w in 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()) self.map.append(w.get_value())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -356,6 +356,7 @@ class MonitoredDataType:
val = get_val() val = get_val()
if val: if val:
default = int(val) default = int(val)
print val, default
else: else:
default = None default = None
@ -382,7 +383,9 @@ class MonitoredDataType:
self.sel.set_values(self.get_val()) self.sel.set_values(self.get_val())
def on_change(self, obj): 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: class MonitoredMenu:

View File

@ -1799,7 +1799,7 @@ def find_spouse(person,family):
def find_marriage(database,family): def find_marriage(database,family):
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
event = database.get_event_from_handle(event_ref.ref) 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 event
return None return None
@ -1989,7 +1989,7 @@ def buried_str(database,person,person_name=None,empty_date="",empty_place=""):
burial = None burial = None
for event_ref in person.get_event_ref_list(): for event_ref in person.get_event_ref_list():
event = database.get_event_from_handle(event_ref.ref) 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 burial = event
break break

View File

@ -42,6 +42,7 @@ from _NoteBase import NoteBase
from _MediaBase import MediaBase from _MediaBase import MediaBase
from _DateBase import DateBase from _DateBase import DateBase
from _PlaceBase import PlaceBase 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. 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): def __init__(self,source=None):
""" """
Creates a new Event instance, copying from the source if present 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 self.cause = source.cause
else: else:
self.description = "" self.description = ""
self.type = (Event.CUSTOM,"") self.type = EventType()
self.cause = "" self.cause = ""
def serialize(self): def serialize(self):
@ -144,7 +98,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
be considered persistent. be considered persistent.
@rtype: tuple @rtype: tuple
""" """
return (self.handle, self.gramps_id, self.type, return (self.handle, self.gramps_id, self.type.serialize(),
DateBase.serialize(self), DateBase.serialize(self),
self.description, self.place, self.cause, self.description, self.place, self.cause,
SourceBase.serialize(self), SourceBase.serialize(self),
@ -161,11 +115,12 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
Person object Person object
@type data: tuple @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, self.description, self.place, self.cause,
source_list, note, media_list, source_list, note, media_list,
self.change, self.marker, self.private) = data self.change, self.marker, self.private) = data
self.type.unserialize(the_type)
DateBase.unserialize(self,date) DateBase.unserialize(self,date)
MediaBase.unserialize(self,media_list) MediaBase.unserialize(self,media_list)
SourceBase.unserialize(self,source_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. @return: Returns the list of all textual attributes of the object.
@rtype: list @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, #return [self.description,self.type[1],self.cause,
# self.get_date(),self.gramps_id] # self.get_date(),self.gramps_id]
@ -251,7 +206,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
description = self.description description = self.description
cause = self.cause cause = self.cause
the_type = self.type 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) and not place and not description and not cause)
def are_equal(self,other): def are_equal(self,other):
@ -266,8 +221,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
if other == None: if other == None:
other = Event (None) other = Event (None)
if self.type[0] != other.type[0] or \ if self.type != other.type or \
(self.type[0] == Event.CUSTOM and self.type[1] != other.type[1]) or\
((self.place or other.place) and (self.place != other.place)) or \ ((self.place or other.place) and (self.place != other.place)) or \
self.description != other.description or self.cause != other.cause \ self.description != other.description or self.cause != other.cause \
or self.private != other.private or \ 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 @param the_type: Type to assign to the Event
@type the_type: tuple @type the_type: tuple
""" """
if not type(the_type) == tuple: if type(the_type) == tuple:
warn( "set_type now takes a tuple", DeprecationWarning, 2) self.type = EventType(the_type)
# Wrapper for old API else:
# remove when transitition done. self.type = the_type
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
def get_type(self): def get_type(self):
""" """

View File

@ -89,7 +89,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
self.father_handle = None self.father_handle = None
self.mother_handle = None self.mother_handle = None
self.child_ref_list = [] self.child_ref_list = []
self.type = (FamilyRelType.MARRIED,'') self.type = FamilyRelType(FamilyRelType.MARRIED)
self.event_ref_list = [] self.event_ref_list = []
self.lds_seal = None self.lds_seal = None
self.complete = 0 self.complete = 0
@ -117,7 +117,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
return (self.handle, self.gramps_id, self.father_handle, return (self.handle, self.gramps_id, self.father_handle,
self.mother_handle, self.mother_handle,
[cr.serialize() for cr in self.child_ref_list], [cr.serialize() for cr in self.child_ref_list],
self.type, self.type.serialize(),
[er.serialize() for er in self.event_ref_list], [er.serialize() for er in self.event_ref_list],
MediaBase.serialize(self), MediaBase.serialize(self),
AttributeBase.serialize(self), AttributeBase.serialize(self),
@ -132,10 +132,11 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
back into the data in a Family structure. back into the data in a Family structure.
""" """
(self.handle, self.gramps_id, self.father_handle, self.mother_handle, (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, attribute_list, lds_seal_list, source_list, note,
self.change, self.marker, self.private) = data self.change, self.marker, self.private) = data
self.type.unserialize(the_type)
self.event_ref_list = [EventRef().unserialize(er) self.event_ref_list = [EventRef().unserialize(er)
for er in event_ref_list] for er in event_ref_list]
self.child_ref_list = [ChildRef().unserialize(cr) 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. between the father and mother of the relationship.
@type relationship_type: tuple @type relationship_type: tuple
""" """
if not isinstance(relationship_type,FamilyRelType): if type(relationship_type) == tuple:
if relationship_type in [FamilyRelType.MARRIED, self.type = FamilyRelType(relationship_type)
FamilyRelType.UNMARRIED, else:
FamilyRelType.CIVIL_UNION, self.type = relationship_type
FamilyRelType.UNKNOWN, return
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
def get_relationship(self): def get_relationship(self):
""" """

View File

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

View File

@ -99,12 +99,7 @@ class SelectEvent:
for handle in self.db.get_event_handles(): for handle in self.db.get_event_handles():
event = self.db.get_event_from_handle(handle) event = self.db.get_event_from_handle(handle)
desc = event.get_description() desc = event.get_description()
etype = event.get_type() name = str(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]]
the_id = event.get_gramps_id() the_id = event.get_gramps_id()
date = DateHandler.get_date(event) date = DateHandler.get_date(event)
self.model.add([desc, the_id, name, date], handle) self.model.add([desc, the_id, name, date], handle)

View File

@ -118,7 +118,7 @@ class SubstKeywords:
if not e_ref: if not e_ref:
continue continue
e = database.get_event_from_handle(e_ref.ref) 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) self.m = DateHandler.get_date(e)
mplace_handle = e.get_place_handle() mplace_handle = e.get_place_handle()
if mplace_handle: if mplace_handle:

View File

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

View File

@ -208,7 +208,7 @@ class CalendarWriter:
if family: if family:
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
event = self.db.get_event_from_handle(event_ref.ref) 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() m_date = event.get_date_object()
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
text = _("Marriage of %s") % Utils.family_name(family,self.db) 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_ref = person.get_birth_ref()
birth = None birth = None
evtName = Utils.personal_events[RelLib.Event.BIRTH] evtName = str(RelLib.EventType())
if birth_ref: if birth_ref:
birth = self.database.get_event_from_handle(birth_ref.ref) birth = self.database.get_event_from_handle(birth_ref.ref)
if birth or self.missingInfo: if birth or self.missingInfo:
@ -231,7 +231,7 @@ class FamilyGroup(Report.Report):
death_ref = person.get_death_ref() death_ref = person.get_death_ref()
death = None death = None
evtName = Utils.personal_events[RelLib.Event.DEATH] evtName = str(RelLib.EventType(RelLib.EventType.DEATH))
if death_ref: if death_ref:
death = self.database.get_event_from_handle(death_ref.ref) death = self.database.get_event_from_handle(death_ref.ref)
if death or self.missingInfo: if death or self.missingInfo:
@ -334,7 +334,7 @@ class FamilyGroup(Report.Report):
for event_ref in family_ref_list: for event_ref in family_ref_list:
if event_ref: if event_ref:
event = self.database.get_event_from_handle(event_ref.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 m = event
break break
@ -348,14 +348,14 @@ class FamilyGroup(Report.Report):
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
evtName = Utils.family_events[RelLib.Event.MARRIAGE] evtName = str(RelLib.EventType(RelLib.EventType.MARRIAGE))
self.dump_parent_event(evtName,m) self.dump_parent_event(evtName,m)
for event_ref in family_ref_list: for event_ref in family_ref_list:
if event_ref: if event_ref:
event = self.database.get_event_from_handle(event_ref.ref) event = self.database.get_event_from_handle(event_ref.ref)
evtType = event.get_type() evtType = event.get_type()
if evtType[0] != RelLib.Event.MARRIAGE: if int(evtType) != RelLib.EventType.MARRIAGE:
name = Utils.format_event( evtType ) name = Utils.format_event( evtType )
self.dump_parent_event(name,event) self.dump_parent_event(name,event)
@ -462,7 +462,7 @@ class FamilyGroup(Report.Report):
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
if event_ref: if event_ref:
event = self.database.get_event_from_handle(event_ref.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 m = event
break break
@ -511,7 +511,7 @@ class FamilyGroup(Report.Report):
self.doc.end_row() self.doc.end_row()
if m: if m:
evtName = Utils.family_events[RelLib.Event.MARRIAGE] evtName = str(RelLib.EventType(RelLib.EventType.MARRIAGE))
if index == families: if index == families:
self.dump_child_event('FGR-TextChild2',evtName,m) self.dump_child_event('FGR-TextChild2',evtName,m)
else: else:

View File

@ -351,7 +351,7 @@ class GraphViz:
for event_ref in fam.get_event_ref_list(): for event_ref in fam.get_event_ref_list():
if event_ref: if event_ref:
event = self.database.get_event_from_handle(event_ref.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 m = event
break break
else: else:

View File

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

View File

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