* src/Utils.py: move event/attr constants to GedcomInfo.

* src/plugins/TestcaseGenerator.py: Use new methods.
	* src/DisplayTabs/_LdsModel.py: Use new methods.
	* src/Editors/_EditLdsOrd.py: Use new methods.
	* src/RelLib/_LdsOrd.py: Add new methods.
	* src/GrampsDb/_WriteGedcom.py: Do not import unused module.
	* src/GrampsDb/_ReadXML.py: Use methods from LdsOrd.
	* src/lds.py: Rename to LdsUtils.py
	* src/GrampsDb/_ReadGedcom.py: Use new module name.
	* src/Makefile.am (gdir_PYTHON): Ship new file.



svn: r6770
This commit is contained in:
Alex Roitman 2006-05-24 05:28:33 +00:00
parent 4cb9bb81b2
commit 54e3f6908d
13 changed files with 335 additions and 248 deletions

View File

@ -5,6 +5,17 @@
* data/gramps.schemas.in: make shading optional
2006-05-23 Alex Roitman <shura@gramps-project.org>
* src/Utils.py: move event/attr constants to GedcomInfo.
* src/plugins/TestcaseGenerator.py: Use new methods.
* src/DisplayTabs/_LdsModel.py: Use new methods.
* src/Editors/_EditLdsOrd.py: Use new methods.
* src/RelLib/_LdsOrd.py: Add new methods.
* src/GrampsDb/_WriteGedcom.py: Do not import unused module.
* src/GrampsDb/_ReadXML.py: Use methods from LdsOrd.
* src/lds.py: Rename to LdsUtils.py
* src/GrampsDb/_ReadGedcom.py: Use new module name.
* src/Makefile.am (gdir_PYTHON): Ship new file.
* src/GrampsDb/_GrampsBSDDB.py (gramps_upgrade_9): Upgrade LdsOrd.
2006-05-23 Martin Hawlisch <Martin.Hawlisch@gmx.de>

View File

@ -46,15 +46,16 @@ class LdsModel(gtk.ListStore):
def __init__(self, lds_list, db):
gtk.ListStore.__init__(self, str, str, str, str, str, object)
import lds
import LdsUtils
self.db = db
for lds_ord in lds_list:
self.append(row=[
lds.ord_type[lds_ord.get_type()],
lds_ord.type2str(),
DateHandler.get_date(lds_ord),
lds.ord_status[lds_ord.get_status()],
lds.temple_to_abrev.get(lds_ord.get_temple(), _("unknown")),
lds_ord.status2str(),
LdsUtils.temple_to_abrev.get(lds_ord.get_temple(),
_("unknown")),
self.column_place(lds_ord),
lds_ord,
])

View File

