* src/GrampsDb/_GrampsBSDDB.py: Upgrade to new types.

* src/GrampsDb/_ReadGedcom.py: Adapt to new types.
	* src/RelLib/_Event.py: Properly set type.
	* src/RelLib/_EventRef.py: Properly set type.
	* src/RelLib/_Family.py: Properly set type.
	* src/RelLib/_Name.py: Properly set type.
	* src/RelLib/_Person.py: Properly set type.
	* src/RelLib/_PrimaryObject.py: Properly set type.
	* src/RelLib/_RepoRef.py: Properly set type.
	* src/RelLib/_Repository.py: Properly set type.
	* src/RelLib/_Url.py: Properly set type.


svn: r6386
This commit is contained in:
Alex Roitman 2006-04-21 00:03:27 +00:00
parent d631037137
commit 44884e9244
12 changed files with 46 additions and 116 deletions

View File

@ -1,3 +1,16 @@
2006-04-20 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_GrampsBSDDB.py: Upgrade to new types.
* src/GrampsDb/_ReadGedcom.py: Adapt to new types.
* src/RelLib/_Event.py: Properly set type.
* src/RelLib/_EventRef.py: Properly set type.
* src/RelLib/_Family.py: Properly set type.
* src/RelLib/_Name.py: Properly set type.
* src/RelLib/_Person.py: Properly set type.
* src/RelLib/_PrimaryObject.py: Properly set type.
* src/RelLib/_RepoRef.py: Properly set type.
* src/RelLib/_Repository.py: Properly set type.
* src/RelLib/_Url.py: Properly set type.
2006-04-20 Brian Matherly <pez4brian@users.sourceforge.net>
* src/docgen/ODFDoc.py: Fix space at begining of paragraph

View File

