From 3771ee4ff99c67485922beb5ce28222f10b86ba8 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Mon, 30 May 2005 20:41:43 +0000 Subject: [PATCH] * src/RelLib.py: Move constants back to RelLib, as class attributes. * src/Utils.py: Move constant mappings from const.py.in * src/const.py.in: Move constants and mappings elsewhere. * various: Use constants from RelLib, not const. svn: r4736 --- src/AddSpouse.py | 32 ++-- src/ChooseParents.py | 24 +-- src/EditPerson.py | 22 +-- src/FamilyView.py | 18 +- src/GenericFilter.py | 6 +- src/PedView.py | 4 +- src/ReadGedcom.py | 10 +- src/ReadXML.py | 8 +- src/RelLib.py | 213 ++++++++++++++++++------ src/Relationship.py | 8 +- src/ReportUtils.py | 60 +++---- src/SelectChild.py | 16 +- src/Utils.py | 216 +++++++++++++++++++++++- src/WriteGedcom.py | 4 +- src/WriteXML.py | 4 +- src/const.py.in | 385 ------------------------------------------- 16 files changed, 485 insertions(+), 545 deletions(-) diff --git a/src/AddSpouse.py b/src/AddSpouse.py index 67f435e04..949baad5e 100644 --- a/src/AddSpouse.py +++ b/src/AddSpouse.py @@ -140,7 +140,7 @@ class AddSpouse: death_handle = self.person.get_death_handle() filt = GenericFilter.GenericFilter() - if gender == const.MALE: + if gender == RelLib.Person.MALE: filt.add_rule(GenericFilter.IsFemale([])) else: filt.add_rule(GenericFilter.IsMale([])) @@ -204,15 +204,15 @@ class AddSpouse: import EditPerson relation = self.rel_combo.get_active() - if relation == const.FAMILY_CIVIL_UNION: - if self.person.get_gender() == const.MALE: - gen = const.MALE + if relation == RelLib.Family.CIVIL_UNION: + if self.person.get_gender() == RelLib.Person.MALE: + gen = RelLib.Person.MALE else: - gen = const.FEMALE - elif self.person.get_gender() == const.MALE: - gen = const.FEMALE + gen = RelLib.Person.FEMALE + elif self.person.get_gender() == RelLib.Person.MALE: + gen = RelLib.Person.FEMALE else: - gen = const.MALE + gen = RelLib.Person.MALE person = RelLib.Person() person.set_gender(gen) @@ -302,7 +302,7 @@ class AddSpouse: spouse.add_family_handle(self.active_family.get_handle()) self.db.commit_person(spouse,trans) - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: self.active_family.set_mother_handle(spouse.get_handle()) self.active_family.set_father_handle(self.person.get_handle()) else: @@ -373,16 +373,16 @@ class AddSpouse: return 1 def set_gender(self): - if self.rel_combo.get_active() == const.FAMILY_CIVIL_UNION: - if self.gender == const.MALE: - self.sgender = const.FEMALE + if self.rel_combo.get_active() == RelLib.Family.CIVIL_UNION: + if self.gender == RelLib.Person.MALE: + self.sgender = RelLib.Person.FEMALE else: - self.sgender = const.MALE + self.sgender = RelLib.Person.MALE else: - if self.gender == const.MALE: - self.sgender = const.MALE + if self.gender == RelLib.Person.MALE: + self.sgender = RelLib.Person.MALE else: - self.sgender = const.FEMALE + self.sgender = RelLib.Person.FEMALE def update_data(self,person = None): """ diff --git a/src/ChooseParents.py b/src/ChooseParents.py index 2c62f5648..5cae04db6 100644 --- a/src/ChooseParents.py +++ b/src/ChooseParents.py @@ -153,7 +153,7 @@ class ChooseParents: if self.family: self.type = self.family.get_relationship() else: - self.type = const.FAMILY_MARRIED + self.type = RelLib.Family.MARRIED self.prel.set_active(self.type) self.redrawm() @@ -300,7 +300,7 @@ class ChooseParents: self.father_model = PeopleModel.PeopleModel(self.db,self.father_filter) self.father_list.set_model(self.father_model) - if self.type == const.FAMILY_CIVIL_UNION: + if self.type == RelLib.Family.CIVIL_UNION: self.flabel.set_label("%s" % _("Par_ent")) else: self.flabel.set_label("%s" % _("Fath_er")) @@ -310,7 +310,7 @@ class ChooseParents: self.mother_model = PeopleModel.PeopleModel(self.db,self.mother_filter) self.mother_list.set_model(self.mother_model) - if self.type == const.FAMILY_CIVIL_UNION: + if self.type == RelLib.Family.CIVIL_UNION: self.mlabel.set_label("%s" % _("Pa_rent")) else: self.mlabel.set_label("%s" % _("Mothe_r")) @@ -319,8 +319,8 @@ class ChooseParents: """Called everytime the parent relationship information is changed""" self.old_type = self.type self.type = self.prel.get_active() - if (self.old_type == const.FAMILY_CIVIL_UNION or - self.type == const.FAMILY_CIVIL_UNION): + if (self.old_type == RelLib.Family.CIVIL_UNION or + self.type == RelLib.Family.CIVIL_UNION): self.redrawf() self.redrawm() @@ -465,7 +465,7 @@ class ChooseParents: trans = self.db.transaction_begin() if self.father or self.mother: if self.mother and not self.father: - if self.mother.get_gender() == const.MALE: + if self.mother.get_gender() == RelLib.Person.MALE: self.father = self.mother father_handle = self.father.get_handle() self.mother = None @@ -474,7 +474,7 @@ class ChooseParents: mother_handle = self.mother.get_handle() father_handle = None elif self.father and not self.mother: - if self.father.get_gender() == const.FEMALE: + if self.father.get_gender() == RelLib.Person.FEMALE: self.mother = self.father self.father = None mother_handle = self.mother.get_handle() @@ -485,7 +485,7 @@ class ChooseParents: elif self.mother.get_gender() != self.father.get_gender(): if self.type == "Partners": self.type = "Unknown" - if self.father.get_gender() == const.FEMALE: + if self.father.get_gender() == RelLib.Person.FEMALE: self.father, self.mother = self.mother, self.father father_handle = self.father.get_handle() mother_handle = self.mother.get_handle() @@ -519,9 +519,9 @@ class ChooseParents: name = person.get_primary_name().get_surname() self.type = self.prel.get_active() - if self.type == const.FAMILY_CIVIL_UNION: + if self.type == RelLib.Family.CIVIL_UNION: self.parent_relation_changed(self.prel) - elif person.get_gender() == const.MALE: + elif person.get_gender() == RelLib.Person.MALE: try: path = self.father_model.on_get_path(handle) top_path = self.father_model.on_get_path(name) @@ -553,7 +553,7 @@ class ChooseParents: class to create a new person.""" person = RelLib.Person() - person.set_gender(const.MALE) + person.set_gender(RelLib.Person.MALE) try: import EditPerson @@ -643,7 +643,7 @@ class ModifyParents: self.title.set_use_markup(True) - if self.family.get_relationship() == const.FAMILY_CIVIL_UNION: + if self.family.get_relationship() == RelLib.Family.CIVIL_UNION: self.mlabel.set_label("%s" % _("Pa_rent")) self.flabel.set_label("%s" % _("Par_ent")) else: diff --git a/src/EditPerson.py b/src/EditPerson.py index 23fec39a1..6a1e4167b 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -114,7 +114,7 @@ class EditPerson: self.name_display = NameDisplay.displayer self.should_guess_gender = (person.get_gramps_id() == '' and person.get_gender () == - const.UNKNOWN) + RelLib.Person.UNKNOWN) for key in db.get_place_handles(): p = db.get_place_from_handle(key).get_display_info() @@ -761,11 +761,11 @@ class EditPerson: (female,male,unknown) = _select_gender[self.gender.get_active()] - if male and self.person.get_gender() != const.MALE: + if male and self.person.get_gender() != RelLib.Person.MALE: changed = True - elif female and self.person.get_gender() != const.FEMALE: + elif female and self.person.get_gender() != RelLib.Person.FEMALE: changed = True - elif unknown and self.person.get_gender() != const.UNKNOWN: + elif unknown and self.person.get_gender() != RelLib.Person.UNKNOWN: changed = True if text != self.person.get_note(): changed = True @@ -865,7 +865,7 @@ class EditPerson: def on_apply_person_clicked(self,obj): - if self.gender.get_active() == const.UNKNOWN: + if self.gender.get_active() == RelLib.Person.UNKNOWN: dialog = QuestionDialog2( _("Unknown gender specified"), _("The gender of the person is currently unknown. " @@ -956,8 +956,8 @@ class EditPerson: error = False (female,male,unknown) = _select_gender[self.gender.get_active()] - if male and self.person.get_gender() != const.MALE: - self.person.set_gender(const.MALE) + if male and self.person.get_gender() != RelLib.Person.MALE: + self.person.set_gender(RelLib.Person.MALE) for temp_family_handle in self.person.get_family_handle_list(): temp_family = self.db.get_family_from_handle(temp_family_handle) if self.person == temp_family.get_mother_handle(): @@ -966,8 +966,8 @@ class EditPerson: else: temp_family.set_mother_handle(None) temp_family.set_father_handle(self.person) - elif female and self.person.get_gender() != const.FEMALE: - self.person.set_gender(const.FEMALE) + elif female and self.person.get_gender() != RelLib.Person.FEMALE: + self.person.set_gender(RelLib.Person.FEMALE) for temp_family_handle in self.person.get_family_handle_list(): temp_family = self.db.get_family_from_handle(temp_family_handle) if self.person == temp_family.get_father_handle(): @@ -976,8 +976,8 @@ class EditPerson: else: temp_family.set_father_handle(None) temp_family.set_mother_handle(self.person) - elif unknown and self.person.get_gender() != const.UNKNOWN: - self.person.set_gender(const.UNKNOWN) + elif unknown and self.person.get_gender() != RelLib.Person.UNKNOWN: + self.person.set_gender(RelLib.Person.UNKNOWN) for temp_family_handle in self.person.get_family_handle_list(): temp_family = self.db.get_family_from_handle(temp_family_handle) if self.person == temp_family.get_father_handle(): diff --git a/src/FamilyView.py b/src/FamilyView.py index cb18296c4..bf3747a0d 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -685,10 +685,10 @@ class FamilyView: if not self.person: return person = RelLib.Person() - if self.person.get_gender() == const.MALE: - person.set_gender(const.FEMALE) + if self.person.get_gender() == RelLib.Person.MALE: + person.set_gender(RelLib.Person.FEMALE) else: - person.set_gender(const.MALE) + person.set_gender(RelLib.Person.MALE) try: EditPerson.EditPerson(self.parent, person, self.parent.db, self.new_spouse_after_edit) @@ -712,7 +712,7 @@ class FamilyView: old_person.add_family_handle(fhandle) new_person.add_family_handle(fhandle) - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: family.set_mother_handle(epo.person.get_handle()) family.set_father_handle(self.person.get_handle()) else: @@ -761,7 +761,7 @@ class FamilyView: self.family = RelLib.Family() self.parent.db.add_family(self.family,trans) person.add_family_handle(self.family.get_handle()) - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: self.family.set_father_handle(person) else: self.family.set_mother_handle(person) @@ -783,7 +783,7 @@ class FamilyView: family = RelLib.Family() self.parent.db.add_family(family,trans) person.add_family_handle(family.get_handle()) - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: family.set_father_handle(person.get_handle()) else: family.set_mother_handle(person.get_handle()) @@ -1434,7 +1434,7 @@ class FamilyView: family = RelLib.Family() self.parent.db.add_family(family,trans) person.add_family_handle(family.get_handle()) - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: family.set_father_handle(person.get_handle()) else: family.set_mother_handle(person.get_handle()) @@ -1546,7 +1546,7 @@ class FamilyView: sel_data.set(sel_data.target, bits_per, data) def north_american(self,val): - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: pname = self.person.get_primary_name() return (pname.get_surname_prefix(),pname.get_surname()) elif self.family: @@ -1579,7 +1579,7 @@ class FamilyView: def icelandic(self,val): fname = "" - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: fname = self.person.get_primary_name().get_first_name() elif self.family: f = self.family.get_father_handle() diff --git a/src/GenericFilter.py b/src/GenericFilter.py index 48c7f5c32..e11b3125d 100644 --- a/src/GenericFilter.py +++ b/src/GenericFilter.py @@ -328,7 +328,7 @@ class IsFemale(Rule): description = _('Matches all females') def apply(self,db,handle): - return db.get_person_from_handle(handle).get_gender() == const.FEMALE + return db.get_person_from_handle(handle).get_gender() == RelLib.Person.FEMALE #------------------------------------------------------------------------- # @@ -343,7 +343,7 @@ class HasUnknownGender(Rule): description = _('Matches all people with unknown gender') def apply(self,db,handle): - return db.get_person_from_handle(handle).get_gender() == const.UNKNOWN + return db.get_person_from_handle(handle).get_gender() == RelLib.Person.UNKNOWN #------------------------------------------------------------------------- # @@ -970,7 +970,7 @@ class IsMale(Rule): description = _('Matches all males') def apply(self,db,handle): - return db.get_person_from_handle(handle).get_gender() == const.MALE + return db.get_person_from_handle(handle).get_gender() == RelLib.Person.MALE #------------------------------------------------------------------------- # diff --git a/src/PedView.py b/src/PedView.py index a434d021b..ca3da2cc1 100644 --- a/src/PedView.py +++ b/src/PedView.py @@ -281,9 +281,9 @@ class PedigreeView: tooltip.set_tip(text, self.format_person(lst[i][0], 11)) text.set_alignment(0.0,0.0) gender = lst[i][0].get_gender() - if gender == const.MALE: + if gender == RelLib.Person.MALE: text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#F5FFFF")) - elif gender == const.FEMALE: + elif gender == RelLib.Person.FEMALE: text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#FFF5FF")) else: text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#FFFFF5")) diff --git a/src/ReadGedcom.py b/src/ReadGedcom.py index 1a1a15c1d..1ec89d731 100644 --- a/src/ReadGedcom.py +++ b/src/ReadGedcom.py @@ -884,7 +884,7 @@ class GedcomParser: except: event.set_name(matches[1]) if event.get_name() == "Marriage": - self.family.set_relationship(const.FAMILY_MARRIED) + self.family.set_relationship(RelLib.Family.MARRIED) self.db.add_event(event,self.trans) self.family.add_event_handle(event.get_handle()) self.parse_family_event(event,2) @@ -972,11 +972,11 @@ class GedcomParser: note = self.parse_note(matches,self.person,1,note) elif matches[1] == "SEX": if matches[2] == '': - self.person.set_gender(const.UNKNOWN) + self.person.set_gender(RelLib.Person.UNKNOWN) elif matches[2][0] == "M": - self.person.set_gender(const.MALE) + self.person.set_gender(RelLib.Person.MALE) else: - self.person.set_gender(const.FEMALE) + self.person.set_gender(RelLib.Person.FEMALE) elif matches[1] in [ "BAPL", "ENDL", "SLGC" ]: lds_ord = RelLib.LdsOrd() if matches[1] == "BAPL": @@ -1138,7 +1138,7 @@ class GedcomParser: self.backup() return (ftype,note) elif matches[1] == "PEDI": - ftype = pedi_type.get(matches[2],const.UNKNOWN) + ftype = pedi_type.get(matches[2],RelLib.Person.UNKNOWN) elif matches[1] == "SOUR": source_ref = self.handle_source(matches,level+1) self.person.get_primary_name().add_source_reference(source_ref) diff --git a/src/ReadXML.py b/src/ReadXML.py index 6a3fad77f..5091a2ff5 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -792,7 +792,7 @@ class GrampsParser: if attrs.has_key("type"): self.family.set_relationship( _FAMILY_TRANS.get(attrs["type"], - const.FAMILY_UNKNOWN)) + RelLib.Family.UNKNOWN)) if attrs.has_key("complete"): self.family.set_complete_flag(int(attrs['complete'])) else: @@ -1242,11 +1242,11 @@ class GrampsParser: def stop_gender(self,tag): t = tag if t == "M": - self.person.set_gender (const.MALE) + self.person.set_gender (RelLib.Person.MALE) elif t == "F": - self.person.set_gender (const.FEMALE) + self.person.set_gender (RelLib.Person.FEMALE) else: - self.person.set_gender (const.UNKNOWN) + self.person.set_gender (RelLib.Person.UNKNOWN) def stop_stitle(self,tag): self.source.set_title(tag) diff --git a/src/RelLib.py b/src/RelLib.py index c3cc1b8f5..460c1b075 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -42,7 +42,6 @@ from warnings import warn # GRAMPS modules # #------------------------------------------------------------------------- -import const import Date import DateHandler @@ -891,6 +890,19 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): @sort: serialize, unserialize, get_*, set_*, add_*, remove_* """ + UNKNOWN = 2 + MALE = 1 + FEMALE = 0 + + CHILD_NONE = 0 + CHILD_BIRTH = 1 + CHILD_ADOPTED = 2 + CHILD_STEPCHILD = 3 + CHILD_SPONSORED = 4 + CHILD_FOSTER = 5 + CHILD_UNKNOWN = 6 + CHILD_CUSTOM = 7 + def __init__(self): """ Creates a new Person instance. After initialization, most @@ -907,7 +919,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): self.parent_family_list = [] self.nickname = "" self.alternate_names = [] - self.gender = const.UNKNOWN + self.gender = Person.UNKNOWN self.death_ref = None self.birth_ref = None self.address_list = [] @@ -1210,9 +1222,9 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): @param gender: Assigns the Person's gender to one of the following constants:: - const.MALE - const.FEMALE - const.UNKNOWN + Person.MALE + Person.FEMALE + Person.UNKNOWN @type gender: int """ # if the db object has been assigned, update the @@ -1228,9 +1240,9 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): Returns the gender of the Person @returns: Returns one of the following constants:: - const.MALE - const.FEMALE - const.UNKNOWN + Person.MALE + Person.FEMALE + Person.UNKNOWN @rtype: int """ return self.gender @@ -1264,7 +1276,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): # remove when transitition done. event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( const.ROLE_PRIMARY) + event_ref.set_role( EventRef.ROLE_PRIMARY) self.set_death_ref( event_ref) def set_death_ref(self,event_ref): @@ -1327,7 +1339,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): # remove when transitition done. event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( const.ROLE_PRIMARY) + event_ref.set_role( EventRef.ROLE_PRIMARY) self.add_event_ref( event_ref) def add_event_ref(self,event_ref): @@ -1372,7 +1384,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): for event_handle in event_list: event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( const.ROLE_PRIMARY) + event_ref.set_role( EventRef.ROLE_PRIMARY) event_ref_list.append( event_ref) self.set_event_ref_list(event_ref_list) @@ -1737,6 +1749,12 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): or the changes will be lost. """ + MARRIED = 0 + UNMARRIED = 1 + CIVIL_UNION = 2 + UNKNOWN = 3 + CUSTOM = 4 + def __init__(self): """ Creates a new Family instance. After initialization, most @@ -1750,7 +1768,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): self.father_handle = None self.mother_handle = None self.child_list = [] - self.type = const.FAMILY_MARRIED + self.type = Family.MARRIED self.event_ref_list = [] self.lds_seal = None self.complete = 0 @@ -1937,17 +1955,17 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): Sets the relationship type between the people identified as the father and mother in the relationship. The valid values are: - - C{const.FAMILY_MARRIED} : indicates a legally recognized married + - C{Family.MARRIED} : indicates a legally recognized married relationship between two individuals. This may be either an opposite or a same sex relationship. - - C{const_FAMILY_UNMARRIED} : indicates a relationship between two + - C{Family.UNMARRIED} : indicates a relationship between two individuals that is not a legally recognized relationship. - - C{const_FAMILY_CIVIL_UNION} : indicates a legally recongnized, + - C{Family.CIVIL_UNION} : indicates a legally recongnized, non-married relationship between two individuals of the same sex. - - C{const.FAMILY_UNKNOWN} : indicates that the type of relationship + - C{Family.UNKNOWN} : indicates that the type of relationship between the two individuals is not know. - - C{const.FAMILY_CUSTOM} : indicates that the type of relationship + - C{Family.CUSTOM} : indicates that the type of relationship between the two individuals does not match any of the other types. @@ -2061,8 +2079,8 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): # remove when transitition done. event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( const.ROLE_PRIMARY) - self.add_event_ref( event_ref) + event_ref.set_role(EventRef.ROLE_PRIMARY) + self.add_event_ref(event_ref) def add_event_ref(self,event_ref): """ @@ -2106,7 +2124,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): for event_handle in event_list: event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( const.ROLE_PRIMARY) + event_ref.set_role(EventRef.ROLE_PRIMARY) event_ref_list.append( event_ref) self.set_event_ref_list(event_ref_list) @@ -2128,9 +2146,53 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): such as a birth, death, or marriage. """ - NAME = 0 - ID = 1 - + 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 @@ -2147,7 +2209,8 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): if source: self.description = source.description - self.name = source.name + self.type_int = source.type_int + self.type_str = source.type_str self.cause = source.cause if source.witness != None: self.witness = source.witness[:] @@ -2155,7 +2218,8 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): self.witness = None else: self.description = "" - self.name = "" + self.type_int = Event.CUSTOM + self.type_str = "" self.cause = "" self.witness = None @@ -2175,10 +2239,10 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): be considered persistent. @rtype: tuple """ - return (self.handle, self.gramps_id, self.name, self.date, - self.description, self.place, self.cause, self.private, - self.source_list, self.note, self.witness, self.media_list, - self.change) + return (self.handle, self.gramps_id, self.type_int, self.type_str, + self.date, self.description, self.place, self.cause, + self.private, self.source_list, self.note, self.witness, + self.media_list, self.change) def unserialize(self,data): """ @@ -2189,9 +2253,10 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): Person object @type data: tuple """ - (self.handle, self.gramps_id, self.name, self.date, self.description, - self.place, self.cause, self.private, self.source_list, - self.note, self.witness, self.media_list, self.change) = data + (self.handle, self.gramps_id, self.type_int, self.type_str, + self.date, self.description, self.place, self.cause, self.private, + self.source_list, self.note, self.witness, self.media_list, + self.change) = data def _has_handle_reference(self,classname,handle): if classname == 'Place': @@ -3488,6 +3553,15 @@ class Attribute(PrivateSourceNote): """Provides a simple key/value pair for describing properties. Used by the Person and Family objects to store descriptive information.""" + UNKNOWN = -1 + CUSTOM = 0 + CASTE = 1 + DESCRIPTION = 2 + ID = 3 + NATIONAL = 4 + NUM_CHILD = 5 + SSN = 6 + def __init__(self,source=None): """creates a new Attribute object, copying from the source if provided""" PrivateSourceNote.__init__(self,source) @@ -3658,6 +3732,12 @@ class Name(PrivateSourceNote,DateBase): LNFN = 1 # last name, first name FNLN = 2 # first name, last name + UNKNOWN = -1 + CUSTOM = 0 + AKA = 1 + BIRTH = 2 + MARRIED = 3 + def __init__(self,source=None): """creates a new Name instance, copying from the source if provided""" PrivateSourceNote.__init__(self,source) @@ -4076,6 +4156,12 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase): """Source reference, containing detailed information about how a referenced source relates to it""" + CONF_VERY_HIGH = 4 + CONF_HIGH = 3 + CONF_NORMAL = 2 + CONF_LOW = 1 + CONF_VERY_LOW = 0 + def __init__(self,source=None): """creates a new SourceRef, copying from the source if present""" DateBase.__init__(self,source) @@ -4087,7 +4173,7 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase): self.page = source.page self.text = source.text else: - self.confidence = const.CONF_NORMAL + self.confidence = SourceRef.CONF_NORMAL self.ref = None self.page = "" self.note = Note() @@ -4188,6 +4274,16 @@ class EventRef(BaseObject,PrivacyBase,NoteBase): to the refereneced event. """ + UNKNOWN = -1 + CUSTOM = 0 + PRIMARY = 1 + CLERGY = 2 + CELEBRANT = 3 + AIDE = 4 + BRIDE = 5 + GROOM = 6 + WITNESS = 7 + def __init__(self,source=None): """ Creates a new EventRef instance, copying from the source if present. @@ -4200,7 +4296,7 @@ class EventRef(BaseObject,PrivacyBase,NoteBase): self.role_str = source.role_str else: self.ref = None - self.role_int = const.ROLE_CUSTOM + self.role_int = EventRef.ROLE_CUSTOM self.role_str = "" def get_text_data_list(self): @@ -4253,7 +4349,7 @@ class EventRef(BaseObject,PrivacyBase,NoteBase): Returns the integer corresponding to the preset role. If custom then the string is returned. """ - if self.role_int == const.ROLE_CUSTOM: + if self.role_int == EventRef.ROLE_CUSTOM: return self.role_str else: return self.role_int @@ -4264,7 +4360,7 @@ class EventRef(BaseObject,PrivacyBase,NoteBase): If integer, it is set as is. If string, it is recorded as custom role. """ if type(role) == str: - self.role_int = const.ROLE_CUSTOM + self.role_int = EventRef.ROLE_CUSTOM self.role_str = role elif type(role) == int: self.role_int = role @@ -4314,11 +4410,11 @@ class GenderStats: else: increment = -1 - if gender == const.MALE: + if gender == Person.MALE: male += increment - elif gender == const.FEMALE: + elif gender == Person.FEMALE: female += increment - elif gender == const.UNKNOWN: + elif gender == Person.UNKNOWN: unknown += increment self.stats[name] = (male, female, unknown) @@ -4330,27 +4426,44 @@ class GenderStats: def guess_gender (self, name): name = self._get_key_from_name (name) if not name or not self.stats.has_key (name): - return const.UNKNOWN + return Person.UNKNOWN (male, female, unknown) = self.stats[name] if unknown == 0: if male and not female: - return const.MALE + return Person.MALE if female and not male: - return const.FEMALE + return Person.FEMALE if male > (2 * female): - return const.MALE + return Person.MALE if female > (2 * male): - return const.FEMALE + return Person.FEMALE - return const.UNKNOWN + return Person.UNKNOWN class RepoRef(BaseObject,NoteBase): """ Repository reference class. """ + + UNKNOWN = -1 + CUSTOM = 0 + AUDIO = 1 + BOOK = 2 + CARD = 3 + ELECTRONIC = 4 + FICHE = 5 + FILM = 6 + MAGAZINE = 7 + MANUSCRIPT = 8 + MAP = 9 + NEWSPAPER = 10 + PHOTO = 11 + THOMBSTOBE = 12 + VIDEO = 13 + def __init__(self,source=None): NoteBase.__init__(self) if source: @@ -4361,7 +4474,7 @@ class RepoRef(BaseObject,NoteBase): else: self.ref = None self.call_number = "" - self.media_type_int = const.SRC_MEDIA_CUSTOM + self.media_type_int = RepoRef.CUSTOM self.media_type_str = "" def get_text_data_list(self): @@ -4410,7 +4523,7 @@ class RepoRef(BaseObject,NoteBase): return self.call_number def get_media_type(self): - if self.media_type_int == const.SRC_MEDIA_CUSTOM: + if self.media_type_int == RepoRef.CUSTOM: return self.media_type_str else: return self.media_type_int @@ -4420,7 +4533,7 @@ class RepoRef(BaseObject,NoteBase): self.media_type_int = media_type self.media_type_str = "" else: - self.media_type_int = const.SRC_MEDIA_CUSTOM + self.media_type_int = RepoRef.CUSTOM self.media_type_str = media_type class Repository(PrimaryObject,NoteBase): @@ -4668,12 +4781,12 @@ if __name__ == "__main__": rr1 = RepoRef() rr1.set_reference_handle('ref-handle') rr1.set_call_number('call-number') - rr1.set_media_type(const.SRC_MEDIA_BOOK) + rr1.set_media_type(RepoRef.BOOK) rr1.set_note('some note') assert rr1.get_reference_handle() == 'ref-handle' assert rr1.get_call_number() == 'call-number' - assert rr1.get_media_type() == const.SRC_MEDIA_BOOK + assert rr1.get_media_type() == RepoRef.BOOK assert rr1.get_note() == 'some note' unittest.main() diff --git a/src/Relationship.py b/src/Relationship.py index 0297769a3..6386d0f12 100644 --- a/src/Relationship.py +++ b/src/Relationship.py @@ -322,22 +322,22 @@ class RelationshipCalculator: if firstRel == 0: if secondRel == 0: return ('',common) - elif other_person.get_gender() == const.MALE: + elif other_person.get_gender() == RelLib.Person.MALE: return (self.get_father(secondRel),common) else: return (self.get_mother(secondRel),common) elif secondRel == 0: - if other_person.get_gender() == const.MALE: + if other_person.get_gender() == RelLib.Person.MALE: return (self.get_son(firstRel),common) else: return (self.get_daughter(firstRel),common) elif firstRel == 1: - if other_person.get_gender() == const.MALE: + if other_person.get_gender() == RelLib.Person.MALE: return (self.get_uncle(secondRel),common) else: return (self.get_aunt(secondRel),common) elif secondRel == 1: - if other_person.get_gender() == const.MALE: + if other_person.get_gender() == RelLib.Person.MALE: return (self.get_nephew(firstRel-1),common) else: return (self.get_niece(firstRel-1),common) diff --git a/src/ReportUtils.py b/src/ReportUtils.py index 7582b7fdf..723d30ac1 100644 --- a/src/ReportUtils.py +++ b/src/ReportUtils.py @@ -499,7 +499,7 @@ def born_died_str(database,person,endnotes=None,name_object=None,person_name=Non if person_name == None: person_name = _nd.display_name(name_object) elif person_name == 0: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: person_name = _('He') else: person_name = _('She') @@ -510,7 +510,7 @@ def born_died_str(database,person,endnotes=None,name_object=None,person_name=Non birth = database.get_event_from_handle(person.get_birth_handle()) death = database.get_event_from_handle(person.get_death_handle()) - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: if bdate: if bplace: if ddate: @@ -817,7 +817,7 @@ def married_str(database,person,spouse,event,endnotes=None, text = "" if is_first: if date and place: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He married %(spouse)s %(date)s in %(place)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event), @@ -830,7 +830,7 @@ def married_str(database,person,spouse,event,endnotes=None, 'endnotes' : endnotes(event), 'place' : place} elif date: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He married %(spouse)s %(date)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event), @@ -841,7 +841,7 @@ def married_str(database,person,spouse,event,endnotes=None, 'endnotes' : endnotes(event), 'place' : place,} elif place: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He married %(spouse)s in %(place)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event), @@ -852,7 +852,7 @@ def married_str(database,person,spouse,event,endnotes=None, 'endnotes' : endnotes(event), 'place' : place} else: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He married %(spouse)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event) } @@ -862,7 +862,7 @@ def married_str(database,person,spouse,event,endnotes=None, 'endnotes' : endnotes(event)} else: if date and place: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He also married %(spouse)s %(date)s in %(place)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event), @@ -875,7 +875,7 @@ def married_str(database,person,spouse,event,endnotes=None, 'endnotes' : endnotes(event), 'place' : place} elif date: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He also married %(spouse)s %(date)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event), @@ -886,7 +886,7 @@ def married_str(database,person,spouse,event,endnotes=None, 'endnotes' : endnotes(event), 'place' : place,} elif place: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He also married %(spouse)s in %(place)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event), @@ -897,7 +897,7 @@ def married_str(database,person,spouse,event,endnotes=None, 'endnotes' : endnotes(event), 'place' : place} else: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He also married %(spouse)s%(endnotes)s.') % { 'spouse' : spouse_name, 'endnotes' : endnotes(event) } @@ -921,26 +921,26 @@ def married_rel_str(database,person,family,is_first=True): spouse_name = _nd.display(spouse) if is_first: - if family.get_relationship() == const.FAMILY_MARRIED: - if person.get_gender() == const.MALE: + if family.get_relationship() == RelLib.Family.MARRIED: + if person.get_gender() == RelLib.Person.MALE: text = _('He married %(spouse)s.') % { 'spouse' : spouse_name } else: text = _('She married %(spouse)s.') % { 'spouse' : spouse_name } else: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He had relationship with %(spouse)s.') % { 'spouse' : spouse_name } else: text = _('She had relationship with %(spouse)s.') % { 'spouse' : spouse_name } else: - if family.get_relationship() == const.FAMILY_MARRIED: - if person.get_gender() == const.MALE: + if family.get_relationship() == RelLib.Family.MARRIED: + if person.get_gender() == RelLib.Person.MALE: text = _('He also married %(spouse)s.') % { 'spouse' : spouse_name } else: text = _('She also married %(spouse)s.') % { 'spouse' : spouse_name } else: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: text = _('He also had relationship with %(spouse)s.') % { 'spouse' : spouse_name } else: @@ -972,7 +972,7 @@ def child_str(person,father_name="",mother_name="",dead=0): text = "" - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: if mother_name and father_name: if dead: text = _("He was the son of %(father)s and %(mother)s.") % { @@ -1053,7 +1053,7 @@ def born_str(database,person,person_name=None,empty_date="",empty_place=""): if person_name == None: person_name = _nd.display_name(person.get_primary_name()) elif person_name == 0: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: person_name = _('He') else: person_name = _('She') @@ -1063,7 +1063,7 @@ def born_str(database,person,person_name=None,empty_date="",empty_place=""): bdate,bplace,bdate_full,ddate,dplace,ddate_full = \ get_birth_death_strings(database,person,empty_date,empty_place) - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: if bdate and bdate_full: if bplace: #male, date, place text = _("%(male_name)s " @@ -1151,7 +1151,7 @@ def died_str(database,person,person_name=None,empty_date="",empty_place="", if person_name == None: person_name = _nd.display_name(person.get_primary_name()) elif person_name == 0: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: person_name = _('He') else: person_name = _('She') @@ -1161,7 +1161,7 @@ def died_str(database,person,person_name=None,empty_date="",empty_place="", bdate,bplace,bdate_full,ddate,dplace,ddate_full = \ get_birth_death_strings(database,person,empty_date,empty_place) - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: if ddate and ddate_full: if dplace: if not age_units: #male, date, place, no age @@ -1442,7 +1442,7 @@ def buried_str(database,person,person_name=None,empty_date="",empty_place=""): if person_name == None: person_name = _nd.display_name(person.get_primary_name()) elif person_name == 0: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: person_name = _('He') else: person_name = _('She') @@ -1470,7 +1470,7 @@ def buried_str(database,person,person_name=None,empty_date="",empty_place=""): else: return text - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: if bdate and bdate_full: if bplace: #male, date, place text = _("%(male_name)s " @@ -1535,7 +1535,7 @@ def list_person_str(database,person,person_name=None,empty_date="",empty_place=" if person_name == None: person_name = _nd.display_name(person.get_primary_name()) elif person_name == 0: - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: person_name = _('He') else: person_name = _('She') @@ -1545,7 +1545,7 @@ def list_person_str(database,person,person_name=None,empty_date="",empty_place=" text = "" - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: if bdate: if bplace: if ddate: @@ -1750,11 +1750,11 @@ def list_person_str(database,person,person_name=None,empty_date="",empty_place=" _rtype = { - const.FAMILY_MARRIED : _("Married"), - const.FAMILY_UNMARRIED : _("Unmarried"), - const.FAMILY_CIVIL_UNION : _("Civil Union"), - const.FAMILY_UNKNOWN : _("Unknown"), - const.FAMILY_CUSTOM : _("Other"), + RelLib.Family.MARRIED : _("Married"), + RelLib.Family.UNMARRIED : _("Unmarried"), + RelLib.Family.CIVIL_UNION : _("Civil Union"), + RelLib.Family.UNKNOWN : _("Unknown"), + RelLib.Family.CUSTOM : _("Other"), } def relationship_name(rtype): diff --git a/src/SelectChild.py b/src/SelectChild.py index d3e707d87..049d0fbc6 100644 --- a/src/SelectChild.py +++ b/src/SelectChild.py @@ -96,7 +96,7 @@ class SelectChild: father = self.db.get_person_from_handle(self.family.get_father_handle()) mother = self.db.get_person_from_handle(self.family.get_mother_handle()) else: - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: self.mrel.set_sensitive(False) else: self.frel.set_sensitive(False) @@ -237,9 +237,9 @@ class SelectChild: for idval in person_list: person = self.db.get_person_from_handle(idval) name = NameDisplay.displayer.display(person) - if person.gender == const.MALE: + if person.gender == RelLib.Person.MALE: gender = _("male") - elif person.gender == const.FEMALE: + elif person.gender == RelLib.Person.FEMALE: gender = _("female") else: gender = _("unknown") @@ -296,7 +296,7 @@ class SelectChild: self.db.add_family(self.family,trans) self.person.add_family_handle(self.family.get_handle()) self.db.commit_person(self.person,trans) - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: self.family.set_father_handle(self.person.get_handle()) else: self.family.set_mother_handle(self.person.get_handle()) @@ -312,13 +312,13 @@ class SelectChild: mrel = self.mrel.get_active() mother = self.db.get_person_from_handle(self.family.get_mother_handle()) - if mother and mother.get_gender() != const.FEMALE: + if mother and mother.get_gender() != RelLib.Person.FEMALE: if mrel == const.CHILD_BIRTH: mrel = const.CHILD_UNKNOWN frel = self.frel.get_active() father = self.db.get_person_from_handle(self.family.get_father_handle()) - if father and father.get_gender() != const.MALE: + if father and father.get_gender() != RelLib.Person.MALE: if frel == const.CHILD_BIRTH: frel = const.CHILD_UNKNOWN @@ -336,7 +336,7 @@ class SelectChild: self.redraw_child_list(not obj.get_active()) def north_american(self,val): - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: return self.person.get_primary_name().get_surname() elif self.family: f = self.family.get_father_handle() @@ -367,7 +367,7 @@ class SelectChild: def icelandic(self,val): fname = "" - if self.person.get_gender() == const.MALE: + if self.person.get_gender() == RelLib.Person.MALE: fname = self.person.get_primary_name().get_first_name() elif self.family: f = self.family.get_father_handle() diff --git a/src/Utils.py b/src/Utils.py index 7385fc8a8..4289025d2 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -27,6 +27,7 @@ #------------------------------------------------------------------------- import os import locale +from gettext import gettext as _ #------------------------------------------------------------------------- # @@ -51,13 +52,224 @@ import const import GrampsMime import NameDisplay import Date +import RelLib #------------------------------------------------------------------------- # -# internationalization +# Integer to String mappings for constants # #------------------------------------------------------------------------- -from gettext import gettext as _ +gender = { + RelLib.Person.MALE : _("male"), + RelLib.Person.FEMALE : _("female"), + RelLib.Person.UNKNOWN : _("unknown"), + } + +child_relations = { + RelLib.Person.CHILD_NONE : _("None"), + RelLib.Person.CHILD_BIRTH : _("Birth"), + RelLib.Person.CHILD_ADOPTED : _("Adopted"), + RelLib.Person.CHILD_STEPCHILD : _("Stepchild"), + RelLib.Person.CHILD_SPONSORED : _("Sponsored"), + RelLib.Person.CHILD_FOSTER : _("Foster"), + RelLib.Person.CHILD_UNKNOWN : _("Unknown"), + RelLib.Person.CHILD_CUSTOM : _("Custom"), + } + +confidence = { + RelLib.SourceRef.CONF_VERY_HIGH : _("Very High"), + RelLib.SourceRef.CONF_HIGH : _("High"), + RelLib.SourceRef.CONF_NORMAL : _("Normal"), + RelLib.SourceRef.CONF_LOW : _("Low"), + RelLib.SourceRef.CONF_VERY_LOW : _("Very Low"), + } + +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"), + } + +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") + } + +personal_attributes = { + RelLib.Attribute.UNKNOWN : _("Unknown"), + RelLib.Attribute.CUSTOM : _("Custom"), + RelLib.Attribute.CASTE : _("Caste"), + RelLib.Attribute.DESCRIPTION : _("Description"), + RelLib.Attribute.ID : _("Identification Number"), + RelLib.Attribute.NATIONAL : _("National Origin"), + RelLib.Attribute.NUM_CHILD : _("Number of Children"), + RelLib.Attribute.SSN : _("Social Security Number"), + } + +family_attributes = { + RelLib.Attribute.UNKNOWN : _("Unknown"), + RelLib.Attribute.CUSTOM : _("Custom"), + RelLib.Attribute.NUM_CHILD : _("Number of Children"), + } + +family_relations = { + RelLib.Family.MARRIED : _("Married"), + RelLib.Family.UNMARRIED : _("Unmarried"), + RelLib.Family.CIVIL_UNION : _("Civil Union"), + RelLib.Family.UNKNOWN : _("Unknown"), + RelLib.Family.CUSTOM : _("Other"), + } + +family_rel_descriptions = { + RelLib.Family.MARRIED : _("A legal or common-law relationship " + "between a husband and wife"), + RelLib.Family.UNMARRIED : _("No legal or common-law relationship " + "between man and woman"), + RelLib.Family.CIVIL_UNION : _("An established relationship between " + "members of the same sex"), + RelLib.Family.UNKNOWN : _("Unknown relationship between a man " + "and woman"), + RelLib.Family.CUSTOM : _("An unspecified relationship " + "a man and woman"), + } + +name_types = { + RelLib.Name.UNKNOWN : _("Unknown"), + RelLib.Name.CUSTOM : _("Custom"), + RelLib.Name.AKA : _("Also Known As"), + RelLib.Name.BIRTH : _("Birth Name"), + RelLib.Name.MARRIED : _("Married Name"), + } + +source_media_types = { + RelLib.RepoRef.UNKNOWN : _("Unknown"), + RelLib.RepoRef.CUSTOM : _("Custom"), + RelLib.RepoRef.AUDIO : _("Audio"), + RelLib.RepoRef.BOOK : _("Book"), + RelLib.RepoRef.CARD : _("Card"), + RelLib.RepoRef.ELECTRONIC : _("Electronic"), + RelLib.RepoRef.FICHE : _("Fiche"), + RelLib.RepoRef.FILM : _("Film"), + RelLib.RepoRef.MAGAZINE : _("Magazine"), + RelLib.RepoRef.MANUSCRIPT : _("Manuscript"), + RelLib.RepoRef.MAP : _("Map"), + RelLib.RepoRef.NEWSPAPER : _("Newspaper"), + RelLib.RepoRef.PHOTO : _("Photo"), + RelLib.RepoRef.THOMBSTOBE : _("Thombstone"), + RelLib.RepoRef.VIDEO : _("Video"), + } + +#------------------------------------------------------------------------- +# +# Integer to GEDCOM tag mappings for constants +# +#------------------------------------------------------------------------- +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" + } + +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 : "", + RelLib.Event.DIV_FILING : "DIVF", + RelLib.Event.EDUCATION : "EDUC", + RelLib.Event.ELECTED : "", + RelLib.Event.ELECTED : "EMIG", + RelLib.Event.FIRST_COMMUN : "FCOM", + RelLib.Event.GRADUATION : "GRAD", + RelLib.Event.MED_INFO : "", + RelLib.Event.MILITARY_SERV : "", + 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", + } + +familyConstantAttributes = { + RelLib.Attribute.NUM_CHILD : "NCHI", + } + +personalConstantAttributes = { + RelLib.Attribute.CASTE : "CAST", + RelLib.Attribute.DESCRIPTION : "DSCR", + RelLib.Attribute.ID : "IDNO", + RelLib.Attribute.NATIONAL : "NATI", + RelLib.Attribute.NUM_CHILD : "NCHI", + RelLib.Attribute.SSN : "SSN", + } #------------------------------------------------------------------------- # diff --git a/src/WriteGedcom.py b/src/WriteGedcom.py index 88c0f6c5a..875268b3b 100644 --- a/src/WriteGedcom.py +++ b/src/WriteGedcom.py @@ -789,9 +789,9 @@ class GedcomWriter: for name in person.get_alternate_names(): self.write_person_name(name,"") - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: self.writeln("1 SEX M") - elif person.get_gender() == const.FEMALE: + elif person.get_gender() == RelLib.Person.FEMALE: self.writeln("1 SEX F") if not restricted: diff --git a/src/WriteXML.py b/src/WriteXML.py index c51b7d74c..1fcc6c429 100644 --- a/src/WriteXML.py +++ b/src/WriteXML.py @@ -253,9 +253,9 @@ class XmlWriter: count += 1 self.write_id("person",person,2) - if person.get_gender() == const.MALE: + if person.get_gender() == RelLib.Person.MALE: self.write_line("gender","M",3) - elif person.get_gender() == const.FEMALE: + elif person.get_gender() == RelLib.Person.FEMALE: self.write_line("gender","F",3) else: self.write_line("gender","U",3) diff --git a/src/const.py.in b/src/const.py.in index 6af4c8050..865944f77 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -28,12 +28,6 @@ # #------------------------------------------------------------------------- import os - -#------------------------------------------------------------------------- -# -# internationalization -# -#------------------------------------------------------------------------- from gettext import gettext as _ #------------------------------------------------------------------------- @@ -77,7 +71,6 @@ prefixdir = "@GPREFIX@" # Configuration database options - True means drop down to .INI files # #------------------------------------------------------------------------- - no_gconf = False #------------------------------------------------------------------------- @@ -86,7 +79,6 @@ no_gconf = False # this one, and that the plugins directory is in a directory below this. # #------------------------------------------------------------------------- - if os.environ.has_key('GRAMPSDIR'): rootDir = os.environ['GRAMPSDIR'] else: @@ -219,383 +211,6 @@ longopts = [ shortopts = "O:i:o:f:a:p:?" -#------------------------------------------------------------------------- -# -# Gender constants -# -#------------------------------------------------------------------------- -UNKNOWN = 2 -MALE = 1 -FEMALE = 0 - -gender = { - MALE : _("male"), - FEMALE : _("female"), - UNKNOWN : _("unknown"), - } - -#------------------------------------------------------------------------- -# -# Child relation constants -# -#------------------------------------------------------------------------- -CHILD_NONE = 0 -CHILD_BIRTH = 1 -CHILD_ADOPTED = 2 -CHILD_STEPCHILD = 3 -CHILD_SPONSORED = 4 -CHILD_FOSTER = 5 -CHILD_UNKNOWN = 6 -CHILD_CUSTOM = 7 - -child_relations = { - CHILD_NONE : _("None"), - CHILD_BIRTH : _("Birth"), - CHILD_ADOPTED : _("Adopted"), - CHILD_STEPCHILD : _("Stepchild"), - CHILD_SPONSORED : _("Sponsored"), - CHILD_FOSTER : _("Foster"), - CHILD_UNKNOWN : _("Unknown"), - CHILD_CUSTOM : _("Custom"), - } - -#------------------------------------------------------------------------- -# -# Confidence constants -# -#------------------------------------------------------------------------- -CONF_VERY_HIGH = 4 -CONF_HIGH = 3 -CONF_NORMAL = 2 -CONF_LOW = 1 -CONF_VERY_LOW = 0 - -confidence = { - CONF_VERY_HIGH : _("Very High"), - CONF_HIGH : _("High"), - CONF_NORMAL : _("Normal"), - CONF_LOW : _("Low"), - CONF_VERY_LOW : _("Very Low"), - } - -#------------------------------------------------------------------------- -# -# Event constants -# -#------------------------------------------------------------------------- -EVENT_UNKNOWN = -1 -EVENT_CUSTOM = 0 -EVENT_MARRIAGE = 1 -EVENT_MARR_SETTL = 2 -EVENT_MARR_LIC = 3 -EVENT_MARR_CONTR = 4 -EVENT_MARR_BANNS = 5 -EVENT_ENGAGEMENT = 6 -EVENT_DIVORCE = 7 -EVENT_DIV_FILING = 8 -EVENT_ANNULMENT = 9 -EVENT_MARR_ALT = 10 -EVENT_ADOPT = 11 -EVENT_BIRTH = 12 -EVENT_DEATH = 13 -EVENT_ADULT_CHRISTEN = 14 -EVENT_BAPTISM = 15 -EVENT_BAR_MITZVAH = 16 -EVENT_BAS_MITZVAH = 17 -EVENT_BLESS = 18 -EVENT_BURIAL = 19 -EVENT_CAUSE_DEATH = 20 -EVENT_CENSUS = 21 -EVENT_CHRISTEN = 22 -EVENT_CONFIRMATION = 23 -EVENT_CREMATION = 24 -EVENT_DEGREE = 25 -EVENT_EDUCATION = 26 -EVENT_ELECTED = 27 -EVENT_EMIGRATION = 28 -EVENT_FIRST_COMMUN = 29 -EVENT_IMMIGRATION = 30 -EVENT_GRADUATION = 31 -EVENT_MED_INFO = 32 -EVENT_MILITARY_SERV = 33 -EVENT_NATURALIZATION = 34 -EVENT_NOB_TITLE = 35 -EVENT_NUM_MARRIAGES = 36 -EVENT_OCCUPATION = 37 -EVENT_ORDINATION = 38 -EVENT_PROBATE = 39 -EVENT_PROPERTY = 40 -EVENT_RELIGION = 41 -EVENT_RESIDENCE = 42 -EVENT_RETIREMENT = 43 -EVENT_WILL = 44 - - -familyConstantEvents = { - EVENT_ANNULMENT : "ANUL", - EVENT_DIV_FILING : "DIVF", - EVENT_DIVORCE : "DIV", - EVENT_ENGAGEMENT : "ENGA", - EVENT_MARR_BANNS : "MARB", - EVENT_MARR_CONTR : "MARC", - EVENT_MARR_LIC : "MARL", - EVENT_MARR_SETTL : "MARS", - EVENT_MARRIAGE : "MARR" - } - -family_events = { - EVENT_UNKNOWN : _("Unknown"), - EVENT_CUSTOM : _("Custom"), - EVENT_MARRIAGE : _("Marriage"), - EVENT_MARR_SETTL : _("Marriage Settlement"), - EVENT_MARR_LIC : _("Marriage License"), - EVENT_MARR_CONTR : _("Marriage Contract"), - EVENT_MARR_BANNS : _("Marriage Banns"), - EVENT_ENGAGEMENT : _("Engagement"), - EVENT_DIVORCE : _("Divorce"), - EVENT_DIV_FILING : _("Divorce Filing"), - EVENT_ANNULMENT : _("Annulment"), - EVENT_MARR_ALT : _("Alternate Marriage"), - } - -personalConstantEvents = { - EVENT_ADOPT : "ADOP", - EVENT_ADULT_CHRISTEN : "CHRA", - EVENT_BIRTH : "BIRT", - EVENT_DEATH : "DEAT", - EVENT_BAPTISM : "BAPM", - EVENT_BAR_MITZVAH : "BARM", - EVENT_BAS_MITZVAH : "BASM", - EVENT_BLESS : "BLES", - EVENT_BURIAL : "BURI", - EVENT_CAUSE_DEATH : "CAUS", - EVENT_ORDINATION : "ORDI", - EVENT_CENSUS : "CENS", - EVENT_CHRISTEN : "CHR" , - EVENT_CONFIRMATION : "CONF", - EVENT_CREMATION : "CREM", - EVENT_DEGREE : "", - EVENT_DIV_FILING : "DIVF", - EVENT_EDUCATION : "EDUC", - EVENT_ELECTED : "", - EVENT_ELECTED : "EMIG", - EVENT_FIRST_COMMUN : "FCOM", - EVENT_GRADUATION : "GRAD", - EVENT_MED_INFO : "", - EVENT_MILITARY_SERV : "", - EVENT_NATURALIZATION : "NATU", - EVENT_NOB_TITLE : "TITL", - EVENT_NUM_MARRIAGES : "NMR", - EVENT_IMMIGRATION : "IMMI", - EVENT_OCCUPATION : "OCCU", - EVENT_PROBATE : "PROB", - EVENT_PROPERTY : "PROP", - EVENT_RELIGION : "RELI", - EVENT_RESIDENCE : "RESI", - EVENT_RETIREMENT : "RETI", - EVENT_WILL : "WILL", - } - -personal_events = { - EVENT_UNKNOWN : _("Unknown"), - EVENT_CUSTOM : _("Custom"), - EVENT_ADOPT : _("Adopted"), - EVENT_BIRTH : _("Birth"), - EVENT_DEATH : _("Death"), - EVENT_ADULT_CHRISTEN : _("Adult Christening"), - EVENT_BAPTISM : _("Baptism"), - EVENT_BAR_MITZVAH : _("Bar Mitzvah"), - EVENT_BAS_MITZVAH : _("Bas Mitzvah"), - EVENT_BLESS : _("Blessing"), - EVENT_BURIAL : _("Burial"), - EVENT_CAUSE_DEATH : _("Cause Of Death"), - EVENT_CENSUS : _("Census"), - EVENT_CHRISTEN : _("Christening"), - EVENT_CONFIRMATION : _("Confirmation"), - EVENT_CREMATION : _("Cremation"), - EVENT_DEGREE : _("Degree"), - EVENT_DIV_FILING : _("Divorce Filing"), - EVENT_EDUCATION : _("Education"), - EVENT_ELECTED : _("Elected"), - EVENT_EMIGRATION : _("Emigration"), - EVENT_FIRST_COMMUN : _("First Communion"), - EVENT_IMMIGRATION : _("Immigration"), - EVENT_GRADUATION : _("Graduation"), - EVENT_MED_INFO : _("Medical Information"), - EVENT_MILITARY_SERV : _("Military Service"), - EVENT_NATURALIZATION : _("Naturalization"), - EVENT_NOB_TITLE : _("Nobility Title"), - EVENT_NUM_MARRIAGES : _("Number of Marriages"), - EVENT_OCCUPATION : _("Occupation"), - EVENT_ORDINATION : _("Ordination"), - EVENT_PROBATE : _("Probate"), - EVENT_PROPERTY : _("Property"), - EVENT_RELIGION : _("Religion"), - EVENT_RESIDENCE : _("Residence"), - EVENT_RETIREMENT : _("Retirement"), - EVENT_WILL : _("Will") - } - -#------------------------------------------------------------------------- -# -# Attribute constants -# -#------------------------------------------------------------------------- -ATTR_UNKNOWN = -1 -ATTR_CUSTOM = 0 -ATTR_CASTE = 1 -ATTR_DESCRIPTION = 2 -ATTR_ID = 3 -ATTR_NATIONAL = 4 -ATTR_NUM_CHILD = 5 -ATTR_SSN = 6 - -personal_attributes = { - ATTR_UNKNOWN : _("Unknown"), - ATTR_CUSTOM : _("Custom"), - ATTR_CASTE : _("Caste"), - ATTR_DESCRIPTION : _("Description"), - ATTR_ID : _("Identification Number"), - ATTR_NATIONAL : _("National Origin"), - ATTR_NUM_CHILD : _("Number of Children"), - ATTR_SSN : _("Social Security Number"), - } - -personalConstantAttributes = { - ATTR_CASTE : "CAST", - ATTR_DESCRIPTION : "DSCR", - ATTR_ID : "IDNO", - ATTR_NATIONAL : "NATI", - ATTR_NUM_CHILD : "NCHI", - ATTR_SSN : "SSN", - } - -familyConstantAttributes = { - ATTR_NUM_CHILD : "NCHI", - } - -family_attributes = { - ATTR_UNKNOWN : _("Unknown"), - ATTR_CUSTOM : _("Custom"), - ATTR_NUM_CHILD : _("Number of Children"), - } - -#------------------------------------------------------------------------- -# -# Family Relationship Translation table -# -#------------------------------------------------------------------------- -FAMILY_MARRIED = 0 -FAMILY_UNMARRIED = 1 -FAMILY_CIVIL_UNION = 2 -FAMILY_UNKNOWN = 3 -FAMILY_CUSTOM = 4 - -family_relations = { - FAMILY_MARRIED : _("Married"), - FAMILY_UNMARRIED : _("Unmarried"), - FAMILY_CIVIL_UNION : _("Civil Union"), - FAMILY_UNKNOWN : _("Unknown"), - FAMILY_CUSTOM : _("Other"), - } - -family_rel_descriptions = { - FAMILY_MARRIED : _("A legal or common-law relationship " - "between a husband and wife"), - FAMILY_UNMARRIED : _("No legal or common-law relationship " - "between man and woman"), - FAMILY_CIVIL_UNION : _("An established relationship between " - "members of the same sex"), - FAMILY_UNKNOWN : _("Unknown relationship between a man and woman"), - FAMILY_CUSTOM : _("An unspecified relationship between " - "a man and woman"), - } - -#------------------------------------------------------------------------- -# -# Name constants -# -#------------------------------------------------------------------------- -NAME_UNKNOWN = -1 -NAME_CUSTOM = 0 -NAME_AKA = 1 -NAME_BIRTH = 2 -NAME_MARRIED = 3 - -NameTypesMap = { - NAME_UNKNOWN : _("Unknown"), - NAME_CUSTOM : _("Custom"), - NAME_AKA : _("Also Known As"), - NAME_BIRTH : _("Birth Name"), - NAME_MARRIED : _("Married Name"), - } - -#------------------------------------------------------------------------- -# -# Role constants -# -#------------------------------------------------------------------------- -ROLE_UNKNOWN = -1 -ROLE_CUSTOM = 0 -ROLE_PRIMARY = 1 -ROLE_CLERGY = 2 -ROLE_CELEBRANT = 3 -ROLE_AIDE = 4 -ROLE_BRIDE = 5 -ROLE_GROOM = 6 -ROLE_WITNESS = 7 - -event_roles = { - ROLE_UNKNOWN : _("Unknown"), - ROLE_CUSTOM : _("Custom"), - ROLE_PRIMARY : _("Primary participant"), - ROLE_CLERGY : _("Clergy personnel"), - ROLE_CELEBRANT : _("Celebrant"), - ROLE_AIDE : _("Aide"), - ROLE_BRIDE : _("Bride"), - ROLE_GROOM : _("Groom"), - ROLE_WITNESS : _("Witness"), - } - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -SRC_MEDIA_UNKNOWN = -1 -SRC_MEDIA_CUSTOM = 0 -SRC_MEDIA_AUDIO = 1 -SRC_MEDIA_BOOK = 2 -SRC_MEDIA_CARD = 3 -SRC_MEDIA_ELECTRONIC = 4 -SRC_MEDIA_FICHE = 5 -SRC_MEDIA_FILM = 6 -SRC_MEDIA_MAGAZINE = 7 -SRC_MEDIA_MANUSCRIPT = 8 -SRC_MEDIA_MAP = 9 -SRC_MEDIA_NEWSPAPER = 10 -SRC_MEDIA_PHOTO = 11 -SRC_MEDIA_THOMBSTOBE = 12 -SRC_MEDIA_VIDEO = 13 - -source_media_types = { - SRC_MEDIA_UNKNOWN : _("Unknown"), - SRC_MEDIA_CUSTOM : _("Custom"), - SRC_MEDIA_AUDIO : _("Audio"), - SRC_MEDIA_BOOK : _("Book"), - SRC_MEDIA_CARD : _("Card"), - SRC_MEDIA_ELECTRONIC : _("Electronic"), - SRC_MEDIA_FICHE : _("Fiche"), - SRC_MEDIA_FILM : _("Film"), - SRC_MEDIA_MAGAZINE : _("Magazine"), - SRC_MEDIA_MANUSCRIPT : _("Manuscript"), - SRC_MEDIA_MAP : _("Map"), - SRC_MEDIA_NEWSPAPER : _("Newspaper"), - SRC_MEDIA_PHOTO : _("Photo"), - SRC_MEDIA_THOMBSTOBE : _("Thombstone"), - SRC_MEDIA_VIDEO : _("Video"), - } - #------------------------------------------------------------------------- # #