1# 2# Gramps - a GTK+/GNOME based genealogy program 3# 4# Copyright (C) 2000-2007 Donald N. Allingham 5# Copyright (C) 2013 Paul Franklin 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program; if not, write to the Free Software 19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20# 21 22""" 23Provide the different event types 24""" 25 26#------------------------------------------------------------------------- 27# 28# Gramps modules 29# 30#------------------------------------------------------------------------- 31from .grampstype import GrampsType 32from ..const import GRAMPS_LOCALE as glocale 33_ = glocale.translation.sgettext 34 35class EventType(GrampsType): 36 """ 37 Event types. 38 39 .. attribute UNKNOWN: Unknown 40 .. attribute CUSTOM: Custom 41 .. attribute ADOPT: Adopted 42 .. attribute BIRTH: Birth 43 .. attribute DEATH: Death 44 .. attribute ADULT_CHRISTEN: Adult Christening 45 .. attribute BAPTISM: Baptism 46 .. attribute BAR_MITZVAH: Bar Mitzvah 47 .. attribute BAS_MITZVAH: Bas Mitzvah 48 .. attribute BLESS: Blessing 49 .. attribute BURIAL: Burial 50 .. attribute CAUSE_DEATH: Cause Of Death 51 .. attribute CENSUS: Census 52 .. attribute CHRISTEN: Christening 53 .. attribute CONFIRMATION: Confirmation 54 .. attribute CREMATION: Cremation 55 .. attribute DEGREE: Degree 56 .. attribute EDUCATION: Education 57 .. attribute ELECTED: Elected 58 .. attribute EMIGRATION: Emigration 59 .. attribute FIRST_COMMUN: First Communion 60 .. attribute IMMIGRATION: Immigration 61 .. attribute GRADUATION: Graduation 62 .. attribute MED_INFO: Medical Information 63 .. attribute MILITARY_SERV: Military Service 64 .. attribute NATURALIZATION: Naturalization 65 .. attribute NOB_TITLE: Nobility Title 66 .. attribute NUM_MARRIAGES: Number of Marriages 67 .. attribute OCCUPATION: Occupation 68 .. attribute ORDINATION: Ordination 69 .. attribute PROBATE: Probate 70 .. attribute PROPERTY: Property 71 .. attribute RELIGION: Religion 72 .. attribute RESIDENCE: Residence 73 .. attribute RETIREMENT: Retirement 74 .. attribute WILL: Will 75 .. attribute MARRIAGE: Marriage 76 .. attribute MARR_SETTL: Marriage Settlement 77 .. attribute MARR_LIC: Marriage License 78 .. attribute MARR_CONTR: Marriage Contract 79 .. attribute MARR_BANNS: Marriage Banns 80 .. attribute ENGAGEMENT: Engagement 81 .. attribute DIVORCE: Divorce 82 .. attribute DIV_FILING: Divorce Filing 83 .. attribute ANNULMENT: Annulment 84 .. attribute MARR_ALT: Alternate Marriage 85 """ 86 UNKNOWN = -1 87 CUSTOM = 0 88 MARRIAGE = 1 89 MARR_SETTL = 2 90 MARR_LIC = 3 91 MARR_CONTR = 4 92 MARR_BANNS = 5 93 ENGAGEMENT = 6 94 DIVORCE = 7 95 DIV_FILING = 8 96 ANNULMENT = 9 97 MARR_ALT = 10 98 ADOPT = 11 99 BIRTH = 12 100 DEATH = 13 101 ADULT_CHRISTEN = 14 102 BAPTISM = 15 103 BAR_MITZVAH = 16 104 BAS_MITZVAH = 17 105 BLESS = 18 106 BURIAL = 19 107 CAUSE_DEATH = 20 108 CENSUS = 21 109 CHRISTEN = 22 110 CONFIRMATION = 23 111 CREMATION = 24 112 DEGREE = 25 113 EDUCATION = 26 114 ELECTED = 27 115 EMIGRATION = 28 116 FIRST_COMMUN = 29 117 IMMIGRATION = 30 118 GRADUATION = 31 119 MED_INFO = 32 120 MILITARY_SERV = 33 121 NATURALIZATION = 34 122 NOB_TITLE = 35 123 NUM_MARRIAGES = 36 124 OCCUPATION = 37 125 ORDINATION = 38 126 PROBATE = 39 127 PROPERTY = 40 128 RELIGION = 41 129 RESIDENCE = 42 130 RETIREMENT = 43 131 WILL = 44 132 133 # _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh 134 def _T_(value): # enable deferred translations (see Python docs 22.1.3.4) 135 return value 136 137 _MENU = [[_T_('Life Events'), 138 [BIRTH, BAPTISM, DEATH, BURIAL, CREMATION, ADOPT]], 139 [_T_('Family'), 140 [ENGAGEMENT, MARRIAGE, DIVORCE, ANNULMENT, MARR_SETTL, MARR_LIC, 141 MARR_CONTR, MARR_BANNS, DIV_FILING, MARR_ALT]], 142 [_T_('Religious'), 143 [CHRISTEN, ADULT_CHRISTEN, CONFIRMATION, FIRST_COMMUN, BLESS, 144 BAR_MITZVAH, BAS_MITZVAH, RELIGION]], 145 [_T_('Vocational'), 146 [OCCUPATION, RETIREMENT, ELECTED, MILITARY_SERV, ORDINATION]], 147 [_T_('Academic'), 148 [EDUCATION, DEGREE, GRADUATION]], 149 [_T_('Travel'), 150 [EMIGRATION, IMMIGRATION, NATURALIZATION]], 151 [_T_('Legal'), 152 [PROBATE, WILL]], 153 [_T_('Residence'), 154 [RESIDENCE, CENSUS, PROPERTY]], 155 [_T_('Other'), 156 [CAUSE_DEATH, MED_INFO, NOB_TITLE, NUM_MARRIAGES]]] 157 158 _CUSTOM = CUSTOM 159 _DEFAULT = BIRTH 160 161 _DATAMAP = [ 162 (UNKNOWN, _("Unknown"), "Unknown"), 163 (CUSTOM, _("Custom"), "Custom"), 164 (ADOPT, _("Adopted"), "Adopted"), 165 (BIRTH, _("Birth"), "Birth"), 166 (DEATH, _("Death"), "Death"), 167 (ADULT_CHRISTEN, _("Adult Christening"), "Adult Christening"), 168 (BAPTISM, _("Baptism"), "Baptism"), 169 (BAR_MITZVAH, _("Bar Mitzvah"), "Bar Mitzvah"), 170 (BAS_MITZVAH, _("Bat Mitzvah"), "Bas Mitzvah"), 171 (BLESS, _("Blessing"), "Blessing"), 172 (BURIAL, _("Burial"), "Burial"), 173 (CAUSE_DEATH, _("Cause Of Death"), "Cause Of Death"), 174 (CENSUS, _("Census"), "Census"), 175 (CHRISTEN, _("Christening"), "Christening"), 176 (CONFIRMATION, _("Confirmation"), "Confirmation"), 177 (CREMATION, _("Cremation"), "Cremation"), 178 (DEGREE, _("Degree"), "Degree"), 179 (EDUCATION, _("Education"), "Education"), 180 (ELECTED, _("Elected"), "Elected"), 181 (EMIGRATION, _("Emigration"), "Emigration"), 182 (FIRST_COMMUN, _("First Communion"), "First Communion"), 183 (IMMIGRATION, _("Immigration"), "Immigration"), 184 (GRADUATION, _("Graduation"), "Graduation"), 185 (MED_INFO, _("Medical Information"), "Medical Information"), 186 (MILITARY_SERV, _("Military Service"), "Military Service"), 187 (NATURALIZATION, _("Naturalization"), "Naturalization"), 188 (NOB_TITLE, _("Nobility Title"), "Nobility Title"), 189 (NUM_MARRIAGES, _("Number of Marriages"), "Number of Marriages"), 190 (OCCUPATION, _("Occupation"), "Occupation"), 191 (ORDINATION, _("Ordination"), "Ordination"), 192 (PROBATE, _("Probate"), "Probate"), 193 (PROPERTY, _("Property"), "Property"), 194 (RELIGION, _("Religion"), "Religion"), 195 (RESIDENCE, _("Residence"), "Residence"), 196 (RETIREMENT, _("Retirement"), "Retirement"), 197 (WILL, _("Will"), "Will"), 198 (MARRIAGE, _("Marriage"), "Marriage"), 199 (MARR_SETTL, _("Marriage Settlement"), "Marriage Settlement"), 200 (MARR_LIC, _("Marriage License"), "Marriage License"), 201 (MARR_CONTR, _("Marriage Contract"), "Marriage Contract"), 202 (MARR_BANNS, _("Marriage Banns"), "Marriage Banns"), 203 (ENGAGEMENT, _("Engagement"), "Engagement"), 204 (DIVORCE, _("Divorce"), "Divorce"), 205 (DIV_FILING, _("Divorce Filing"), "Divorce Filing"), 206 (ANNULMENT, _("Annulment"), "Annulment"), 207 (MARR_ALT, _("Alternate Marriage"), "Alternate Marriage"), 208 ] 209 210 _ABBREVIATIONS = { 211 BIRTH: _T_("birth abbreviation|b."), 212 DEATH: _T_("death abbreviation|d."), 213 MARRIAGE: _T_("marriage abbreviation|m."), 214 UNKNOWN: _T_("Unknown abbreviation|unkn."), 215 CUSTOM: _T_("Custom abbreviation|cust."), 216 ADOPT: _T_("Adopted abbreviation|adop."), 217 ADULT_CHRISTEN : _T_("Adult Christening abbreviation|a.chr."), 218 BAPTISM: _T_("Baptism abbreviation|bap."), 219 BAR_MITZVAH : _T_("Bar Mitzvah abbreviation|bar."), 220 BAS_MITZVAH : _T_("Bat Mitzvah abbreviation|bat."), 221 BLESS: _T_("Blessing abbreviation|bles."), 222 BURIAL: _T_("Burial abbreviation|bur."), 223 CAUSE_DEATH : _T_("Cause Of Death abbreviation|d.cau."), 224 CENSUS: _T_("Census abbreviation|cens."), 225 CHRISTEN: _T_("Christening abbreviation|chr."), 226 CONFIRMATION: _T_("Confirmation abbreviation|conf."), 227 CREMATION: _T_("Cremation abbreviation|crem."), 228 DEGREE: _T_("Degree abbreviation|deg."), 229 EDUCATION: _T_("Education abbreviation|edu."), 230 ELECTED: _T_("Elected abbreviation|elec."), 231 EMIGRATION: _T_("Emigration abbreviation|em."), 232 FIRST_COMMUN: _T_("First Communion abbreviation|f.comm."), 233 IMMIGRATION: _T_("Immigration abbreviation|im."), 234 GRADUATION: _T_("Graduation abbreviation|grad."), 235 MED_INFO: _T_("Medical Information abbreviation|medinf."), 236 MILITARY_SERV: _T_("Military Service abbreviation|milser."), 237 NATURALIZATION: _T_("Naturalization abbreviation|nat."), 238 NOB_TITLE: _T_("Nobility Title abbreviation|nob."), 239 NUM_MARRIAGES: _T_("Number of Marriages abbreviation|n.o.mar."), 240 OCCUPATION: _T_("Occupation abbreviation|occ."), 241 ORDINATION: _T_("Ordination abbreviation|ord."), 242 PROBATE: _T_("Probate abbreviation|prob."), 243 PROPERTY: _T_("Property abbreviation|prop."), 244 RELIGION: _T_("Religion abbreviation|rel."), 245 RESIDENCE: _T_("Residence abbreviation|res."), 246 RETIREMENT: _T_("Retirement abbreviation|ret."), 247 WILL: _T_("Will abbreviation|will."), 248 MARR_SETTL: _T_("Marriage Settlement abbreviation|m.set."), 249 MARR_LIC: _T_("Marriage License abbreviation|m.lic."), 250 MARR_CONTR: _T_("Marriage Contract abbreviation|m.con."), 251 MARR_BANNS: _T_("Marriage Banns abbreviation|m.ban."), 252 MARR_ALT: _T_("Alternate Marriage abbreviation|alt.mar."), 253 ENGAGEMENT: _T_("Engagement abbreviation|engd."), 254 DIVORCE: _T_("Divorce abbreviation|div."), 255 DIV_FILING: _T_("Divorce Filing abbreviation|div.f."), 256 ANNULMENT: _T_("Annulment abbreviation|annul.") 257 } 258 259 def __init__(self, value=None): 260 GrampsType.__init__(self, value) 261 262 def is_birth(self): 263 """ 264 Returns True if EventType is BIRTH, False 265 otherwise. 266 """ 267 return self.value == self.BIRTH 268 269 def is_baptism(self): 270 """ 271 Returns True if EventType is BAPTISM, False 272 otherwise. 273 """ 274 return self.value == self.BAPTISM 275 276 def is_death(self): 277 """ 278 Returns True if EventType is DEATH, False 279 otherwise. 280 """ 281 return self.value == self.DEATH 282 283 def is_burial(self): 284 """ 285 Returns True if EventType is BURIAL, False 286 otherwise. 287 """ 288 return self.value == self.BURIAL 289 290 def is_birth_fallback(self): 291 """ 292 Returns True if EventType is a birth fallback, False 293 otherwise. 294 """ 295 return self.value in [self.CHRISTEN, 296 self.BAPTISM] 297 298 def is_death_fallback(self): 299 """ 300 Returns True if EventType is a death fallback, False 301 otherwise. 302 """ 303 return self.value in [self.BURIAL, 304 self.CREMATION, 305 self.CAUSE_DEATH] 306 def is_marriage(self): 307 """ 308 Returns True if EventType is MARRIAGE, False otherwise. 309 """ 310 return self.value == self.MARRIAGE 311 312 def is_marriage_fallback(self): 313 """ 314 Returns True if EventType is a marriage fallback, False 315 otherwise. 316 """ 317 return self.value in [self.ENGAGEMENT, 318 self.MARR_ALT] 319 320 def is_divorce(self): 321 """ 322 Returns True if EventType is DIVORCE, False otherwise. 323 """ 324 return self.value == self.DIVORCE 325 326 def is_divorce_fallback(self): 327 """ 328 Returns True if EventType is a divorce fallback, False 329 otherwise. 330 """ 331 return self.value in [self.ANNULMENT, 332 self.DIV_FILING] 333 334 def is_relationship_event(self): 335 """ 336 Returns True is EventType is a relationship type event. 337 """ 338 return self.value in [self.DIVORCE, self.MARRIAGE, self.ANNULMENT] 339 340 def is_type(self, event_name): 341 """ 342 Returns True if EventType has name EVENT_NAME, False otherwise. 343 """ 344 event_type = [tup for tup in self._DATAMAP if tup[2] == event_name] 345 if len(event_type) > 0: 346 return self.value == event_type[0][0] # first one, the code 347 return False 348 349 def get_abbreviation(self, trans_text=glocale.translation.sgettext): 350 """ 351 Returns the abbreviation for this event. Uses the explicitly 352 given abbreviations, or first letter of each word, or the first 353 three letters. Appends a period after the abbreviation, 354 but not if string is in _ABBREVIATIONS. 355 356 If trans_text is passed in (a GrampsLocale sgettext instance) 357 then the translated abbreviation will be returned instead. 358 """ 359 if self.value in self._ABBREVIATIONS: 360 return trans_text(self._ABBREVIATIONS[self.value]) 361 else: 362 abbrev = str(self) 363 if " " in abbrev: 364 return ".".join([letter[0].lower() 365 for letter in abbrev.split()]) + "." 366 else: 367 return abbrev[:3].lower() + "." 368