@ -51,13 +51,64 @@ import const
import RelLib
import GrampsDisplay
import NameDisplay
import lds
import LdsUtils
from _EditSecondary import EditSecondary
from DisplayTabs import SourceEmbedList,NoteTab
from GrampsWidgets import *
_DATA_MAP = {
RelLib.LdsOrd.BAPTISM : [
RelLib.LdsOrd.STATUS_NONE,
RelLib.LdsOrd.STATUS_CHILD,
RelLib.LdsOrd.STATUS_CLEARED,
RelLib.LdsOrd.STATUS_COMPLETED,
RelLib.LdsOrd.STATUS_INFANT,
RelLib.LdsOrd.STATUS_PRE_1970,
RelLib.LdsOrd.STATUS_QUALIFIED,
RelLib.LdsOrd.STATUS_STILLBORN,
RelLib.LdsOrd.STATUS_SUBMITTED,
RelLib.LdsOrd.STATUS_UNCLEARED,
],
RelLib.LdsOrd.ENDOWMENT: [
RelLib.LdsOrd.STATUS_NONE,
RelLib.LdsOrd.STATUS_CHILD,
RelLib.LdsOrd.STATUS_CLEARED,
RelLib.LdsOrd.STATUS_COMPLETED,
RelLib.LdsOrd.STATUS_INFANT,
RelLib.LdsOrd.STATUS_PRE_1970,
RelLib.LdsOrd.STATUS_QUALIFIED,
RelLib.LdsOrd.STATUS_STILLBORN,
RelLib.LdsOrd.STATUS_SUBMITTED,
RelLib.LdsOrd.STATUS_UNCLEARED,
],
RelLib.LdsOrd.SEAL_TO_PARENTS:[
RelLib.LdsOrd.STATUS_NONE,
RelLib.LdsOrd.STATUS_BIC,
RelLib.LdsOrd.STATUS_CLEARED,
RelLib.LdsOrd.STATUS_COMPLETED,
RelLib.LdsOrd.STATUS_DNS,
RelLib.LdsOrd.STATUS_PRE_1970,
RelLib.LdsOrd.STATUS_QUALIFIED,
RelLib.LdsOrd.STATUS_STILLBORN,
RelLib.LdsOrd.STATUS_SUBMITTED,
RelLib.LdsOrd.STATUS_UNCLEARED,
],
RelLib.LdsOrd.SEAL_TO_SPOUSE :[
RelLib.LdsOrd.STATUS_NONE,
RelLib.LdsOrd.STATUS_CANCELED,
RelLib.LdsOrd.STATUS_CLEARED,
RelLib.LdsOrd.STATUS_COMPLETED,
RelLib.LdsOrd.STATUS_DNS,
RelLib.LdsOrd.STATUS_PRE_1970,
RelLib.LdsOrd.STATUS_QUALIFIED,
RelLib.LdsOrd.STATUS_DNS_CAN,
RelLib.LdsOrd.STATUS_SUBMITTED,
RelLib.LdsOrd.STATUS_UNCLEARED,
],
}
#-------------------------------------------------------------------------
#
# EditLdsOrd class
@ -68,44 +119,6 @@ class EditLdsOrd(EditSecondary):
Displays a dialog that allows the user to edit an attribute.
"""
_data_map = {
RelLib.LdsOrd.BAPTISM : [
(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("Child"), RelLib.LdsOrd.STATUS_CHILD),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("Infant"), RelLib.LdsOrd.STATUS_INFANT),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
(_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
],
RelLib.LdsOrd.ENDOWMENT: [
(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("Child"), RelLib.LdsOrd.STATUS_CHILD),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("Infant"), RelLib.LdsOrd.STATUS_INFANT),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
(_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
],
RelLib.LdsOrd.SEAL_TO_PARENTS:[
(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("BIC"), RelLib.LdsOrd.STATUS_BIC),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("DNS"), RelLib.LdsOrd.STATUS_DNS),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
(_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
],
}
def __init__(self, state, uistate, track, attrib, callback):
"""
@ -132,6 +145,11 @@ class EditLdsOrd(EditSecondary):
self.define_help_button(self.top.get_widget('help'),'adv-at')
self.define_ok_button(self.top.get_widget('ok'),self.save)
def _get_types(self):
return (RelLib.LdsOrd.BAPTISM,
RelLib.LdsOrd.ENDOWMENT,
RelLib.LdsOrd.SEAL_TO_PARENTS)
def _setup_fields(self):
self.parents_label = self.top.get_widget('parents_label')
@ -164,14 +182,13 @@ class EditLdsOrd(EditSecondary):
self.top.get_widget('type'),
self.obj.set_type,
self.obj.get_type,
[(_('Baptism'),RelLib.LdsOrd.BAPTISM),
(_('Endowment'),RelLib.LdsOrd.ENDOWMENT),
(_('Sealed to Parents'),RelLib.LdsOrd.SEAL_TO_PARENTS)],
[(item[1],item[0]) for item in RelLib.LdsOrd._TYPE_MAP
if item[0] in self._get_types()],
self.db.readonly,
changed=self.ord_type_changed)
temple_list = []
for val in lds.temples:
for val in LdsUtils.temples:
temple_list.append((val[1],val[0]))
self.temple_menu = MonitoredStrMenu(
@ -185,7 +202,8 @@ class EditLdsOrd(EditSecondary):
self.top.get_widget('status'),
self.obj.set_status,
self.obj.get_status,
self._data_map[self.obj.get_type()],
[(item[1],item[0]) for item in RelLib.LdsOrd._STATUS_MAP
if item[0] in _DATA_MAP[self.obj.get_type()] ],
self.db.readonly)
self.ord_type_changed()
@ -204,7 +222,9 @@ class EditLdsOrd(EditSecondary):
self.parents.show()
self.parents_label.show()
self.parents_select.show()
self.status_menu.change_menu(self._data_map[self.obj.get_type()])
new_data = [(item[1],item[0]) for item in RelLib.LdsOrd._STATUS_MAP
if item[0] in _DATA_MAP[self.obj.get_type()] ]
self.status_menu.change_menu(new_data)
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
@ -235,8 +255,10 @@ class EditLdsOrd(EditSecondary):
handle = self.obj.get_family_handle()
if handle:
family = self.dbstate.db.get_family_from_handle(handle)
f = self.dbstate.db.get_person_from_handle(family.get_father_handle())
m = self.dbstate.db.get_person_from_handle(family.get_mother_handle())
f = self.dbstate.db.get_person_from_handle(
family.get_father_handle())
m = self.dbstate.db.get_person_from_handle(
family.get_mother_handle())
if f and m:
label = _("%(father)s and %(mother)s [%(gramps_id)s]") % {
'father' : NameDisplay.displayer.display(f),
@ -309,6 +331,9 @@ class EditFamilyLdsOrd(EditSecondary):
self.define_help_button(self.top.get_widget('help'),'adv-at')
self.define_ok_button(self.top.get_widget('ok'),self.save)
def _get_types(self):
return (RelLib.LdsOrd.SEAL_TO_SPOUSE,)
def _setup_fields(self):
self.parents_label = self.top.get_widget('parents_label')
@ -341,11 +366,12 @@ class EditFamilyLdsOrd(EditSecondary):
self.top.get_widget('type'),
self.obj.set_type,
self.obj.get_type,
[(_('Sealed to Spouse'),RelLib.LdsOrd.SEAL_TO_SPOUSE)],
[(item[1],item[0]) for item in RelLib.LdsOrd._TYPE_MAP
if item[0] in self._get_types()],
self.db.readonly)
temple_list = []
for val in lds.temples:
for val in LdsUtils.temples:
temple_list.append((val[1],val[0]))
self.temple_menu = MonitoredStrMenu(
@ -359,16 +385,8 @@ class EditFamilyLdsOrd(EditSecondary):
self.top.get_widget('status'),
self.obj.set_status,
self.obj.get_status,
[(_('<No Status>'), RelLib.LdsOrd.STATUS_NONE),
(_('Canceled'), RelLib.LdsOrd.STATUS_CANCELED),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("DNS"), RelLib.LdsOrd.STATUS_DNS),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
(_("DNS/CAN"), RelLib.LdsOrd.STATUS_DNS_CAN),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),],
[(item[1],item[0]) for item in RelLib.LdsOrd._STATUS_MAP
if item[0] in _DATA_MAP[self.obj.get_type()]],
self.db.readonly)
def _create_tabbed_pages(self):

