Removing InstanceType calls from gen.lib modules. Required by the

GrampsTypeMeta changes.


svn: r10399
This commit is contained in:
Zsolt Foldvari 2008-03-25 23:38:24 +00:00
parent 8e5591ee16
commit 93998976ff
14 changed files with 66 additions and 109 deletions

View File

@ -35,7 +35,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.lib.grampstype import GrampsType, init_map
from gen.lib.grampstype import GrampsType
class AttributeType(GrampsType):

View File

@ -23,13 +23,6 @@
"""
Child Reference class for GRAMPS.
"""
#-------------------------------------------------------------------------
#
# standard python modules
#
#-------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -88,9 +81,9 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self, note_list)
RefBase.unserialize(self, ref)
self.frel = InstanceType(ChildRefType)
self.frel = ChildRefType()
self.frel.unserialize(frel)
self.mrel = InstanceType(ChildRefType)
self.mrel = ChildRefType()
self.mrel.unserialize(mrel)
return self

View File

@ -24,13 +24,6 @@
DateBase class for GRAMPS.
"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -74,10 +67,8 @@ class DateBase:
"""
Convert a serialized tuple of data to an object.
"""
if data == None:
self.date = Date()
else:
self.date = InstanceType(Date)
self.date = Date()
if data is not None:
self.date.unserialize(data)
def get_date_object(self):

View File

@ -39,8 +39,6 @@ from gen.lib.placebase import PlaceBase
from gen.lib.eventtype import EventType
from gen.lib.markertype import MarkerType
from types import InstanceType
#-------------------------------------------------------------------------
#
# Event class
@ -120,9 +118,9 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
source_list, note_list, media_list, attribute_list,
self.change, marker, self.private) = data
self.marker = InstanceType(MarkerType)
self.marker = MarkerType()
self.marker.unserialize(marker)
self.type = InstanceType(EventType)
self.type = EventType()
self.type.unserialize(the_type)
DateBase.unserialize(self, date)
MediaBase.unserialize(self, media_list)

View File

@ -24,13 +24,6 @@
Event Reference class for GRAMPS
"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -90,7 +83,7 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
NoteBase.unserialize(self, note_list)
AttributeBase.unserialize(self, attribute_list)
RefBase.unserialize(self, ref)
self.role = InstanceType(EventRoleType)
self.role = EventRoleType()
self.role.unserialize(role)
return self

View File

@ -30,7 +30,6 @@ Family object for GRAMPS.
#
#-------------------------------------------------------------------------
from warnings import warn
from types import InstanceType
#-------------------------------------------------------------------------
#
@ -136,14 +135,20 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
attribute_list, lds_seal_list, source_list, note_list,
self.change, marker, self.private) = data
self.marker = InstanceType(MarkerType)
self.marker = MarkerType()
self.marker.unserialize(marker)
self.type = InstanceType(FamilyRelType)
self.type = FamilyRelType()
self.type.unserialize(the_type)
self.event_ref_list = [InstanceType(EventRef).unserialize(er)
for er in event_ref_list]
self.child_ref_list = [InstanceType(ChildRef).unserialize(cr)
for cr in child_ref_list]
self.event_ref_list = []
for er in event_ref_list:
eventref = EventRef()
eventref.unserialize(er)
self.event_ref_list.append(eventref)
self.child_ref_list = []
for cr in child_ref_list:
childref = ChildRef()
childref.unserialize(cr)
self.child_ref_list.append(childref)
MediaBase.unserialize(self, media_list)
AttributeBase.unserialize(self, attribute_list)
SourceBase.unserialize(self, source_list)

View File

@ -31,7 +31,7 @@ Base type for all gramps types.
#------------------------------------------------------------------------
from gettext import gettext as _
def __init_map(data, key_col, data_col):
def _init_map(data, key_col, data_col):
"""
Initialize the map, building a new map from the specified columns.
"""
@ -63,10 +63,10 @@ class GrampsType(object):
__metaclass__ = GrampsTypeMeta
def __class_init__(cls, namespace):
cls._I2SMAP = __init_map(cls._DATAMAP, 0, 1)
cls._S2IMAP = __init_map(cls._DATAMAP, 1, 0)
cls._I2EMAP = __init_map(cls._DATAMAP, 0, 2)
cls._E2IMAP = __init_map(cls._DATAMAP, 2, 0)
cls._I2SMAP = _init_map(cls._DATAMAP, 0, 1)
cls._S2IMAP = _init_map(cls._DATAMAP, 1, 0)
cls._I2EMAP = _init_map(cls._DATAMAP, 0, 2)
cls._E2IMAP = _init_map(cls._DATAMAP, 2, 0)
__class_init__ = classmethod(__class_init__)

View File