@ -1317,7 +1317,7 @@ class GrampsBSDDB(GrampsDbBase):
family.handle = handle
# Restore data from dbversion 8 (gramps 2.0.9)
(junk_handle, family.gramps_id, family.father_handle,
family.mother_handle, child_list, family.type,
family.mother_handle, child_list, the_type,
event_list, family.media_list, family.attribute_list,
lds_seal, complete, family.source_list,
family.note, family.change) = info
@ -1339,7 +1339,7 @@ class GrampsBSDDB(GrampsDbBase):
family.child_ref_list.append(child_ref)
# Change relationship type from int to tuple
family.type = (family.type,'')
family.type.set(the_type)
# In all Attributes, convert type from string to a tuple
for attribute in family.attribute_list:
@ -1369,7 +1369,7 @@ class GrampsBSDDB(GrampsDbBase):
death_handle, birth_handle, event_list,
person.family_list, parent_family_list,
person.media_list, person.address_list, person.attribute_list,
person.urls, lds_bapt, lds_endow, lds_seal,
urls, lds_bapt, lds_endow, lds_seal,
complete, person.source_list, person.note,
person.change, person.private) = (info + (False,))[0:23]
@ -1435,8 +1435,7 @@ class GrampsBSDDB(GrampsDbBase):
convert_mediaref_9(media_ref)
# In all Urls, add type attribute
for url in person.urls:
convert_url_9(url)
person.urls = [convert_url_9(url) for url in urls]
# Switch from fixed lds ords to a list
person.lds_ord_list = [item for item
@ -1447,55 +1446,6 @@ class GrampsBSDDB(GrampsDbBase):
self.update(100*current/length)
# Event upgrade
event_conversion = {
"Alternate Marriage" : (EventType.MARR_ALT,""),
"Annulment" : (EventType.ANNULMENT,""),
"Divorce" : (EventType.DIVORCE,""),
"Engagement" : (EventType.ENGAGEMENT,""),
"Marriage Banns" : (EventType.MARR_BANNS,""),
"Marriage Contract" : (EventType.MARR_CONTR,""),
"Marriage License" : (EventType.MARR_LIC,""),
"Marriage Settlement" : (EventType.MARR_SETTL,""),
"Marriage" : (EventType.MARRIAGE,""),
"Adopted" : (EventType.ADOPT,""),
"Birth" : (EventType.BIRTH,""),
"Alternate Birth" : (EventType.BIRTH,""),
"Death" : (EventType.DEATH,""),
"Alternate Death" : (EventType.DEATH,""),
"Adult Christening" : (EventType.ADULT_CHRISTEN,""),
"Baptism" : (EventType.BAPTISM,""),
"Bar Mitzvah" : (EventType.BAR_MITZVAH,""),
"Bas Mitzvah" : (EventType.BAS_MITZVAH,""),
"Blessing" : (EventType.BLESS,""),
"Burial" : (EventType.BURIAL,""),
"Cause Of Death" : (EventType.CAUSE_DEATH,""),
"Census" : (EventType.CENSUS,""),
"Christening" : (EventType.CHRISTEN,""),
"Confirmation" : (EventType.CONFIRMATION,""),
"Cremation" : (EventType.CREMATION,""),
"Degree" : (EventType.DEGREE,""),
"Divorce Filing" : (EventType.DIV_FILING,""),
"Education" : (EventType.EDUCATION,""),
"Elected" : (EventType.ELECTED,""),
"Emigration" : (EventType.EMIGRATION,""),
"First Communion" : (EventType.FIRST_COMMUN,""),
"Immigration" : (EventType.IMMIGRATION,""),
"Graduation" : (EventType.GRADUATION,""),
"Medical Information" : (EventType.MED_INFO,""),
"Military Service" : (EventType.MILITARY_SERV,""),
"Naturalization" : (EventType.NATURALIZATION,""),
"Nobility Title" : (EventType.NOB_TITLE,""),
"Number of Marriages" : (EventType.NUM_MARRIAGES,""),
"Occupation" : (EventType.OCCUPATION,""),
"Ordination" : (EventType.ORDINATION,""),
"Probate" : (EventType.PROBATE,""),
"Property" : (EventType.PROPERTY,""),
"Religion" : (EventType.RELIGION,""),
"Residence" : (EventType.RESIDENCE,""),
"Retirement" : (EventType.RETIREMENT,""),
"Will" : (EventType.WILL,""),
}
# Turns out that a lof ot events have duplicate gramps IDs
# We need to fix this
table_flags = self.open_flags()
@ -1519,14 +1469,7 @@ class GrampsBSDDB(GrampsDbBase):
if event.gramps_id in dup_ids:
event.gramps_id = self.find_next_event_gramps_id()
if old_type:
if event_conversion.has_key(old_type):
new_type = event_conversion[old_type]
else:
new_type = (EventType.CUSTOM,old_type)
else:
new_type = (EventType.UNKNOWN,"")
event.type = new_type
event.type.set_from_xml_str(old_type)
# Cover attributes contained in MediaRefs
for media_ref in event.media_list:
@ -1568,7 +1511,7 @@ class GrampsBSDDB(GrampsDbBase):
place = Place()
place.handle = handle
(junk_handle, place.gramps_id, place.title, place.long, place.lat,
place.main_loc, place.alt_loc, place.urls, place.media_list,
place.main_loc, place.alt_loc, urls, place.media_list,
place.source_list, place.note, place.change) = info
# Cover attributes contained in MediaRefs
@ -1576,8 +1519,7 @@ class GrampsBSDDB(GrampsDbBase):
convert_mediaref_9(media_ref)
# In all Urls, add type attribute
for url in place.urls:
convert_url_9(url)
place.urls = [convert_url_9(url) for url in urls]
self.commit_place(place,trans)
current += 1
@ -1640,14 +1582,20 @@ def convert_mediaref_9(media_ref):
def convert_url_9(url):
path = url.path.strip()
if path.find('mailto:') == 0 or url.path.find('@') != -1:
url.type = (Url.EMAIL,'')
if (path.find('mailto:') == 0) or (url.path.find('@') != -1):
new_type = UrlType.EMAIL
elif path.find('http://') == 0:
url.type = (Url.WEB_HOME,'')
new_type = UrlType.WEB_HOME
elif path.find('ftp://') == 0:
url.type = (Url.WEB_FTP,'')
new_type = UrlType.WEB_FTP
else:
url.type = (Url.CUSTOM,'')
new_type = UrlType.CUSTOM
new_url = Url()
new_url.type.set(new_type)
new_url.path = url.path
new_url.desc = url.desc
new_url.private = url.private
return new_url
def low_level_9(the_db):
"""

View File

@ -69,7 +69,6 @@ from DateHandler import DateParser
import NameDisplay
import Utils
import Mime
import _ConstXML
from ansel_utf8 import ansel_to_utf8
from bsddb import db
@ -1031,9 +1030,7 @@ class GedcomParser:
self.backup()
return
elif matches[1] == TOKEN_MEDI:
media_type = _ConstXML.tuple_from_xml(
_ConstXML.source_media_types,matches[2])
reporef.set_media_type(media_type)
reporef.media_type.set(matches[2])
else:
self.barf(1)
@ -1154,11 +1151,11 @@ class GedcomParser:
event.set_description(matches[2])
self.parse_family_event(event,2)
if int(event.get_type()) == RelLib.EventType.MARRIAGE:
self.family.set_relationship((RelLib.Family.MARRIED,''))
self.family.type.set(RelLib.FamilyRelType.MARRIED)
if int(event.get_type()) != RelLib.EventType.CUSTOM:
if not event.get_description():
text = _event_family_str % {
'event_name' : Utils.family_events[event.get_type()[0]],
'event_name' : str(event.get_type()),
'family' : Utils.family_name(self.family,self.db),
}
event.set_description(text)
@ -2197,7 +2194,7 @@ class GedcomParser:
event.set_gramps_id(self.emapper.find_next())
if matches[2]:
event.set_description(matches[2])
event.set_type(RelLib.EventTypeType.DEATH)
event.type.set(RelLib.EventType.DEATH)
self.parse_person_event(event,2)
person_event_name(event,state.person)
@ -2217,8 +2214,9 @@ class GedcomParser:
if matches[2]:
event.set_description(matches[2])
self.parse_person_event(event,2)
(t,n) = event.get_type()
if t == RelLib.EventType.CUSTOM and n in self.attrs:
the_type = event.get_type()
if int(the_type) == RelLib.EventType.CUSTOM \
and str(the_type) in self.attrs:
attr = RelLib.Attribute()
attr.set_type((RelLib.EventType.CUSTOM,self.gedattr[n]))
attr.set_value(event.get_description())

View File

@ -245,10 +245,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
@param the_type: Type to assign to the Event
@type the_type: tuple
"""
if type(the_type) == tuple:
self.type = EventType(the_type)
else:
self.type = the_type
self.type.set(the_type)
def get_type(self):
"""

View File

@ -127,7 +127,4 @@ class EventRef(BaseObject,PrivacyBase,NoteBase,RefBase):
"""
Sets the role according to the given argument.
"""
if type(role) == tuple:
self.role = EventRoleType(role)
else:
self.role = role
self.role.set(role)

View File

@ -45,7 +45,6 @@ from _EventRef import EventRef
from _LdsOrdBase import LdsOrdBase
from _ChildRef import ChildRef
from _FamilyRelType import FamilyRelType
from _MarkerType import MarkerType
#-------------------------------------------------------------------------
#
@ -298,11 +297,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
between the father and mother of the relationship.
@type relationship_type: tuple
"""
if type(relationship_type) == tuple:
self.type = FamilyRelType(relationship_type)
else:
self.type = relationship_type
return
self.type.set(relationship_type)
def get_relationship(self):
"""

View File

@ -234,10 +234,7 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
def set_type(self,the_type):
"""sets the type of the Name instance"""
if type(the_type) == tuple:
self.type = NameType(the_type)
else:
self.type = the_type
self.type(the_type)
def get_type(self):
"""returns the type of the Name instance"""

View File

@ -45,7 +45,6 @@ from _AddressBase import AddressBase
from _LdsOrdBase import LdsOrdBase
from _UrlBase import UrlBase
from _Name import Name
from _NameType import NameType
from _EventRef import EventRef
from _LdsOrd import LdsOrd
from _PersonRef import PersonRef

View File

@ -210,10 +210,7 @@ class PrimaryObject(BaseObject,PrivacyBase):
pass
def set_marker(self,marker):
if type(marker) == tuple:
self.marker = MarkerType(marker)
else:
self.marker = marker
self.marker.set(marker)
def get_marker(self):
return self.marker

View File

@ -111,7 +111,4 @@ class RepoRef(BaseObject,NoteBase,RefBase):
return self.media_type
def set_media_type(self,media_type):
if type(media_type) == tuple:
self.media_type = SourceMediaType(media_type)
else:
self.media_type = media_type
self.media_type.set(media_type)

View File

@ -140,10 +140,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
@param type: descriptive type of the Repository
@type type: str
"""
if type(the_type) == tuple:
self.type = RepositoryType(the_type)
else:
self.type = the_type
self.type.set(the_type)
def get_type(self):
"""

View File

@ -100,12 +100,7 @@ class Url(BaseObject,PrivacyBase):
@param type: descriptive type of the Url
@type type: str
"""
if type(the_type) == tuple:
self.type = UrlType(the_type)
else:
print the_type
assert(isinstance(the_type,UrlType))
self.type = the_type
self.type.set(the_type)
def get_type(self):
"""