View File

@ -21,6 +21,7 @@
# $Id$
import const
import RelLib
ADOPT_NONE = 0
ADOPT_EVENT = 1
@ -47,6 +48,95 @@ RESIDENCE_PLAC = 1
SOURCE_REFS_NO = 0
SOURCE_REFS_YES = 1
#-------------------------------------------------------------------------
#
# Integer to GEDCOM tag mappings for constants
#
#-------------------------------------------------------------------------
familyConstantEvents = {
RelLib.EventType.ANNULMENT : "ANUL",
RelLib.EventType.DIV_FILING : "DIVF",
RelLib.EventType.DIVORCE : "DIV",
RelLib.EventType.ENGAGEMENT : "ENGA",
RelLib.EventType.MARR_BANNS : "MARB",
RelLib.EventType.MARR_CONTR : "MARC",
RelLib.EventType.MARR_LIC : "MARL",
RelLib.EventType.MARR_SETTL : "MARS",
RelLib.EventType.MARRIAGE : "MARR"
}
personalConstantEvents = {
RelLib.EventType.ADOPT : "ADOP",
RelLib.EventType.ADULT_CHRISTEN : "CHRA",
RelLib.EventType.BIRTH : "BIRT",
RelLib.EventType.DEATH : "DEAT",
RelLib.EventType.BAPTISM : "BAPM",
RelLib.EventType.BAR_MITZVAH : "BARM",
RelLib.EventType.BAS_MITZVAH : "BASM",
RelLib.EventType.BLESS : "BLES",
RelLib.EventType.BURIAL : "BURI",
RelLib.EventType.CAUSE_DEATH : "CAUS",
RelLib.EventType.ORDINATION : "ORDI",
RelLib.EventType.CENSUS : "CENS",
RelLib.EventType.CHRISTEN : "CHR" ,
RelLib.EventType.CONFIRMATION : "CONF",
RelLib.EventType.CREMATION : "CREM",
RelLib.EventType.DEGREE : "_DEG",
RelLib.EventType.DIV_FILING : "DIVF",
RelLib.EventType.EDUCATION : "EDUC",
RelLib.EventType.ELECTED : "",
RelLib.EventType.EMIGRATION : "EMIG",
RelLib.EventType.FIRST_COMMUN : "FCOM",
RelLib.EventType.GRADUATION : "GRAD",
RelLib.EventType.MED_INFO : "_MDCL",
RelLib.EventType.MILITARY_SERV : "_MILT",
RelLib.EventType.NATURALIZATION : "NATU",
RelLib.EventType.NOB_TITLE : "TITL",
RelLib.EventType.NUM_MARRIAGES : "NMR",
RelLib.EventType.IMMIGRATION : "IMMI",
RelLib.EventType.OCCUPATION : "OCCU",
RelLib.EventType.PROBATE : "PROB",
RelLib.EventType.PROPERTY : "PROP",
RelLib.EventType.RELIGION : "RELI",
RelLib.EventType.RESIDENCE : "RESI",
RelLib.EventType.RETIREMENT : "RETI",
RelLib.EventType.WILL : "WILL",
}
familyConstantAttributes = {
RelLib.AttributeType.NUM_CHILD : "NCHI",
}
personalConstantAttributes = {
RelLib.AttributeType.CASTE : "CAST",
RelLib.AttributeType.DESCRIPTION : "DSCR",
RelLib.AttributeType.ID : "IDNO",
RelLib.AttributeType.NATIONAL : "NATI",
RelLib.AttributeType.NUM_CHILD : "NCHI",
RelLib.AttributeType.SSN : "SSN",
}
#-------------------------------------------------------------------------
#
# Gedcom to int constants
#
#-------------------------------------------------------------------------
lds_status = {
"BIC" : RelLib.LdsOrd.STATUS_BIC,
"CANCELED" : RelLib.LdsOrd.STATUS_CANCELED,
"CHILD" : RelLib.LdsOrd.STATUS_CHILD,
"CLEARED" : RelLib.LdsOrd.STATUS_CLEARED,
"COMPLETED": RelLib.LdsOrd.STATUS_COMPLETED,
"DNS" : RelLib.LdsOrd.STATUS_DNS,
"INFANT" : RelLib.LdsOrd.STATUS_INFANT,
"PRE-1970" : RelLib.LdsOrd.STATUS_PRE_1970,
"QUALIFIED": RelLib.LdsOrd.STATUS_QUALIFIED,
"DNS/CAN" : RelLib.LdsOrd.STATUS_DNS_CAN,
"STILLBORN": RelLib.LdsOrd.STATUS_STILLBORN,
"SUBMITTED": RelLib.LdsOrd.STATUS_SUBMITTED,
"UNCLEARED": RelLib.LdsOrd.STATUS_UNCLEARED,
}
#-------------------------------------------------------------------------
#
# XML parser