@ -30,7 +30,6 @@ Media object for GRAMPS.
#
#-------------------------------------------------------------------------
import os
from types import InstanceType
#-------------------------------------------------------------------------
#
@ -122,7 +121,7 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
attribute_list, source_list, note_list, self.change,
date, marker, self.private) = data
self.marker = InstanceType(MarkerType)
self.marker = MarkerType()
self.marker.unserialize(marker)
AttributeBase.unserialize(self, attribute_list)
SourceBase.unserialize(self, source_list)

View File

@ -23,12 +23,6 @@
"""
Person object for GRAMPS.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
@ -189,16 +183,25 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
person_ref_list, # 20
) = data
self.marker = InstanceType(MarkerType)
self.marker = MarkerType()
self.marker.unserialize(marker)
self.primary_name = InstanceType(Name)
self.primary_name = Name()
self.primary_name.unserialize(primary_name)
self.alternate_names = [InstanceType(Name).unserialize(name)
for name in alternate_names]
self.event_ref_list = [InstanceType(EventRef).unserialize(er)
for er in event_ref_list]
self.person_ref_list = [InstanceType(PersonRef).unserialize(pr)
for pr in person_ref_list]
self.alternate_names = []
for name in alternate_names:
n = Name()
n.unserialize(name)
self.alternate_names.append(n)
self.event_ref_list = []
for er in event_ref_list:
eventref = EventRef()
eventref.unserialize(er)
self.event_ref_list.append(eventref)
self.person_ref_list = []
for pr in person_ref_list:
personref = PersonRef()
personref.unserialize(pr)
self.person_ref_list.append(personref)
MediaBase.unserialize(self, media_list)
LdsOrdBase.unserialize(self, lds_ord_list)
AddressBase.unserialize(self, address_list)

View File

@ -24,13 +24,6 @@
Place object for GRAMPS.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -128,13 +121,17 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
main_loc, alt_loc, urls, media_list, source_list, note_list,
self.change, marker, self.private) = data
if main_loc == None:
if main_loc is None:
self.main_loc = None
else:
self.main_loc = InstanceType(Location).unserialize(main_loc)
self.alt_loc = [InstanceType(Location).unserialize(al)
for al in alt_loc]
self.marker = InstanceType(MarkerType)
self.main_loc = Location()
self.main_loc.unserialize(main_loc)
self.alt_loc = []
for al in alt_loc:
location = Location()
location.unserialize(al)
self.alt_loc.append(location)
self.marker = MarkerType()
self.marker.unserialize(marker)
UrlBase.unserialize(self, urls)
MediaBase.unserialize(self, media_list)

View File

@ -24,13 +24,6 @@
Repository object for GRAMPS.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -81,9 +74,9 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject):
(self.handle, self.gramps_id, the_type, self.name, note_list,
address_list, urls, self.change, marker, self.private) = data
self.marker = InstanceType(MarkerType)
self.marker = MarkerType()
self.marker.unserialize(marker)
self.type = InstanceType(RepositoryType)
self.type = RepositoryType()
self.type.unserialize(the_type)
NoteBase.unserialize(self, note_list)
AddressBase.unserialize(self, address_list)

View File

@ -24,13 +24,6 @@
Repository Reference class for GRAMPS
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -79,7 +72,7 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
Convert a serialized tuple of data to an object.
"""
(note_list, ref, self.call_number, media_type, privacy) = data
self.media_type = InstanceType(SourceMediaType)
self.media_type = SourceMediaType()
self.media_type.unserialize(media_type)
PrivacyBase.unserialize(self, privacy)
NoteBase.unserialize(self, note_list)

View File

@ -24,13 +24,6 @@
Source object for GRAMPS.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -85,12 +78,15 @@ class Source(MediaBase, NoteBase, PrimaryObject):
self.abbrev, self.change, self.datamap, reporef_list,
marker, self.private) = data
self.marker = InstanceType(MarkerType)
self.marker = MarkerType()
self.marker.unserialize(marker)
NoteBase.unserialize(self, note_list)
MediaBase.unserialize(self, media_list)
self.reporef_list = [InstanceType(RepoRef).unserialize(rr)
for rr in reporef_list]
self.reporef_list = []
for rr in reporef_list:
reporef = RepoRef()
reporef.unserialize(rr)
self.reporef_list.append(reporef)
def _has_handle_reference(self, classname, handle):
"""

View File

@ -24,13 +24,6 @@
SourceBase class for GRAMPS.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from types import InstanceType
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -70,8 +63,11 @@ class SourceBase:
"""
Convert a serialized tuple of data to an object.
"""
self.source_list = [InstanceType(SourceRef).unserialize(item)
for item in data]
self.source_list = []
for item in data:
sourceref = SourceRef()
sourceref.unserialize(item)
self.source_list.append(sourceref)
def add_source_reference(self, src_ref) :
"""