Handle ChildRefType on XML import
svn: r6344
This commit is contained in:
		@@ -1,3 +1,7 @@
 | 
			
		||||
2006-04-14  Don Allingham  <don@gramps-project.org>
 | 
			
		||||
	* src/GrampsDb/_ReadXML.py: handle ChildRefType
 | 
			
		||||
	* src/GrampsDb/_ConstXML.py: remove unused map
 | 
			
		||||
 | 
			
		||||
2006-04-14  Martin Hawlisch  <Martin.Hawlisch@gmx.de>
 | 
			
		||||
	* src/DataViews/_PedigreeView.py: Fix ChildRef, Show person references
 | 
			
		||||
	* src/Editors/_EditFamily.py: Typo
 | 
			
		||||
 
 | 
			
		||||
@@ -32,15 +32,6 @@ import RelLib
 | 
			
		||||
# Collection of standard types for various kinds of objects
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
child_relations = (
 | 
			
		||||
    (RelLib.ChildRefType.BIRTH     , "Birth"),
 | 
			
		||||
    (RelLib.ChildRefType.ADOPTED   , "Adopted"),
 | 
			
		||||
    (RelLib.ChildRefType.STEPCHILD , "Stepchild"),
 | 
			
		||||
    (RelLib.ChildRefType.SPONSORED , "Sponsored"),
 | 
			
		||||
    (RelLib.ChildRefType.FOSTER    , "Foster"),
 | 
			
		||||
    (RelLib.ChildRefType.UNKNOWN   , "Unknown"),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
events = (
 | 
			
		||||
    # Family events
 | 
			
		||||
    (RelLib.Event.UNKNOWN    , "Unknown"),
 | 
			
		||||
@@ -175,7 +166,6 @@ url_types = (
 | 
			
		||||
 | 
			
		||||
# mapping from the tuple collection to the appropriate CUSTOM integer
 | 
			
		||||
custom_types = {
 | 
			
		||||
    child_relations    : RelLib.ChildRefType.CUSTOM,
 | 
			
		||||
    events             : RelLib.Event.CUSTOM,
 | 
			
		||||
    attributes         : RelLib.Attribute.CUSTOM,
 | 
			
		||||
    family_relations   : RelLib.Family.CUSTOM,
 | 
			
		||||
 
 | 
			
		||||
@@ -77,6 +77,15 @@ except:
 | 
			
		||||
 | 
			
		||||
personRE = re.compile(r"\s*\<person\s(.*)$")
 | 
			
		||||
 | 
			
		||||
crel_map = {
 | 
			
		||||
    "Birth"     : RelLib.ChildRefType(RelLib.ChildRefType.BIRTH),
 | 
			
		||||
    "Adopted"   : RelLib.ChildRefType(RelLib.ChildRefType.ADOPTED),
 | 
			
		||||
    "Stepchild" : RelLib.ChildRefType(RelLib.ChildRefType.STEPCHILD),
 | 
			
		||||
    "Sponsored" : RelLib.ChildRefType(RelLib.ChildRefType.SPONSORED),
 | 
			
		||||
    "Foster"    : RelLib.ChildRefType(RelLib.ChildRefType.FOSTER),
 | 
			
		||||
    "Unknown"   : RelLib.ChildRefType(RelLib.ChildRefType.UNKNOWN),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Importing data into the currently open database. 
 | 
			
		||||
@@ -912,13 +921,11 @@ class GrampsParser:
 | 
			
		||||
            family = self.find_family_by_gramps_id(self.map_fid(attrs["ref"]))
 | 
			
		||||
            handle = family.handle
 | 
			
		||||
 | 
			
		||||
        mrel = _ConstXML.tuple_from_xml(_ConstXML.child_relations,
 | 
			
		||||
                                        attrs.get('mrel','Birth'))
 | 
			
		||||
        frel = _ConstXML.tuple_from_xml(_ConstXML.child_relations,
 | 
			
		||||
                                        attrs.get('frel','Birth'))
 | 
			
		||||
        mrel = crel_map.get(attrs.get('mrel'),RelLib.ChildRefType())
 | 
			
		||||
        frel = crel_map.get(attrs.get('frel'),RelLib.ChildRefType())
 | 
			
		||||
 | 
			
		||||
        if mrel != RelLib.ChildRefType.CHILD_BIRTH or \
 | 
			
		||||
               frel != RelLib.ChildRefType.CHILD_BIRTH:
 | 
			
		||||
        if mrel != RelLib.ChildRefType.BIRTH or \
 | 
			
		||||
               frel != RelLib.ChildRefType.BIRTH:
 | 
			
		||||
            childref = RelLib.ChildRef()
 | 
			
		||||
            childref.ref = self.person.handle
 | 
			
		||||
            childref.set_mother_relation(mrel)
 | 
			
		||||
@@ -938,8 +945,8 @@ class GrampsParser:
 | 
			
		||||
    def start_name(self,attrs):
 | 
			
		||||
        if not self.in_witness:
 | 
			
		||||
            self.name = RelLib.Name()
 | 
			
		||||
            self.name.type =_ConstXML.tuple_from_xml(
 | 
			
		||||
                _ConstXML.name_types,attrs.get('type','Birth Name'))
 | 
			
		||||
            self.name.type.set(_ConstXML.tuple_from_xml(
 | 
			
		||||
                _ConstXML.name_types,attrs.get('type','Birth Name')))
 | 
			
		||||
            self.name.sort_as = int(attrs.get("sort",RelLib.Name.DEF))
 | 
			
		||||
            self.name.display_as = int(attrs.get("display",RelLib.Name.DEF))
 | 
			
		||||
            self.name.conf = int(attrs.get("conf",2))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user