View File

@ -30,10 +30,8 @@
import os
import re
import string
import const
import lds
import time
from bsddb import db
from gettext import gettext as _
# and module sets for earlier pythons
@ -63,15 +61,16 @@ import gtk.glade
# GRAMPS modules
#
#-------------------------------------------------------------------------
import const
import Errors
import RelLib
from DateHandler._DateParser import DateParser
import NameDisplay
import Utils
import Mime
import LdsUtils
from ansel_utf8 import ansel_to_utf8
from bsddb import db
from _GedcomInfo import *
from _GedTokens import *
from QuestionDialog import ErrorDialog, WarningDialog
@ -145,23 +144,6 @@ pedi_type = {
'foster' : _TYPE_FOSTER,
}
lds_status = {
"BIC" : RelLib.LdsOrd.STATUS_BIC,
"CANCELED" : RelLib.LdsOrd.STATUS_CANCELED,
"CHILD" : RelLib.LdsOrd.STATUS_CHILD,
"CLEARED" : RelLib.LdsOrd.STATUS_CLEARED,
"COMPLETED": RelLib.LdsOrd.STATUS_COMPLETED,
"DNS" : RelLib.LdsOrd.STATUS_DNS,
"INFANT" : RelLib.LdsOrd.STATUS_INFANT,
"PRE-1970" : RelLib.LdsOrd.STATUS_PRE_1970,
"QUALIFIED": RelLib.LdsOrd.STATUS_QUALIFIED,
"DNS/CAN" : RelLib.LdsOrd.STATUS_DNS_CAN,
"STILLBORN": RelLib.LdsOrd.STATUS_STILLBORN,
"SUBMITTED": RelLib.LdsOrd.STATUS_SUBMITTED,
"UNCLEARED": RelLib.LdsOrd.STATUS_UNCLEARED,
}
_event_family_str = _("%(event_name)s of %(family)s")
_event_person_str = _("%(event_name)s of %(person)s")
@ -175,14 +157,14 @@ _transtable2 = _transtable[0:128] + ('?' * 128)
#
#-------------------------------------------------------------------------
ged2gramps = {}
for _val in Utils.personalConstantEvents.keys():
_key = Utils.personalConstantEvents[_val]
for _val in personalConstantEvents.keys():
_key = personalConstantEvents[_val]
if _key != "":
ged2gramps[_key] = _val
ged2fam = {}
for _val in Utils.familyConstantEvents.keys():
_key = Utils.familyConstantEvents[_val]
for _val in familyConstantEvents.keys():
_key = familyConstantEvents[_val]
if _key != "":
ged2fam[_key] = _val
@ -612,7 +594,7 @@ class GedcomParser(UpdateCallback):
self.geddir = os.path.dirname(os.path.normpath(os.path.abspath(filename)))
self.error_count = 0
amap = Utils.personalConstantAttributes
amap = personalConstantAttributes
self.attrs = amap.values()
self.gedattr = {}
@ -1450,11 +1432,13 @@ class GedcomParser(UpdateCallback):
except NameError:
pass
elif matches[1] == TOKEN_SOUR:
lds_ord.add_source_reference(self.handle_source(matches,level+1))
lds_ord.add_source_reference(
self.handle_source(matches,level+1))
elif matches[1] == TOKEN_NOTE:
note = self.parse_note(matches,lds_ord,level+1,note)
elif matches[1] == TOKEN_STAT:
lds_ord.set_status(lds_status.get(matches[2],RelLib.LdsOrd.STATUS_NONE))
lds_ord.set_status(
lds_status.get(matches[2],RelLib.LdsOrd.STATUS_NONE))
else:
self.barf(level+1)
@ -2446,10 +2430,10 @@ class GedcomParser(UpdateCallback):
def extract_temple(self, matches):
def get_code(code):
if lds.temple_to_abrev.has_key(code):
if LdsUtils.temple_to_abrev.has_key(code):
return code
elif lds.temple_codes.has_key(code):
return lds.temple_codes[code]
elif LdsUtils.temple_codes.has_key(code):
return LdsUtils.temple_codes[code]
c = get_code(matches[2])
if c: return c

