* src/RelLib/Makefile.am: Ship new file.
	* src/PluginUtils/_ReportUtils.py: Use fam relations from new module.
	* src/Relationship.py: Use family relations from new module.
	* src/Utils.py: Remove family relations.
	* src/RelLib/__init__.py: Expose new module.
	* src/RelLib/_Family.py: Adapt to new types.
	* src/GrampsDb/_ReadXML.py: Adapt to new types.
	* src/GrampsDb/_ConstXML.py: Remove family relations.
	* src/RelLib/_FamilyRelType.py: Add new class
In po:
2006-04-19  Alex Roitman  <shura@gramps-project.org>
	* POTFILES.in: Add new files.



svn: r6369
This commit is contained in:
Alex Roitman 2006-04-19 18:27:51 +00:00
parent 4944e06cef
commit 90832a683e
12 changed files with 135 additions and 68 deletions

View File

@ -1,4 +1,13 @@
2006-04-19 Alex Roitman <shura@gramps-project.org>
* src/RelLib/Makefile.am: Ship new file.
* src/PluginUtils/_ReportUtils.py: Use fam relations from new module.
* src/Relationship.py: Use family relations from new module.
* src/Utils.py: Remove family relations.
* src/RelLib/__init__.py: Expose new module.
* src/RelLib/_Family.py: Adapt to new types.
* src/GrampsDb/_ReadXML.py: Adapt to new types.
* src/GrampsDb/_ConstXML.py: Remove family relations.
* src/RelLib/_FamilyRelType.py: Add new class
* src/RelLib/_Event.py: Add "personal" attribute to events.
* src/RelLib/_Event.py: Revert this change.

View File

@ -1,3 +1,6 @@
2006-04-19 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Add new files.
2006-04-06 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Add new files to the list.
* gramps.pot: regenerate the template.

View File

@ -280,6 +280,10 @@ src/RelLib/_Url.py
src/RelLib/_Witness.py
src/TreeViews/__init__.py
src/TreeViews/_PersonTreeView.py
src/RelLib/_FamilyRelType.py
src/RelLib/_UrlType.py
src/RelLib/_NameType.py
src/RelLib/_ChildRefType.py
#
# Glade files
#

View File