View File

@ -636,20 +636,12 @@ class GrampsParser(UpdateCallback):
self.db.request_rebuild()
def start_lds_ord(self,attrs):
atype = attrs['type']
self.ord = RelLib.LdsOrd()
self.ord.set_type_from_xml(attrs['type'])
if self.person:
if atype == "baptism":
self.ord.set_type(RelLib.LdsOrd.BAPTISM)
elif atype == "endowment":
self.ord.set_type(RelLib.LdsOrd.ENDOWMENT)
elif atype == "sealed_to_parents":
self.ord.set_type(RelLib.LdsOrd.SEAL_TO_PARENTS)
self.person.lds_ord_list.append(self.ord)
elif self.family:
if atype == "sealed_to_spouse":
self.ord.set_type(RelLib.LdsOrd.SEAL_TO_SPOUSE)
self.family.lds_ord_list.append(self.ord)
self.family.lds_ord_list.append(self.ord)
def start_temple(self,attrs):
self.ord.set_temple(attrs['val'])
@ -658,7 +650,12 @@ class GrampsParser(UpdateCallback):
self.source.set_data_item(attrs['key'],attrs['value'])
def start_status(self,attrs):
self.ord.set_status(int(attrs['val']))
try:
# old xml with integer statuses
self.ord.set_status(int(attrs['val']))
except ValueError:
# string
self.ord.set_status_from_xml(attrs['val'])
def start_sealed_to(self,attrs):
try:

View File

@ -55,7 +55,6 @@ import gtk.glade
import RelLib
from Filters import GenericFilter, Rules, build_filter_menu
import const
import lds
import _GedcomInfo as GedcomInfo
import Errors
import ansel_utf8
@ -631,8 +630,8 @@ class GedcomWriter(UpdateCallback):
mother_alive = Utils.probably_alive(person,self.db)
if not self.restrict or ( not father_alive and not mother_alive ):
for lds in family.get_lds_ord_list():
self.write_ord(lds,1)
for lds_ord in family.get_lds_ord_list():
self.write_ord(lds_ord,1)
for event_ref in family.get_event_ref_list():
event_handle = event_ref.ref

View File

@ -79,13 +79,6 @@ except:
_xml_version = "1.1.0"
lds_map = {
RelLib.LdsOrd.BAPTISM : 'baptism',
RelLib.LdsOrd.ENDOWMENT : 'endowment',
RelLib.LdsOrd.SEAL_TO_PARENTS : 'sealed_to_parents',
RelLib.LdsOrd.SEAL_TO_SPOUSE : 'sealed_to_spouse',
}
#-------------------------------------------------------------------------
#
#
@ -599,22 +592,23 @@ class XmlWriter(UpdateCallback):
def dump_ordinance(self,ord,index=1):
name = lds_map[ord.get_type()]
name = ord.type2xml()
sp = " " * index
sp2 = " " * (index+1)
self.g.write('%s<lds_ord type="%s">\n' % (sp,self.fix(name)))
self.g.write('%s<lds_ord type="%s">\n' % (sp,name))
dateobj = ord.get_date_object()
if dateobj and not dateobj.is_empty():
self.write_date(dateobj,index+1)
if ord.get_temple():
self.g.write('%s<temple val="%s"/>\n' % (sp2,self.fix(ord.get_temple())))
self.g.write('%s<temple val="%s"/>\n'
% (sp2,self.fix(ord.get_temple())))
self.write_ref("place",ord.get_place_handle(),index+1)
if ord.get_status() != 0:
self.g.write('%s<status val="%d"/>\n' % (sp2,ord.get_status()))
self.g.write('%s<status val="%s"/>\n' % (sp2,ord.status2xml()))
if ord.get_family_handle():
self.g.write('%s<sealed_to hlink="%s"/>\n' %
(sp2,"_"+self.fix(ord.get_family_handle())))
(sp2,"_"+ord.get_family_handle()))
if ord.get_note() != "":
self.write_note("note",ord.get_note_object(),index+1)
for s in ord.get_source_references():

View File

@ -1,5 +1,3 @@
# -*- python -*-
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
@ -22,13 +20,6 @@
# $Id$
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#Updated LDS Temple Codes from:
#http://www.geocities.com/rgpassey/temple/abclist.htm
@ -181,27 +172,3 @@ temple_to_abrev = {}
for x in temples:
for y in x[1:]:
temple_to_abrev[y] = x[0]
ord_type = {
0 : _('Baptism'),
1 : _('Endowment'),
2 : _('Sealed to Parents'),
3 : _('Sealed to Spouse'),
}
ord_status = [
_("<No Status>"),
_("BIC"),
_("Canceled"),
_("Child"),
_("Cleared"),
_("Completed"),
_("DNS"),
_("Infant"),
_("Pre-1970"),
_("Qualified"),
_("DNS/CAN"),
_("Stillborn"),
_("Submitted"),
_("Uncleared"),
]

View File

@ -51,7 +51,7 @@ gdir_PYTHON = \
gramps.py\
GrampsWidgets.py\
ImgManip.py\
lds.py \
LdsUtils.py \
ListModel.py\
ManagedWindow.py\
MergeData.py\

View File