@ -94,12 +94,12 @@ attributes = (
(RelLib.Attribute.SSN , "Social Security Number"),
)
family_relations = (
(RelLib.Family.MARRIED , "Married"),
(RelLib.Family.UNMARRIED , "Unmarried"),
(RelLib.Family.CIVIL_UNION , "Civil Union"),
(RelLib.Family.UNKNOWN , "Unknown"),
)
## family_relations = (
## (RelLib.Family.MARRIED , "Married"),
## (RelLib.Family.UNMARRIED , "Unmarried"),
## (RelLib.Family.CIVIL_UNION , "Civil Union"),
## (RelLib.Family.UNKNOWN , "Unknown"),
## )
# name_types = (
# (RelLib.NameType.UNKNOWN , "Unknown"),
@ -168,7 +168,7 @@ marker_types = (
custom_types = {
events : RelLib.Event.CUSTOM,
attributes : RelLib.Attribute.CUSTOM,
family_relations : RelLib.Family.CUSTOM,
# family_relations : RelLib.Family.CUSTOM,
# name_types : RelLib.NameType.CUSTOM,
source_media_types : RelLib.RepoRef.CUSTOM,
event_roles : RelLib.EventRef.CUSTOM,

View File

@ -769,18 +769,21 @@ class GrampsParser:
self.eventref.private = bool(attrs.get('priv'))
self.eventref.role = _ConstXML.tuple_from_xml(_ConstXML.event_roles,
attrs.get('role',''))
# We count here on events being already parsed prior to parsing
# people or families. This code will fail if this is not true.
event = self.db.get_event_from_handle(self.eventref.ref)
if self.family:
event.personal = False
self.family.add_event_ref(self.eventref)
elif self.person:
# We count here on events being already parsed prior
# to parsing people. This will fail if this is not true.
event = self.db.get_event_from_handle(self.eventref.ref)
event.personal = True
if event.type[0] == RelLib.Event.BIRTH:
self.person.birth_ref = self.eventref
elif event.type[0] == RelLib.Event.DEATH:
self.person.death_ref = self.eventref
else:
self.person.add_event_ref(self.eventref)
def start_attribute(self,attrs):
self.attribute = RelLib.Attribute()
@ -919,8 +922,8 @@ class GrampsParser:
self.family = self.find_family_by_gramps_id(gramps_id)
# GRAMPS LEGACY: the type now belongs to <rel> tag
# Here we need to support old format of <family type="Married">
self.family.type = _ConstXML.tuple_from_xml(
_ConstXML.family_relations,attrs.get("type",'Unknown'))
self.family.type = RelLib.FamilyRelType().set_from_xml_str(
attrs.get("type",'Unknown'))
# Old and new markers: complete=1 and marker=word both have to work
if attrs.get('complete'): # this is only true for complete=1
@ -930,8 +933,8 @@ class GrampsParser:
_ConstXML.marker_types,attrs.get("marker",''))
def start_rel(self,attrs):
self.family.type = _ConstXML.tuple_from_xml(
_ConstXML.family_relations,attrs.get("type",'Unknown'))
self.family.type = RelLib.FamilyRelType().set_from_xml_str(
attrs.get("type",'Unknown'))
def start_file(self,attrs):
self.object.mime = attrs['mime']

View File

@ -815,10 +815,10 @@ child_mother = {
#
#-------------------------------------------------------------------------
_rtype = {
RelLib.Family.UNMARRIED : _("unmarried"),
RelLib.Family.CIVIL_UNION : _("civil union"),
RelLib.Family.UNKNOWN : _("Unknown"),
RelLib.Family.CUSTOM : _("Other"),
RelLib.FamilyRelType.UNMARRIED : _("unmarried"),
RelLib.FamilyRelType.CIVIL_UNION : _("civil union"),
RelLib.FamilyRelType.UNKNOWN : _("Unknown"),
RelLib.FamilyRelType.CUSTOM : _("Other"),
}
#-------------------------------------------------------------------------
@ -1680,14 +1680,14 @@ def married_rel_str(database,person,family,is_first=True):
relationship = family.get_relationship()[0]
if is_first:
if relationship == RelLib.Family.MARRIED:
if relationship == RelLib.FamilyRelType.MARRIED:
if person.get_gender() == RelLib.Person.MALE:
text = _('He married %(spouse)s.') % values
elif person.get_gender() == RelLib.Person.FEMALE:
text = _('She married %(spouse)s.') % values
else:
text = _('This person married %(spouse)s.') % values
elif relationship == RelLib.Family.UNMARRIED:
elif relationship == RelLib.FamilyRelType.UNMARRIED:
if person.get_gender() == RelLib.Person.MALE:
text = _('He had an unmarried relationship with %(spouse)s.') % values
elif person.get_gender() == RelLib.Person.FEMALE:
@ -1702,14 +1702,14 @@ def married_rel_str(database,person,family,is_first=True):
else:
text = _('This person had relationship with %(spouse)s.') % values
else:
if relationship == RelLib.Family.MARRIED:
if relationship == RelLib.FamilyRelType.MARRIED:
if person.get_gender() == RelLib.Person.MALE:
text = _('He also married %(spouse)s.') % values
elif person.get_gender() == RelLib.Person.FEMALE:
text = _('She also married %(spouse)s.') % values
else:
text = _('This person also married %(spouse)s.') % values
elif relationship == RelLib.Family.UNMARRIED:
elif relationship == RelLib.FamilyRelType.UNMARRIED:
if person.get_gender() == RelLib.Person.MALE:
text = _('He had an unmarried relationship with %(spouse)s.') % values
elif person.get_gender() == RelLib.Person.FEMALE:

View File

@ -51,7 +51,8 @@ pkgdata_PYTHON = \
_SourceBase.py\
_RefBase.py\
_ChildRef.py\
_ChildRefType.py
_ChildRefType.py\
_FamilyRelType.py
pkgpyexecdir = @pkgpyexecdir@/RelLib
pkgpythondir = @pkgpythondir@/RelLib

View File

@ -44,6 +44,7 @@ from _AttributeBase import AttributeBase
from _EventRef import EventRef
from _LdsOrdBase import LdsOrdBase
from _ChildRef import ChildRef
from _FamilyRelType import FamilyRelType
#-------------------------------------------------------------------------
#
@ -73,12 +74,6 @@ class Family(PrimaryObject,SourceBase,NoteBase,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
@ -94,7 +89,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
self.father_handle = None
self.mother_handle = None
self.child_ref_list = []
self.type = (Family.MARRIED,'')
self.type = (FamilyRelType.MARRIED,'')
self.event_ref_list = []
self.lds_seal = None
self.complete = 0
@ -287,17 +282,17 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
first item is an integer constant and whose second item is
the string. The valid values are:
- C{Family.MARRIED} : indicates a legally recognized married
- C{FamilyRelType.MARRIED} : indicates a legally recognized married
relationship between two individuals. This may be either
an opposite or a same sex relationship.
- C{Family.UNMARRIED} : indicates a relationship between two
- C{FamilyRelType.UNMARRIED} : indicates a relationship between two
individuals that is not a legally recognized relationship.
- C{Family.CIVIL_UNION} : indicates a legally recongnized,
- C{FamilyRelType.CIVIL_UNION} : indicates a legally recongnized,
non-married relationship between two individuals of the
same sex.
- C{Family.UNKNOWN} : indicates that the type of relationship
- C{FamilyRelType.UNKNOWN} : indicates that the type of relationship
between the two individuals is not know.
- C{Family.CUSTOM} : indicates that the type of relationship
- C{FamilyRelType.CUSTOM} : indicates that the type of relationship
between the two individuals does not match any of the
other types.
@ -305,15 +300,17 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
between the father and mother of the relationship.
@type relationship_type: tuple
"""
if not type(relationship_type) == tuple:
if relationship_type in [Family.MARRIED,Family.UNMARRIED,
Family.CIVIL_UNION,Family.UNKNOWN,
Family.CUSTOM]:
warn( "set_relationship now takes a tuple",
if not isinstance(relationship_type,FamilyRelType):
if relationship_type in [FamilyRelType.MARRIED,
FamilyRelType.UNMARRIED,
FamilyRelType.CIVIL_UNION,
FamilyRelType.UNKNOWN,
FamilyRelType.CUSTOM]:
warn( "set_relationship now takes a FamilyRelType instance",
DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
relationship_type = (relationship_type,'')
relationship_type = FamilyRelType(relationship_type)
else:
assert type(relationship_type) == tuple
self.type = relationship_type

View File

@ -0,0 +1,50 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $
from _GrampsType import GrampsType, init_map
from gettext import gettext as _
class FamilyRelType(GrampsType):
MARRIED = 0
UNMARRIED = 1
CIVIL_UNION = 2
UNKNOWN = 3
CUSTOM = 4
_CUSTOM = CUSTOM
_DEFAULT = MARRIED
_DATAMAP = [
(UNKNOWN, _("Unknown"), "Unknown"),
(CUSTOM, _("Custom"), "Custom"),
(CIVIL_UNION, _("Civil Union"), "Civil Union"),
(UNMARRIED, _("Unmarried"), "Unmarried"),
(MARRIED, _("Married"), "Married"),
]
_I2SMAP = init_map(_DATAMAP, 0, 1)
_S2IMAP = init_map(_DATAMAP, 1, 0)
_I2EMAP = init_map(_DATAMAP, 0, 2)
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None):
GrampsType.__init__(self, value)

View File

@ -65,4 +65,4 @@ from _UrlType import UrlType
from _ChildRefType import ChildRefType
from _RepositoryType import RepositoryType
from _EventType import EventType
from _FamilyRelType import FamilyRelType

View File

@ -260,33 +260,33 @@ class RelationshipCalculator:
gender = RelLib.Person.FEMALE
# Person's gender is unknown, try guessing from spouse's
elif orig.get_gender() == RelLib.Person.MALE:
if family_rel == RelLib.Family.CIVIL_UNION:
if family_rel == RelLib.FamilyRelType.CIVIL_UNION:
gender = RelLib.Person.MALE
else:
gender = RelLib.Person.FEMALE
elif orig.get_gender() == RelLib.Person.FEMALE:
if family_rel == RelLib.Family.CIVIL_UNION:
if family_rel == RelLib.FamilyRelType.CIVIL_UNION:
gender = RelLib.Person.FEMALE
else:
gender = RelLib.Person.MALE
else:
gender = RelLib.Person.UNKNOWN
if family_rel == RelLib.Family.MARRIED:
if family_rel == RelLib.FamilyRelType.MARRIED:
if gender == RelLib.Person.MALE:
return _("husband")
elif gender == RelLib.Person.FEMALE:
return _("wife")
else:
return _("gender unknown|spouse")
elif family_rel == RelLib.Family.UNMARRIED:
elif family_rel == RelLib.FamilyRelType.UNMARRIED:
if gender == RelLib.Person.MALE:
return _("unmarried|husband")
elif gender == RelLib.Person.FEMALE:
return _("unmarried|wife")
else:
return _("gender unknown,unmarried|spouse")
elif family_rel == RelLib.Family.CIVIL_UNION:
elif family_rel == RelLib.FamilyRelType.CIVIL_UNION:
if gender == RelLib.Person.MALE:
return _("male,civil union|partner")
elif gender == RelLib.Person.FEMALE:

View File

@ -185,29 +185,29 @@ def format_attribute( type):
val = family_attributes.get(type[0],_("Invalid id %d ('%s')")%type)
return val
family_relations = {
RelLib.Family.MARRIED : _("Married"),
RelLib.Family.UNMARRIED : _("Unmarried"),
RelLib.Family.CIVIL_UNION : _("Civil Union"),
RelLib.Family.UNKNOWN : _("Unknown"),
RelLib.Family.CUSTOM : _("Other"),
}
def format_family_relation( type):
if type[0] == RelLib.Family.CUSTOM:
return type[1]
return family_relations.get(type[0],_("Invalid id %d ('%s')")%type)
## family_relations = {
## RelLib.Family.MARRIED : _("Married"),
## RelLib.Family.UNMARRIED : _("Unmarried"),
## RelLib.Family.CIVIL_UNION : _("Civil Union"),
## RelLib.Family.UNKNOWN : _("Unknown"),
## RelLib.Family.CUSTOM : _("Other"),
## }
## def format_family_relation( type):
## if type[0] == RelLib.Family.CUSTOM:
## return type[1]
## return family_relations.get(type[0],_("Invalid id %d ('%s')")%type)
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"),
RelLib.FamilyRelType.MARRIED : _("A legal or common-law relationship "
"between a husband and wife"),
RelLib.FamilyRelType.UNMARRIED : _("No legal or common-law relationship "
"between man and woman"),
RelLib.FamilyRelType.CIVIL_UNION : _("An established relationship between "
"members of the same sex"),
RelLib.FamilyRelType.UNKNOWN : _("Unknown relationship between a man "
"and woman"),
RelLib.FamilyRelType.CUSTOM : _("An unspecified relationship "
"a man and woman"),
}
source_media_types = {