@ -24,6 +24,12 @@
LDS Ordinance class for GRAMPS
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
from warnings import warn
#-------------------------------------------------------------------------
@ -43,35 +49,66 @@ from _PrivacyBase import PrivacyBase
# LDS Ordinance class
#
#-------------------------------------------------------------------------
class LdsOrd(SecondaryObject,SourceBase,NoteBase,DateBase,PlaceBase,PrivacyBase):
class LdsOrd(SecondaryObject,SourceBase,NoteBase,
DateBase,PlaceBase,PrivacyBase):
"""
Class that contains information about LDS Ordinances. LDS
ordinances are similar to events, but have very specific additional
information related to data collected by the Church of Jesus Christ
of Latter Day Saints (Morman church). The LDS church is the largest
of Latter Day Saints (Mormon church). The LDS church is the largest
source of genealogical information in the United States.
"""
BAPTISM = 0
ENDOWMENT = 1
BAPTISM = 0
ENDOWMENT = 1
SEAL_TO_PARENTS = 2
SEAL_TO_SPOUSE = 3
SEAL_TO_SPOUSE = 3
DEFAULT_TYPE = BAPTISM
STATUS_NONE = 0
STATUS_BIC = 1
STATUS_CANCELED = 2
STATUS_CHILD = 3
STATUS_CLEARED = 4
STATUS_NONE = 0
STATUS_BIC = 1
STATUS_CANCELED = 2
STATUS_CHILD = 3
STATUS_CLEARED = 4
STATUS_COMPLETED = 5
STATUS_DNS = 6
STATUS_INFANT = 7
STATUS_PRE_1970 = 8
STATUS_DNS = 6
STATUS_INFANT = 7
STATUS_PRE_1970 = 8
STATUS_QUALIFIED = 9
STATUS_DNS_CAN = 10
STATUS_DNS_CAN = 10
STATUS_STILLBORN = 11
STATUS_SUBMITTED = 12
STATUS_UNCLEARED = 13
DEFAULT_STATUS = STATUS_NONE
_TYPE_MAP = [
(BAPTISM, _('Baptism'), 'baptism'),
(ENDOWMENT, _('Endowment'), 'endowment'),
(SEAL_TO_PARENTS, _('Sealed to Parents'), 'sealed_to_parents'),
(SEAL_TO_SPOUSE, _('Sealed to Spouse'), 'sealed_to_spouse' ),
]
_STATUS_MAP = [
(STATUS_NONE, _("<No Status>"), ""),
(STATUS_BIC, _("BIC"), "BIC"),
(STATUS_CANCELED, _("Canceled"), "Canceled"),
(STATUS_CHILD, _("Child"), "Child"),
(STATUS_CLEARED, _("Cleared"), "Cleared"),
(STATUS_COMPLETED, _("Completed"), "Completed"),
(STATUS_DNS, _("DNS"), "DNS"),
(STATUS_INFANT, _("Infant"), "Infant"),
(STATUS_PRE_1970, _("Pre-1970"), "Pre-1970"),
(STATUS_QUALIFIED, _("Qualified"), "Qualified"),
(STATUS_DNS_CAN, _("DNS/CAN"), "DNS/CAN"),
(STATUS_STILLBORN, _("Stillborn"), "Stillborn"),
(STATUS_SUBMITTED, _("Submitted"), "Submitted"),
(STATUS_UNCLEARED, _("Uncleared"), "Uncleared"),
]
def __init__(self,source=None):
"""Creates a LDS Ordinance instance"""
SecondaryObject.__init__(self)
@ -87,10 +124,10 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,DateBase,PlaceBase,PrivacyBase)
self.temple = source.temple
self.status = source.status
else:
self.type = self.BAPTISM
self.type = LdsOrd.DEFAULT_TYPE
self.famc = None
self.temple = ""
self.status = 0
self.status = LdsOrd.DEFAULT_STATUS
def serialize(self):
return (SourceBase.serialize(self),
@ -199,3 +236,61 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,DateBase,PlaceBase,PrivacyBase)
"""returns 1 if the specified ordinance is the same as the instance"""
warn( "Use is_equal instead are_equal", DeprecationWarning, 2)
return self.is_equal(other)
def type2xml(self):
"""
Return type-representing string suitable for XML.
"""
for item in LdsOrd._TYPE_MAP:
if item[0] == self.type:
return item[2]
return ""
def type2str(self):
"""
Return type-representing string suitable for UI (translated).
"""
for item in LdsOrd._TYPE_MAP:
if item[0] == self.type:
return item[1]
return ""
def set_type_from_xml(self,xml_str):
"""
Set type based on a given string from XML.
Return boolean of success.
"""
for item in LdsOrd._TYPE_MAP:
if item[2] == xml_str:
self.type = item[0]
return True
return False
def status2xml(self):
"""
Return status-representing string suitable for XML.
"""
for item in LdsOrd._STATUS_MAP:
if item[0] == self.status:
return item[2]
return ""
def status2str(self):
"""
Return status-representing string suitable for UI (translated).
"""
for item in LdsOrd._STATUS_MAP:
if item[0] == self.status:
return item[1]
return ""
def set_status_from_xml(self,xml_str):
"""
Set status based on a given string from XML.
Return boolean of success.
"""
for item in LdsOrd._STATUS_MAP:
if item[2] == xml_str:
self.status = item[0]
return True
return False

View File

@ -77,8 +77,6 @@ confidence = {
RelLib.SourceRef.CONF_LOW : _("Low"),
RelLib.SourceRef.CONF_VERY_LOW : _("Very Low"),
}
def format_confidence( type):
return confidence.get(type[0],_("Invalid id %d ('%s')")%type)
family_rel_descriptions = {
RelLib.FamilyRelType.MARRIED : _("A legal or common-law relationship "
@ -94,74 +92,6 @@ family_rel_descriptions = {
}
#-------------------------------------------------------------------------
#
# Integer to GEDCOM tag mappings for constants
#
#-------------------------------------------------------------------------
familyConstantEvents = {
RelLib.EventType.ANNULMENT : "ANUL",
RelLib.EventType.DIV_FILING : "DIVF",
RelLib.EventType.DIVORCE : "DIV",
RelLib.EventType.ENGAGEMENT : "ENGA",
RelLib.EventType.MARR_BANNS : "MARB",
RelLib.EventType.MARR_CONTR : "MARC",
RelLib.EventType.MARR_LIC : "MARL",
RelLib.EventType.MARR_SETTL : "MARS",
RelLib.EventType.MARRIAGE : "MARR"
}
personalConstantEvents = {
RelLib.EventType.ADOPT : "ADOP",
RelLib.EventType.ADULT_CHRISTEN : "CHRA",
RelLib.EventType.BIRTH : "BIRT",
RelLib.EventType.DEATH : "DEAT",
RelLib.EventType.BAPTISM : "BAPM",
RelLib.EventType.BAR_MITZVAH : "BARM",
RelLib.EventType.BAS_MITZVAH : "BASM",
RelLib.EventType.BLESS : "BLES",
RelLib.EventType.BURIAL : "BURI",
RelLib.EventType.CAUSE_DEATH : "CAUS",
RelLib.EventType.ORDINATION : "ORDI",
RelLib.EventType.CENSUS : "CENS",
RelLib.EventType.CHRISTEN : "CHR" ,
RelLib.EventType.CONFIRMATION : "CONF",
RelLib.EventType.CREMATION : "CREM",
RelLib.EventType.DEGREE : "_DEG",
RelLib.EventType.DIV_FILING : "DIVF",
RelLib.EventType.EDUCATION : "EDUC",
RelLib.EventType.ELECTED : "",
RelLib.EventType.EMIGRATION : "EMIG",
RelLib.EventType.FIRST_COMMUN : "FCOM",
RelLib.EventType.GRADUATION : "GRAD",
RelLib.EventType.MED_INFO : "_MDCL",
RelLib.EventType.MILITARY_SERV : "_MILT",
RelLib.EventType.NATURALIZATION : "NATU",
RelLib.EventType.NOB_TITLE : "TITL",
RelLib.EventType.NUM_MARRIAGES : "NMR",
RelLib.EventType.IMMIGRATION : "IMMI",
RelLib.EventType.OCCUPATION : "OCCU",
RelLib.EventType.PROBATE : "PROB",
RelLib.EventType.PROPERTY : "PROP",
RelLib.EventType.RELIGION : "RELI",
RelLib.EventType.RESIDENCE : "RESI",
RelLib.EventType.RETIREMENT : "RETI",
RelLib.EventType.WILL : "WILL",
}
familyConstantAttributes = {
RelLib.AttributeType.NUM_CHILD : "NCHI",
}
personalConstantAttributes = {
RelLib.AttributeType.CASTE : "CAST",
RelLib.AttributeType.DESCRIPTION : "DSCR",
RelLib.AttributeType.ID : "IDNO",
RelLib.AttributeType.NATIONAL : "NATI",
RelLib.AttributeType.NUM_CHILD : "NCHI",
RelLib.AttributeType.SSN : "SSN",
}
#-------------------------------------------------------------------------
#
# modified flag
@ -361,8 +291,9 @@ def find_file( filename):
except:
pass
# Build list of elternate encodings
encodings = [sys.getfilesystemencoding(), locale.getpreferredencoding(), 'UTF-8', 'ISO-8859-1']
# Build list of alternate encodings
encodings = [sys.getfilesystemencoding(), locale.getpreferredencoding(),
'UTF-8', 'ISO-8859-1']
encodings = list(set(encodings))
for enc in encodings:
try:

View File

@ -50,7 +50,6 @@ import Errors
import RelLib
from PluginUtils import Tool, register_tool
import const
import lds
import Utils
from QuestionDialog import ErrorDialog
from DateHandler import parser as _dp
@ -1048,7 +1047,7 @@ class TestcaseGenerator(Tool.Tool):
if isinstance(o,RelLib.LdsOrd):
if randint(0,1) == 1:
o.set_temple( choice( lds.temple_to_abrev.keys()))
o.set_temple( choice( LdsUtils.temple_to_abrev.keys()))
if issubclass(o.__class__,RelLib._LdsOrdBase.LdsOrdBase):
while randint(0,1) == 1:
@ -1057,8 +1056,9 @@ class TestcaseGenerator(Tool.Tool):
# TODO: adapt type and status to family/person
#if isinstance(o,RelLib.Person):
#if isinstance(o,RelLib.Family):
ldsord.set_type( choice( lds.ord_type.keys()))
ldsord.set_status( randint(0,len(lds.ord_status)-1))
ldsord.set_type( choice(
[item[0] for item in RelLib.LdsOrd._TYPE_MAP] ))
ldsord.set_status( randint(0,len(RelLib.LdsOrd._STATUS_MAP)-1))
if self.generated_families:
ldsord.set_family_handle( choice(self.generated_families))
o.add_lds_ord( ldsord)