* src/GrampsDb/_WriteGedcom.py: Multiple improvements.

* various: Replace get/set_base_handle with get/set_reference_handle.
	* src/RelLib/_SourceRef.py (get_base_handle,set_base_handle):
	Remove redundant methods.


svn: r6750
This commit is contained in:
Alex Roitman 2006-05-22 23:56:57 +00:00
parent a11c0949d6
commit 36413653f9
18 changed files with 335 additions and 288 deletions

View File

@ -1,4 +1,8 @@
2006-05-22 Alex Roitman <shura@gramps-project.org> 2006-05-22 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_WriteGedcom.py: Multiple improvements.
* various: Replace get/set_base_handle with get/set_reference_handle.
* src/RelLib/_SourceRef.py (get_base_handle,set_base_handle):
Remove redundant methods.
* src/ArgHandler.py (need_gui): Add method. * src/ArgHandler.py (need_gui): Add method.
* src/ViewManager.py: Move statusbar notification from gramps_main. * src/ViewManager.py: Move statusbar notification from gramps_main.
* src/gramps_main.py: Remove unused methods, handle ArgHandler better. * src/gramps_main.py: Remove unused methods, handle ArgHandler better.

View File

@ -836,7 +836,7 @@ class GedcomParser(UpdateCallback):
self.db.commit_person(child, self.trans) self.db.commit_person(child, self.trans)
if len(self.family.get_source_references()) == 0: if len(self.family.get_source_references()) == 0:
sref = RelLib.SourceRef() sref = RelLib.SourceRef()
sref.set_base_handle(self.def_src.handle) sref.set_reference_handle(self.def_src.handle)
self.family.add_source_reference(sref) self.family.add_source_reference(sref)
self.db.commit_family(self.family, self.trans) self.db.commit_family(self.family, self.trans)
del self.family del self.family
@ -849,7 +849,7 @@ class GedcomParser(UpdateCallback):
self.parse_individual(self.person) self.parse_individual(self.person)
if len(self.person.get_source_references()) == 0: if len(self.person.get_source_references()) == 0:
sref = RelLib.SourceRef() sref = RelLib.SourceRef()
sref.set_base_handle(self.def_src.handle) sref.set_reference_handle(self.def_src.handle)
self.person.add_source_reference(sref) self.person.add_source_reference(sref)
self.db.commit_person(self.person, self.trans) self.db.commit_person(self.person, self.trans)
del self.person del self.person
@ -1990,7 +1990,7 @@ class GedcomParser(UpdateCallback):
else: else:
handle = self.find_or_create_source(matches[2][1:-1]).handle handle = self.find_or_create_source(matches[2][1:-1]).handle
self.parse_source_reference(source_ref,level) self.parse_source_reference(source_ref,level)
source_ref.set_base_handle(handle) source_ref.set_reference_handle(handle)
return source_ref return source_ref
def resolve_refns(self): def resolve_refns(self):

View File

@ -26,23 +26,16 @@
# Standard Python Modules # Standard Python Modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gettext import gettext as _
import os import os
import time import time
import re import re
import shutil import shutil
try: try:
set() set()
except: except:
from sets import Set as set from sets import Set as set
from gettext import gettext as _
#------------------------------------------------------------------------
#
# Set up logging
#
#------------------------------------------------------------------------
import logging import logging
log = logging.getLogger(".WriteGedcom") log = logging.getLogger(".WriteGedcom")
@ -71,6 +64,11 @@ import NameDisplay
from QuestionDialog import ErrorDialog, WarningDialog from QuestionDialog import ErrorDialog, WarningDialog
from BasicUtils import UpdateCallback from BasicUtils import UpdateCallback
#------------------------------------------------------------------------
#
# Helper functions
#
#------------------------------------------------------------------------
def keep_utf8(s): def keep_utf8(s):
return s return s
@ -148,87 +146,98 @@ lds_status = {
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_get_int = re.compile('([0-9]+)') _get_int = re.compile('([0-9]+)')
mime2ged = {
"image/bmp" : "bmp",
"image/gif" : "gif",
"image/jpeg" : "jpeg",
"image/x-pcx" : "pcx",
"image/tiff" : "tiff",
"audio/x-wav" : "wav"
}
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def add_srefs(the_set,obj):
"""
Add handles of sources referenced in obj to the_set.
"""
the_list = [source_ref.ref
for source_ref in obj.get_source_references()
if source_ref.ref != None]
the_set.update(the_list)
def add_familys_sources(db,family_handle,slist,private): def add_familys_sources(db,family_handle,slist,private):
"""
Add handles of sources referenced in family and its child objects to slist.
"""
# FIXME: this only considers source references for family, events,
# and attributes.
family = db.get_family_from_handle(family_handle) family = db.get_family_from_handle(family_handle)
for source_ref in family.get_source_references():
sbase = source_ref.get_base_handle() add_srefs(slist,family)
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
if not event_ref: if not event_ref:
continue continue
event_handle = event_ref.ref event_handle = event_ref.ref
event = db.get_event_from_handle(event_handle) event = db.get_event_from_handle(event_handle)
if not event:
continue
if private and event.get_privacy(): if private and event.get_privacy():
continue continue
for source_ref in event.get_source_references():
sbase = source_ref.get_base_handle() add_srefs(slist,event)
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1 for lds_ord in family.get_lds_ord_list():
add_srefs(slist,event)
for attr in family.get_attribute_list(): for attr in family.get_attribute_list():
if private and attr.get_privacy(): if private and attr.get_privacy():
continue continue
for source_ref in attr.get_source_references():
sbase = source_ref.get_base_handle()
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
#------------------------------------------------------------------------- add_srefs(slist,attr)
#
#
#
#-------------------------------------------------------------------------
def add_persons_sources(db,person,slist,private): def add_persons_sources(db,person,slist,private):
for source_ref in person.get_source_references(): """
sbase = source_ref.get_base_handle() Add handles of sources referenced in person and its child objects to slist.
if sbase != None and not slist.has_key(sbase): """
slist[sbase] = 1
# FIXME: this only considers source references for person, events,
# attributes, addresses, and names.
add_srefs(slist,person)
for event_ref in person.get_event_ref_list() + [person.get_birth_ref(), for event_ref in person.get_event_ref_list() + [person.get_birth_ref(),
person.get_death_ref()]: person.get_death_ref()]:
if event_ref: if not event_ref:
event_handle = event_ref.ref continue
event = db.get_event_from_handle(event_handle) event_handle = event_ref.ref
if not event: event = db.get_event_from_handle(event_handle)
continue if not event:
if private and event.get_privacy(): continue
continue
for source_ref in event.get_source_references():
sbase = source_ref.get_base_handle()
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
for event in person.get_address_list():
if private and event.get_privacy(): if private and event.get_privacy():
continue continue
for source_ref in event.get_source_references(): add_srefs(slist,event)
sbase = source_ref.get_base_handle()
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
for event in person.get_attribute_list(): for lds_ord in person.get_lds_ord_list():
if private and event.get_privacy(): add_srefs(slist,event)
for addr in person.get_address_list():
if private and addr.get_privacy():
continue continue
for source_ref in event.get_source_references(): add_srefs(slist,addr)
sbase = source_ref.get_base_handle()
if sbase != None and not slist.has_key(sbase): for attr in person.get_attribute_list():
slist[sbase] = 1 if private and attr.get_privacy():
continue
add_srefs(slist,attr)
for name in person.get_alternate_names() + [person.get_primary_name()]: for name in person.get_alternate_names() + [person.get_primary_name()]:
if private and name.get_privacy(): if private and name.get_privacy():
continue continue
for source_ref in name.get_source_references(): add_srefs(slist,name)
sbase = source_ref.get_base_handle()
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -240,22 +249,6 @@ def addr_append(text,data):
else: else:
return text return text
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def sortById(first,second):
fid = first.get_handle()
sid = second.get_handle()
if fid == sid:
return 0
elif fid < sid:
return -1
else:
return 1
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -473,7 +466,6 @@ class GedcomWriterOptionBox:
self.nl = self.cnvtxt(self.target_ged.get_endl()) self.nl = self.cnvtxt(self.target_ged.get_endl())
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GedcomWriter class # GedcomWriter class
@ -489,72 +481,80 @@ class GedcomWriter(UpdateCallback):
self.option_box = option_box self.option_box = option_box
self.cl = cl self.cl = cl
self.filename = filename self.filename = filename
self.plist = {}
self.slist = {}
self.flist = {}
self.fidval = 0
self.fidmap = {}
self.sidval = 0
self.sidmap = {}
self.rlist = set()
if not option_box: if option_box:
self.cl_setup() setup_func = self.gui_setup
else: else:
self.option_box.parse_options() setup_func = self.cli_setup
self.restrict = self.option_box.restrict # Run setup, bail out if status is not Ture
self.living = self.option_box.living if not setup_func():
self.exclnotes = self.option_box.exclnotes return
self.exclsrcs = self.option_box.exclsrcs
self.private = self.option_box.private
self.copy = self.option_box.copy
self.images = self.option_box.images
self.images_path = self.option_box.images_path
self.target_ged = self.option_box.target_ged
self.dest = self.option_box.dest
self.adopt = self.option_box.adopt
self.conc = self.option_box.conc
self.altname = self.option_box.altname
self.cal = self.option_box.cal
self.obje = self.option_box.obje
self.resi = self.option_box.resi
self.prefix = self.option_box.prefix
self.source_refs = self.option_box.source_refs
self.cnvtxt = self.option_box.cnvtxt
self.nl = self.option_box.nl
if self.option_box.cfilter == None:
for p in self.db.get_person_handles(sort_handles=False):
self.plist[p] = 1
else:
try:
for p in self.option_box.cfilter.apply(self.db,
self.db.get_person_handles(sort_handles=False)):
self.plist[p] = 1
except Errors.FilterError, msg:
(m1,m2) = msg.messages()
ErrorDialog(m1,m2)
return
for key in self.plist.keys(): self.flist = set()
p = self.db.get_person_from_handle(key) self.slist = set()
add_persons_sources(self.db,p,self.slist, self.rlist = set()
self.option_box.private)
for family_handle in p.get_family_handle_list(): # Collect needed families
add_familys_sources(self.db,family_handle, for handle in list(self.plist):
self.slist,self.option_box.private) person = self.db.get_person_from_handle(handle)
self.flist[family_handle] = 1 #add_persons_sources(self.db,person,self.slist,
# self.option_box.private)
if self.private and person.private:
self.plist.remove(handle)
for family_handle in person.get_family_handle_list():
#add_familys_sources(self.db,family_handle,
# self.slist,self.option_box.private)
family = self.db.get_person_from_handle(family_handle)
if self.private and family.private:
continue
self.flist.add(family_handle)
def cl_setup(self): def gui_setup(self):
# Get settings from the options store/dialog
self.option_box.parse_options()
self.restrict = self.option_box.restrict
self.living = self.option_box.living
self.exclnotes = self.option_box.exclnotes
self.exclsrcs = self.option_box.exclsrcs
self.private = self.option_box.private
self.copy = self.option_box.copy
self.images = self.option_box.images
self.images_path = self.option_box.images_path
self.target_ged = self.option_box.target_ged
self.dest = self.option_box.dest
self.adopt = self.option_box.adopt
self.conc = self.option_box.conc
self.altname = self.option_box.altname
self.cal = self.option_box.cal
self.obje = self.option_box.obje
self.resi = self.option_box.resi
self.prefix = self.option_box.prefix
self.source_refs = self.option_box.source_refs
self.cnvtxt = self.option_box.cnvtxt
self.nl = self.option_box.nl
if self.option_box.cfilter == None:
self.plist = set(self.db.get_person_handles(sort_handles=False))
else:
try:
self.plist = set(self.option_box.cfilter.apply(
self.db,self.db.get_person_handles(sort_handles=False)))
return True
except Errors.FilterError, msg:
(m1,m2) = msg.messages()
ErrorDialog(m1,m2)
return False
def cli_setup(self):
# use default settings
self.restrict = 0 self.restrict = 0
self.private = 0 self.private = 0
self.copy = 0 self.copy = 0
self.images = 0 self.images = 0
for p in self.db.get_person_handles(sort_handles=False): self.plist = set(self.db.get_person_handles(sort_handles=False))
self.plist[p] = 1
gedmap = GedcomInfo.GedcomInfoDB() gedmap = GedcomInfo.GedcomInfoDB()
self.target_ged = gedmap.standard self.target_ged = gedmap.standard
@ -572,13 +572,7 @@ class GedcomWriter(UpdateCallback):
self.cnvtxt = keep_utf8 self.cnvtxt = keep_utf8
self.nl = self.cnvtxt(self.target_ged.get_endl()) self.nl = self.cnvtxt(self.target_ged.get_endl())
for key in self.plist.keys(): return True
p = self.db.get_person_from_handle(key)
add_persons_sources(self.db,p,self.slist,self.private)
for family_handle in p.get_family_handle_list():
add_familys_sources(self.db,family_handle,
self.slist,self.private)
self.flist[family_handle] = 1
def writeln(self,text): def writeln(self,text):
self.g.write('%s%s' % (text,self.nl)) self.g.write('%s%s' % (text,self.nl))
@ -635,7 +629,8 @@ class GedcomWriter(UpdateCallback):
self.writeln("2 CONT %s" % self.cnvtxt(owner.get_state())) self.writeln("2 CONT %s" % self.cnvtxt(owner.get_state()))
cnt = 1 cnt = 1
if owner.get_postal_code(): if owner.get_postal_code():
self.writeln("2 CONT %s" % self.cnvtxt(owner.get_postal_code())) self.writeln("2 CONT %s" %
self.cnvtxt(owner.get_postal_code()))
cnt = 1 cnt = 1
if owner.get_country(): if owner.get_country():
self.writeln("2 CONT %s" % self.cnvtxt(owner.get_country())) self.writeln("2 CONT %s" % self.cnvtxt(owner.get_country()))
@ -648,13 +643,11 @@ class GedcomWriter(UpdateCallback):
self.writeln('1 ADDR Not Provided') self.writeln('1 ADDR Not Provided')
self.writeln('2 CONT Not Provided') self.writeln('2 CONT Not Provided')
pkeys = self.plist.keys() self.set_total(len(self.plist) + len(self.flist))
self.set_total(len(pkeys) + len(self.flist.keys()) \
+ len(self.slist.keys()))
sorted = [] sorted = []
for key in pkeys: for handle in self.plist:
person = self.db.get_person_from_handle (key) person = self.db.get_person_from_handle (handle)
data = (person.get_gramps_id (), person) data = (person.get_gramps_id (), person)
sorted.append (data) sorted.append (data)
sorted.sort() sorted.sort()
@ -665,8 +658,7 @@ class GedcomWriter(UpdateCallback):
self.write_families() self.write_families()
if self.source_refs: if self.source_refs:
self.write_sources() self.write_sources()
self.write_repos()
self.write_repos()
self.writeln("0 TRLR") self.writeln("0 TRLR")
self.g.close() self.g.close()
@ -681,7 +673,8 @@ class GedcomWriter(UpdateCallback):
self.writeln('1 COPR Copyright (c) %d %s.' % (y,o)) self.writeln('1 COPR Copyright (c) %d %s.' % (y,o))
elif self.copy == 1: elif self.copy == 1:
o = self.db.get_researcher().get_name() o = self.db.get_researcher().get_name()
self.writeln('1 COPR Copyright (c) %d %s. See additional copyright NOTE below.' % (y,o)) self.writeln('1 COPR Copyright (c) %d %s. '
'See additional copyright NOTE below.' % (y,o))
def gnu_fdl(self): def gnu_fdl(self):
if self.copy != 1: if self.copy != 1:
@ -702,9 +695,9 @@ class GedcomWriter(UpdateCallback):
def write_families(self): def write_families(self):
sorted = [] sorted = []
for family_handle in self.flist.keys (): for family_handle in self.flist:
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
data = (self.fid (family_handle), family_handle, family) data = (family.get_gramps_id(), family_handle, family)
sorted.append (data) sorted.append (data)
sorted.sort () sorted.sort ()
for (gramps_id, family_handle, family) in sorted: for (gramps_id, family_handle, family) in sorted:
@ -712,14 +705,14 @@ class GedcomWriter(UpdateCallback):
self.writeln("0 @%s@ FAM" % gramps_id) self.writeln("0 @%s@ FAM" % gramps_id)
self.frefn(family) self.frefn(family)
person_handle = family.get_father_handle() person_handle = family.get_father_handle()
if person_handle != None and self.plist.has_key(person_handle): if (person_handle != None) and (person_handle in self.plist):
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
gramps_id = person.get_gramps_id() gramps_id = person.get_gramps_id()
self.writeln("1 HUSB @%s@" % gramps_id) self.writeln("1 HUSB @%s@" % gramps_id)
father_alive = Utils.probably_alive(person,self.db) father_alive = Utils.probably_alive(person,self.db)
person_handle = family.get_mother_handle() person_handle = family.get_mother_handle()
if person_handle != None and self.plist.has_key(person_handle): if (person_handle != None) and (person_handle in self.plist):
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
gramps_id = person.get_gramps_id() gramps_id = person.get_gramps_id()
self.writeln("1 WIFE @%s@" % gramps_id) self.writeln("1 WIFE @%s@" % gramps_id)
@ -739,7 +732,8 @@ class GedcomWriter(UpdateCallback):
val = self.target_ged.gramps2tag(name) val = self.target_ged.gramps2tag(name)
if val: if val:
if not event.get_date_object().is_empty() or event.get_place_handle(): if (not event.get_date_object().is_empty()) \
or event.get_place_handle():
self.writeln("1 %s" % self.cnvtxt(val)) self.writeln("1 %s" % self.cnvtxt(val))
else: else:
self.writeln("1 %s Y" % self.cnvtxt(val)) self.writeln("1 %s Y" % self.cnvtxt(val))
@ -781,14 +775,15 @@ class GedcomWriter(UpdateCallback):
self.write_source_ref(2,srcref) self.write_source_ref(2,srcref)
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
if not self.plist.has_key(child_ref.ref): if child_ref.ref not in self.plist:
continue continue
person = self.db.get_person_from_handle(child_ref.ref) person = self.db.get_person_from_handle(child_ref.ref)
if not person: if not person:
continue continue
self.writeln("1 CHIL @%s@" % person.get_gramps_id()) self.writeln("1 CHIL @%s@" % person.get_gramps_id())
if self.adopt == GedcomInfo.ADOPT_FTW: if self.adopt == GedcomInfo.ADOPT_FTW:
if person.get_main_parents_family_handle() == family.get_handle(): if person.get_main_parents_family_handle() \
== family.get_handle():
self.writeln('2 _FREL Natural') self.writeln('2 _FREL Natural')
self.writeln('2 _MREL Natural') self.writeln('2 _MREL Natural')
else: else:
@ -823,15 +818,17 @@ class GedcomWriter(UpdateCallback):
self.update() self.update()
def write_sources(self): def write_sources(self):
index = 0.0
sorted = [] sorted = []
for handle in self.slist.keys(): for handle in self.slist:
source = self.db.get_source_from_handle(handle) source = self.db.get_source_from_handle(handle)
if not source: if not source:
continue continue
data = (self.sid(handle), source) if self.private and source.private:
continue
data = (source.get_gramps_id(), source)
sorted.append (data) sorted.append (data)
sorted.sort () sorted.sort ()
for (source_id, source) in sorted: for (source_id, source) in sorted:
self.writeln("0 @%s@ SOUR" % source_id) self.writeln("0 @%s@ SOUR" % source_id)
if source.get_title(): if source.get_title():
@ -847,7 +844,8 @@ class GedcomWriter(UpdateCallback):
source.get_publication_info())) source.get_publication_info()))
if source.get_abbreviation(): if source.get_abbreviation():
self.writeln("1 ABBR %s" % self.cnvtxt(source.get_abbreviation())) self.writeln("1 ABBR %s" %
self.cnvtxt(source.get_abbreviation()))
if self.images: if self.images:
photos = source.get_media_list () photos = source.get_media_list ()
for photo in photos: for photo in photos:
@ -860,18 +858,20 @@ class GedcomWriter(UpdateCallback):
if source.get_note(): if source.get_note():
self.write_long_text("NOTE",1,self.cnvtxt(source.get_note())) self.write_long_text("NOTE",1,self.cnvtxt(source.get_note()))
index = index + 1
self.write_change(1,source.get_change_time()) self.write_change(1,source.get_change_time())
self.update()
def write_repos(self): def write_repos(self):
sorted = [] sorted = []
for handle in self.rlist: for handle in self.rlist:
repo = self.db.get_repository_from_handle(handle) repo = self.db.get_repository_from_handle(handle)
if self.private and repo.private:
continue
repo_id = repo.get_gramps_id() repo_id = repo.get_gramps_id()
rlist.append((repo_id,repo)) sorted.append((repo_id,repo))
sorted.sort() sorted.sort()
slist = set()
for (repo_id,repo) in sorted: for (repo_id,repo) in sorted:
self.writeln("0 @%s@ REPO" % repo_id) self.writeln("0 @%s@ REPO" % repo_id)
@ -879,11 +879,31 @@ class GedcomWriter(UpdateCallback):
self.write_long_text('NAME',1, self.write_long_text('NAME',1,
"%s" % self.cnvtxt(repo.get_name())) "%s" % self.cnvtxt(repo.get_name()))
for addr in repo.get_address_list(): for addr in repo.get_address_list():
pass self.write_long_text("ADDR",1,
self.cnvtxt(addr.get_street()))
if addr.get_city():
self.writeln("2 CITY %s"
% self.cnvtxt(addr.get_city()))
if addr.get_state():
self.writeln("2 STAE %s"
% self.cnvtxt(addr.get_state()))
if addr.get_postal_code():
self.writeln("2 POST %s"
% self.cnvtxt(addr.get_postal_code()))
if addr.get_country():
self.writeln("2 CTRY %s"
% self.cnvtxt(addr.get_country()))
if addr.get_phone():
self.writeln("1 PHON %s"
% self.cnvtxt(addr.get_phone()))
if repo.get_note(): if repo.get_note():
self.write_long_text("NOTE",1,self.cnvtxt(repo.get_note())) self.write_long_text("NOTE",1,self.cnvtxt(repo.get_note()))
def write_reporef(self,reporef,level): def write_reporef(self,reporef,level):
if self.private and reporef.private:
return
if reporef.ref == None: if reporef.ref == None:
return return
@ -947,7 +967,8 @@ class GedcomWriter(UpdateCallback):
if birth_ref: if birth_ref:
birth = self.db.get_event_from_handle(birth_ref.ref) birth = self.db.get_event_from_handle(birth_ref.ref)
if not (self.private and birth.get_privacy()): if not (self.private and birth.get_privacy()):
if not birth.get_date_object().is_empty() or birth.get_place_handle(): if (not birth.get_date_object().is_empty()) \
or birth.get_place_handle():
self.writeln("1 BIRT") self.writeln("1 BIRT")
else: else:
self.writeln("1 BIRT Y") self.writeln("1 BIRT Y")
@ -959,7 +980,8 @@ class GedcomWriter(UpdateCallback):
if death_ref: if death_ref:
death = self.db.get_event_from_handle(death_ref.ref) death = self.db.get_event_from_handle(death_ref.ref)
if not (self.private and death.get_privacy()): if not (self.private and death.get_privacy()):
if not death.get_date_object().is_empty() or death.get_place_handle(): if (not death.get_date_object().is_empty()) \
or death.get_place_handle():
self.writeln("1 DEAT") self.writeln("1 DEAT")
else: else:
self.writeln("1 DEAT Y") self.writeln("1 DEAT Y")
@ -998,8 +1020,7 @@ class GedcomWriter(UpdateCallback):
fam = family fam = family
break break
if fam: if fam:
self.writeln('2 FAMC @%s@' % self.writeln('2 FAMC @%s@' % fam.get_gramps_id())
self.fid(fam.get_gramps_id()))
if mrel == frel: if mrel == frel:
self.writeln('3 ADOP BOTH') self.writeln('3 ADOP BOTH')
elif mrel == RelLib.ChildRefType.ADOPTED: elif mrel == RelLib.ChildRefType.ADOPTED:
@ -1009,17 +1030,22 @@ class GedcomWriter(UpdateCallback):
elif val : elif val :
if val in personalAttributeTakesParam: if val in personalAttributeTakesParam:
if event.get_description(): if event.get_description():
self.writeln("1 %s %s" % (self.cnvtxt(val),\ self.writeln(
self.cnvtxt(event.get_description()))) "1 %s %s" %
(self.cnvtxt(val),
self.cnvtxt(event.get_description())))
else: else:
self.writeln("1 %s" % self.cnvtxt(val)) self.writeln("1 %s" % self.cnvtxt(val))
else: else:
if not event.get_date_object().is_empty() or event.get_place_handle(): if (not event.get_date_object().is_empty()) \
or event.get_place_handle():
self.writeln("1 %s" % self.cnvtxt(val)) self.writeln("1 %s" % self.cnvtxt(val))
else: else:
self.writeln("1 %s Y" % self.cnvtxt(val)) self.writeln("1 %s Y" % self.cnvtxt(val))
if event.get_description(): if event.get_description():
self.writeln("2 TYPE %s" % self.cnvtxt(event.get_description())) self.writeln(
"2 TYPE %s"
% self.cnvtxt(event.get_description()))
else: else:
# Actually, it is against the spec to put anything # Actually, it is against the spec to put anything
# after EVEN on the same line, possibly an option is # after EVEN on the same line, possibly an option is
@ -1033,24 +1059,23 @@ class GedcomWriter(UpdateCallback):
self.dump_event_stats(event) self.dump_event_stats(event)
if self.adopt == GedcomInfo.ADOPT_EVENT and ad == 0 and len(person.get_parent_family_handle_list()) != 0: if (self.adopt == GedcomInfo.ADOPT_EVENT) and (ad == 0) \
and (len(person.get_parent_family_handle_list()) != 0):
self.writeln('1 ADOP') self.writeln('1 ADOP')
fam = None fam = None
for fh in person.get_parent_family_handle_list(): for fh in person.get_parent_family_handle_list():
family = self.db.get_family_from_handle(fh) family = self.db.get_family_from_handle(fh)
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
if child_ref.ref == person.handle: if child_ref.ref == person.handle:
if \ if (child_ref.mrel == RelLib.ChildRefType.ADOPTED)\
child_ref.mrel == \ or (child_ref.frel \
RelLib.ChildRefType.ADOPTED \ == RelLib.ChildRefType.ADOPTED):
or child_ref.frel == \ frel = child_ref.frel
RelLib.ChildRefType.ADOPTED: mrel = child_ref.mrel
frel = child_ref.frel fam = family
mrel = child_ref.mrel break
fam = family
break
if fam: if fam:
self.writeln('2 FAMC @%s@' % self.fid(fam.get_gramps_id())) self.writeln('2 FAMC @%s@' % fam.get_gramps_id())
if mrel == frel: if mrel == frel:
self.writeln('3 ADOP BOTH') self.writeln('3 ADOP BOTH')
elif mrel == RelLib.ChildRefType.ADOPTED: elif mrel == RelLib.ChildRefType.ADOPTED:
@ -1091,17 +1116,23 @@ class GedcomWriter(UpdateCallback):
self.writeln("1 RESI") self.writeln("1 RESI")
self.print_date("2 DATE",addr.get_date_object()) self.print_date("2 DATE",addr.get_date_object())
if self.resi == 0: if self.resi == 0:
self.write_long_text("ADDR",2,self.cnvtxt(addr.get_street())) self.write_long_text("ADDR",2,
self.cnvtxt(addr.get_street()))
if addr.get_city(): if addr.get_city():
self.writeln("3 CITY %s" % self.cnvtxt(addr.get_city())) self.writeln("3 CITY %s"
% self.cnvtxt(addr.get_city()))
if addr.get_state(): if addr.get_state():
self.writeln("3 STAE %s" % self.cnvtxt(addr.get_state())) self.writeln("3 STAE %s"
% self.cnvtxt(addr.get_state()))
if addr.get_postal_code(): if addr.get_postal_code():
self.writeln("3 POST %s" % self.cnvtxt(addr.get_postal_code())) self.writeln("3 POST %s"
% self.cnvtxt(addr.get_postal_code()))
if addr.get_country(): if addr.get_country():
self.writeln("3 CTRY %s" % self.cnvtxt(addr.get_country())) self.writeln("3 CTRY %s"
% self.cnvtxt(addr.get_country()))
if addr.get_phone(): if addr.get_phone():
self.writeln("2 PHON %s" % self.cnvtxt(addr.get_phone())) self.writeln("2 PHON %s"
% self.cnvtxt(addr.get_phone()))
else: else:
text = addr.get_street() text = addr.get_street()
text = addr_append(text,addr.get_city()) text = addr_append(text,addr.get_city())
@ -1110,7 +1141,8 @@ class GedcomWriter(UpdateCallback):
text = addr_append(text,addr.get_country()) text = addr_append(text,addr.get_country())
text = addr_append(text,addr.get_phone()) text = addr_append(text,addr.get_phone())
if text: if text:
self.writeln("2 PLAC %s" % self.cnvtxt(text).replace('\r',' ')) self.writeln("2 PLAC %s"
% self.cnvtxt(text).replace('\r',' '))
if addr.get_note(): if addr.get_note():
self.write_long_text("NOTE",2,self.cnvtxt(addr.get_note())) self.write_long_text("NOTE",2,self.cnvtxt(addr.get_note()))
for srcref in addr.get_source_references(): for srcref in addr.get_source_references():
@ -1123,16 +1155,26 @@ class GedcomWriter(UpdateCallback):
continue continue
self.write_photo(photo,1) self.write_photo(photo,1)
for family in person.get_parent_family_handle_list(): for family_handle in person.get_parent_family_handle_list():
if self.flist.has_key(family[0]): if family_handle in self.flist:
self.writeln("1 FAMC @%s@" % self.fid(family[0])) family = self.db.get_family_from_handle(family_handle)
family_id = family.get_gramps_id()
self.writeln("1 FAMC @%s@" % family_id)
if self.adopt == GedcomInfo.ADOPT_PEDI: if self.adopt == GedcomInfo.ADOPT_PEDI:
if family[1] == RelLib.ChildRef.CHILD_ADOPTED: # Go over all children of the family to find the ref
self.writeln("2 PEDI Adopted") for child_ref in family.get_child_ref_list:
if child_ref.ref == person.handle:
if (child_ref.frel ==
RelLib.ChildRef.CHILD_ADOPTED) \
or (child_ref.mrel \
== RelLib.ChildRef.CHILD_ADOPTED):
self.writeln("2 PEDI Adopted")
break
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
if family_handle != None and self.flist.has_key(family_handle): if (family_handle != None) and (family_handle in self.flist):
self.writeln("1 FAMS @%s@" % self.fid(family_handle)) family = self.db.get_family_from_handle(family_handle)
self.writeln("1 FAMS @%s@" % family.get_gramps_id())
for srcref in person.get_source_references(): for srcref in person.get_source_references():
self.write_source_ref(1,srcref) self.write_source_ref(1,srcref)
@ -1264,19 +1306,23 @@ class GedcomWriter(UpdateCallback):
self.write_photo(photo,2) self.write_photo(photo,2)
def write_ord(self, ord, index): def write_ord(self, ord, index):
if self.private and ord.private:
return
self.writeln('%d %s' % (index, lds_ord_name[ord.get_type()])) self.writeln('%d %s' % (index, lds_ord_name[ord.get_type()]))
self.print_date("%d DATE" % (index + 1), ord.get_date_object()) self.print_date("%d DATE" % (index + 1), ord.get_date_object())
if ord.get_family_handle(): if ord.get_family_handle():
family_id = ord.get_family_handle() family_handle = ord.get_family_handle()
f = self.db.get_family_from_handle(family_id) family = self.db.get_family_from_handle(family_handle)
if f: if family:
self.writeln('%d FAMC @%s@' % (index+1,self.fid(family_id))) self.writeln('%d FAMC @%s@' % (index+1,family.get_gramps_id()))
if ord.get_temple(): if ord.get_temple():
self.writeln('%d TEMP %s' % (index+1,ord.get_temple())) self.writeln('%d TEMP %s' % (index+1,ord.get_temple()))
if ord.get_place_handle(): if ord.get_place_handle():
self.write_place(self.db.get_place_from_handle(ord.get_place_handle()),2) self.write_place(
self.db.get_place_from_handle(ord.get_place_handle()),2)
if ord.get_status() != RelLib.LdsOrd.STATUS_NONE: if ord.get_status() != RelLib.LdsOrd.STATUS_NONE:
self.writeln("2 STAT %s" % self.cnvtxt(lds_status[ord.get_status()])) self.writeln("2 STAT %s" %
self.cnvtxt(lds_status[ord.get_status()]))
if ord.get_note(): if ord.get_note():
self.write_long_text("NOTE",index+1,self.cnvtxt(ord.get_note())) self.write_long_text("NOTE",index+1,self.cnvtxt(ord.get_note()))
for srcref in ord.get_source_references(): for srcref in ord.get_source_references():
@ -1288,11 +1334,13 @@ class GedcomWriter(UpdateCallback):
cal = date.get_calendar() cal = date.get_calendar()
mod = date.get_modifier() mod = date.get_modifier()
if date.get_modifier() == RelLib.Date.MOD_SPAN: if date.get_modifier() == RelLib.Date.MOD_SPAN:
val = "FROM %s TO %s" % (make_date(start,cal,mod), val = "FROM %s TO %s" % (
make_date(date.get_stop_date(),cal,mod)) make_date(start,cal,mod),
make_date(date.get_stop_date(),cal,mod))
elif date.get_modifier() == RelLib.Date.MOD_RANGE: elif date.get_modifier() == RelLib.Date.MOD_RANGE:
val = "BET %s AND %s" % (make_date(start,cal,mod), val = "BET %s AND %s" % (
make_date(date.get_stop_date(),cal,mod)) make_date(start,cal,mod),
make_date(date.get_stop_date(),cal,mod))
else: else:
val = make_date(start,cal,mod) val = make_date(start,cal,mod)
self.writeln("%s %s" % (prefix,val)) self.writeln("%s %s" % (prefix,val))
@ -1300,7 +1348,10 @@ class GedcomWriter(UpdateCallback):
self.writeln("%s %s" % (prefix,self.cnvtxt(date.get_text()))) self.writeln("%s %s" % (prefix,self.cnvtxt(date.get_text())))
def write_person_name(self,name,nick): def write_person_name(self,name,nick):
firstName = self.cnvtxt("%s %s" % (name.get_first_name(),name.get_patronymic())).strip() if self.private and name.private:
return
firstName = self.cnvtxt("%s %s" % (name.get_first_name(),
name.get_patronymic())).strip()
surName = self.cnvtxt(name.get_surname()) surName = self.cnvtxt(name.get_surname())
surName = surName.replace('/','?') surName = surName.replace('/','?')
surPref = self.cnvtxt(name.get_surname_prefix()) surPref = self.cnvtxt(name.get_surname_prefix())
@ -1316,7 +1367,8 @@ class GedcomWriter(UpdateCallback):
if surPref == "": if surPref == "":
self.writeln("1 NAME %s /%s/ %s" % (firstName,surName,suffix)) self.writeln("1 NAME %s /%s/ %s" % (firstName,surName,suffix))
else: else:
self.writeln("1 NAME %s /%s %s/ %s" % (firstName,surPref,surName,suffix)) self.writeln("1 NAME %s /%s %s/ %s" % (firstName,surPref,
surName,suffix))
if firstName: if firstName:
self.writeln("2 GIVN %s" % firstName) self.writeln("2 GIVN %s" % firstName)
@ -1343,14 +1395,26 @@ class GedcomWriter(UpdateCallback):
self.write_source_ref(2,srcref) self.write_source_ref(2,srcref)
def write_source_ref(self,level,ref): def write_source_ref(self,level,ref):
if ref.get_base_handle() == None: if self.private and ref.private:
return return
src_handle = ref.get_reference_handle()
if src_handle == None:
return
src = self.db.get_source_from_handle(src_handle)
if self.private and src.private:
return
self.slist.add(src_handle)
if self.source_refs: if self.source_refs:
self.writeln("%d SOUR @%s@" % # Reference to the source
(level,self.sid(ref.get_base_handle()))) self.writeln("%d SOUR @%s@" % (level,src.get_gramps_id()))
if ref.get_page() != "": if ref.get_page() != "":
self.write_long_text("PAGE",level+1,self.cnvtxt(ref.get_page())) self.write_long_text("PAGE",level+1,
self.cnvtxt(ref.get_page()))
ref_text = ref.get_text() ref_text = ref.get_text()
if ref_text != "" or not ref.get_date_object().is_empty(): if ref_text != "" or not ref.get_date_object().is_empty():
@ -1360,39 +1424,27 @@ class GedcomWriter(UpdateCallback):
pfx = "%d DATE" % (level+2) pfx = "%d DATE" % (level+2)
self.print_date(pfx,ref.get_date_object()) self.print_date(pfx,ref.get_date_object())
else: else:
# Inline source
# We put title, page, and date on the SOUR line. # We put title, page, and date on the SOUR line.
# Not using CONC and CONT because GeneWeb does not support these. # Not using CONC and CONT because GeneWeb does not support these.
# TEXT and NOTE will be ignored by GeneWeb, but we can't # TEXT and NOTE will be ignored by GeneWeb, but we can't
# output paragaphs in SOUR without CONT. # output paragaphs in SOUR without CONT.
txt = "" txt = ""
sbase_handle = ref.get_base_handle() if src.get_title():
if sbase_handle: txt = src.get_title() + ". "
sbase = self.db.get_source_from_handle(sbase_handle)
if sbase and sbase.get_title():
txt = sbase.get_title() + ". "
if ref.get_page(): if ref.get_page():
txt = txt + ref.get_page() + ". " txt = txt + ref.get_page() + ". "
self.g.write("%d SOUR %s" % (level,self.cnvtxt(txt))) self.writeln("%d SOUR %s" % (level,self.cnvtxt(txt)))
if not ref.get_date_object().is_empty(): if not ref.get_date_object().is_empty():
self.print_date("", ref.get_date_object()) self.print_date("", ref.get_date_object())
else: ref_text = ref.get_text()
self.writeln("") if ref_text:
if ref.get_text():
ref_text = ref.get_text()
self.write_long_text("TEXT",level+1,self.cnvtxt(ref_text)) self.write_long_text("TEXT",level+1,self.cnvtxt(ref_text))
if ref.get_note(): if ref.get_note():
self.write_long_text("NOTE",level+1,self.cnvtxt(ref.get_note())) self.write_long_text("NOTE",level+1,self.cnvtxt(ref.get_note()))
mime2ged = {
"image/bmp" : "bmp",
"image/gif" : "gif",
"image/jpeg" : "jpeg",
"image/x-pcx" : "pcx",
"image/tiff" : "tiff",
"audio/x-wav" : "wav"
}
def write_photo(self,photo,level): def write_photo(self,photo,level):
photo_obj_id = photo.get_reference_handle() photo_obj_id = photo.get_reference_handle()
photo_obj = self.db.get_object_from_handle(photo_obj_id) photo_obj = self.db.get_object_from_handle(photo_obj_id)
@ -1431,16 +1483,16 @@ class GedcomWriter(UpdateCallback):
self.writeln('%d FILE %s' % (level+1,os.path.join(self.images_path, self.writeln('%d FILE %s' % (level+1,os.path.join(self.images_path,
basename))) basename)))
if photo_obj.get_note(): if photo_obj.get_note():
self.write_long_text("NOTE",level+1,self.cnvtxt(photo_obj.get_note())) self.write_long_text("NOTE",level+1,
self.cnvtxt(photo_obj.get_note()))
def write_place(self,place,level): def write_place(self,place,level):
if self.private and place.private:
return
place_name = place.get_title() place_name = place.get_title()
self.writeln("%d PLAC %s" % (level,self.cnvtxt(place_name).replace('\r',' '))) self.writeln("%d PLAC %s" %
(level,self.cnvtxt(place_name).replace('\r',' ')))
def fid(self,id):
family = self.db.get_family_from_handle (id)
return family.get_gramps_id ()
def prefn(self,person): def prefn(self,person):
match = _get_int.search(person.get_gramps_id()) match = _get_int.search(person.get_gramps_id())
if match: if match:
@ -1450,10 +1502,6 @@ class GedcomWriter(UpdateCallback):
match = _get_int.search(family.get_gramps_id()) match = _get_int.search(family.get_gramps_id())
if match: if match:
self.writeln('1 REFN %d' % int(match.groups()[0])) self.writeln('1 REFN %d' % int(match.groups()[0]))
def sid(self,handle):
source = self.db.get_source_from_handle(handle)
return source.get_gramps_id()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -622,7 +622,8 @@ class XmlWriter(UpdateCallback):
self.g.write('%s</lds_ord>\n' % sp) self.g.write('%s</lds_ord>\n' % sp)
def dump_source_ref(self,source_ref,index=1): def dump_source_ref(self,source_ref,index=1):
source = self.db.get_source_from_handle(source_ref.get_base_handle()) source = self.db.get_source_from_handle(
source_ref.get_reference_handle())
if source: if source:
p = source_ref.get_page() p = source_ref.get_page()
c = source_ref.get_note() c = source_ref.get_note()

View File

@ -122,7 +122,7 @@ class PersonPreviewFrame(PreviewFrameBase):
if len(person.get_source_references()) > 0: if len(person.get_source_references()) > 0:
psrc_ref = person.get_source_references()[0] psrc_ref = person.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._dbstate.db.get_source_from_handle(psrc_id) psrc = self._dbstate.db.get_source_from_handle(psrc_id)
s += "\n<span weight=\"bold\">%s</span>\n"\ s += "\n<span weight=\"bold\">%s</span>\n"\

View File

@ -126,14 +126,6 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
"""Returns the confidence level""" """Returns the confidence level"""
return self.confidence return self.confidence
def set_base_handle(self,ref):
"""sets the Source instance to which the SourceRef refers"""
self.ref = ref
def get_base_handle(self):
"""returns the Source instance to which the SourceRef refers"""
return self.ref
def set_page(self,page): def set_page(self,page):
"""sets the page indicator of the SourceRef""" """sets the page indicator of the SourceRef"""
self.page = page self.page = page

View File

@ -164,7 +164,7 @@ class ScratchPadAddress(ScratchPadGrampsTypeWrapper):
if len(self._obj.get_source_references()) > 0: if len(self._obj.get_source_references()) > 0:
psrc_ref = self._obj.get_source_references()[0] psrc_ref = self._obj.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<big><b>%s</b></big>\n\n"\ s += "\n<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n" % ( "\t<b>%s:</b>\t%s\n" % (
@ -238,7 +238,7 @@ class ScratchPadEvent(ScratchPadWrapper):
# if len(self._obj.get_source_references()) > 0: # if len(self._obj.get_source_references()) > 0:
# psrc_ref = self._obj.get_source_references()[0] # psrc_ref = self._obj.get_source_references()[0]
# psrc_id = psrc_ref.get_base_handle() # psrc_id = psrc_ref.get_reference_handle()
# psrc = self._db.get_source_from_handle(psrc_id) # psrc = self._db.get_source_from_handle(psrc_id)
# s += "\n<big><b>%s</b></big>\n\n"\ # s += "\n<big><b>%s</b></big>\n\n"\
@ -279,7 +279,7 @@ class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
if len(self._obj.get_source_references()) > 0: if len(self._obj.get_source_references()) > 0:
psrc_ref = self._obj.get_source_references()[0] psrc_ref = self._obj.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<big><b>%s</b></big>\n\n"\ s += "\n<big><b>%s</b></big>\n\n"\
@ -336,7 +336,7 @@ class ScratchPadAttribute(ScratchPadGrampsTypeWrapper):
if len(self._obj.get_source_references()) > 0: if len(self._obj.get_source_references()) > 0:
psrc_ref = self._obj.get_source_references()[0] psrc_ref = self._obj.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<big><b>%s</b></big>\n\n"\ s += "\n<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n" % ( "\t<b>%s:</b>\t%s\n" % (
@ -369,7 +369,7 @@ class ScratchPadFamilyAttribute(ScratchPadGrampsTypeWrapper):
if len(self._obj.get_source_references()) > 0: if len(self._obj.get_source_references()) > 0:
psrc_ref = self._obj.get_source_references()[0] psrc_ref = self._obj.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<big><b>%s</b></big>\n\n"\ s += "\n<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n" % ( "\t<b>%s:</b>\t%s\n" % (
@ -388,13 +388,13 @@ class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper):
ScratchPadGrampsTypeWrapper.__init__(self, db, obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Source Reference") self._type = _("Source Reference")
base = self._db.get_source_from_handle(self._obj.get_base_handle()) base = self._db.get_source_from_handle(self._obj.get_reference_handle())
self._title = base.get_title() self._title = base.get_title()
self._value = self._obj.get_text() self._value = self._obj.get_text()
def tooltip(self): def tooltip(self):
global escape global escape
base = self._db.get_source_from_handle(self._obj.get_base_handle()) base = self._db.get_source_from_handle(self._obj.get_reference_handle())
s = "<big><b>%s</b></big>\n\n"\ s = "<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
@ -466,7 +466,7 @@ class ScratchPadName(ScratchPadGrampsTypeWrapper):
if len(self._obj.get_source_references()) > 0: if len(self._obj.get_source_references()) > 0:
psrc_ref = self._obj.get_source_references()[0] psrc_ref = self._obj.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<big><b>%s</b></big>\n\n"\ s += "\n<big><b>%s</b></big>\n\n"\
@ -552,7 +552,7 @@ class ScratchPersonLink(ScratchPadWrapper):
if len(person.get_source_references()) > 0: if len(person.get_source_references()) > 0:
psrc_ref = person.get_source_references()[0] psrc_ref = person.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<big><b>%s</b></big>\n\n"\ s += "\n<big><b>%s</b></big>\n\n"\

View File

@ -2,7 +2,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2003 Donald N. Allingham # Copyright (C) 2000-2006 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -196,7 +196,7 @@ class PersonTip:
if len(self._obj.get_source_references()) > 0: if len(self._obj.get_source_references()) > 0:
psrc_ref = self._obj.get_source_references()[0] psrc_ref = self._obj.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<span size=\"larger\" weight=\"bold\">%s</span>\n"\ s += "\n<span size=\"larger\" weight=\"bold\">%s</span>\n"\

View File

@ -617,7 +617,7 @@ class ComprehensiveAncestorsReport (Report.Report):
continue continue
self.sourcerefs.append (ref) self.sourcerefs.append (ref)
source_handle = ref.get_base_handle () source_handle = ref.get_reference_handle ()
if source_handle in self.sources: if source_handle in self.sources:
ind = self.sources.index (source_handle) + 1 ind = self.sources.index (source_handle) + 1
else: else:

View File

@ -499,7 +499,7 @@ class DetAncestorReport(Report.Report):
keys.sort() keys.sort()
for key in keys: for key in keys:
srcref = self.sref_map[key] srcref = self.sref_map[key]
sh = srcref.get_base_handle() sh = srcref.get_reference_handle()
base = self.database.get_source_from_handle(sh) base = self.database.get_source_from_handle(sh)
self.doc.start_paragraph('DAR-Endnotes',"%d." % key) self.doc.start_paragraph('DAR-Endnotes',"%d." % key)
@ -544,10 +544,10 @@ class DetAncestorReport(Report.Report):
if not first: if not first:
msg.write(',') msg.write(',')
first = 0 first = 0
ref_base = ref.get_base_handle() ref_base = ref.get_reference_handle()
the_key = 0 the_key = 0
for key in self.sref_map.keys(): for key in self.sref_map.keys():
if ref_base == self.sref_map[key].get_base_handle(): if ref_base == self.sref_map[key].get_reference_handle():
the_key = key the_key = key
break break
if the_key: if the_key:

View File

@ -530,7 +530,8 @@ class DetDescendantReport(Report.Report):
keys.sort() keys.sort()
for key in keys: for key in keys:
srcref = self.sref_map[key] srcref = self.sref_map[key]
base = self.database.get_source_from_handle(srcref.get_base_handle()) base = self.database.get_source_from_handle(
srcref.get_reference_handle())
self.doc.start_paragraph('DDR-Endnotes',"%d." % key) self.doc.start_paragraph('DDR-Endnotes',"%d." % key)
self.doc.write_text(base.get_title()) self.doc.write_text(base.get_title())
@ -574,10 +575,10 @@ class DetDescendantReport(Report.Report):
if not first: if not first:
msg.write(',') msg.write(',')
first = 0 first = 0
ref_base = ref.get_base_handle() ref_base = ref.get_reference_handle()
the_key = 0 the_key = 0
for key in self.sref_map.keys(): for key in self.sref_map.keys():
if ref_base == self.sref_map[key].get_base_handle(): if ref_base == self.sref_map[key].get_reference_handle():
the_key = key the_key = key
break break
if the_key: if the_key:

View File

@ -145,7 +145,8 @@ class FtmAncestorReport(Report.Report):
keys.sort() keys.sort()
for key in keys: for key in keys:
srcref = self.sref_map[key] srcref = self.sref_map[key]
base = self.database.get_source_from_handle(srcref.get_base_handle()) base = self.database.get_source_from_handle(
srcref.get_reference_handle())
self.doc.start_paragraph('FTA-Endnotes',"%d." % key) self.doc.start_paragraph('FTA-Endnotes',"%d." % key)
self.doc.write_text(base.get_title()) self.doc.write_text(base.get_title())
@ -185,10 +186,10 @@ class FtmAncestorReport(Report.Report):
if not first: if not first:
msg.write(',') msg.write(',')
first = 0 first = 0
ref_base = ref.get_base_handle() ref_base = ref.get_reference_handle()
the_key = 0 the_key = 0
for key in self.sref_map.keys(): for key in self.sref_map.keys():
if ref_base == self.sref_map[key].get_base_handle(): if ref_base == self.sref_map[key].get_reference_handle():
the_key = key the_key = key
break break
if the_key: if the_key:

View File

@ -174,7 +174,7 @@ class FtmDescendantReport(Report.Report):
keys.sort() keys.sort()
for key in keys: for key in keys:
srcref = self.sref_map[key] srcref = self.sref_map[key]
base_handle = srcref.get_base_handle() base_handle = srcref.get_reference_handle()
base = self.database.get_source_from_handle(base_handle) base = self.database.get_source_from_handle(base_handle)
self.doc.start_paragraph('FTD-Endnotes',"%d." % key) self.doc.start_paragraph('FTD-Endnotes',"%d." % key)
@ -215,10 +215,10 @@ class FtmDescendantReport(Report.Report):
if not first: if not first:
msg.write(',') msg.write(',')
first = 0 first = 0
ref_base = ref.get_base_handle() ref_base = ref.get_reference_handle()
the_key = 0 the_key = 0
for key in self.sref_map.keys(): for key in self.sref_map.keys():
if ref_base == self.sref_map[key].get_base_handle(): if ref_base == self.sref_map[key].get_reference_handle():
the_key = key the_key = key
break break
if the_key: if the_key:

View File

@ -807,7 +807,7 @@ class GeneWebParser:
self.db.commit_source(source,self.trans) self.db.commit_source(source,self.trans)
self.skeys[source_name] = source.get_handle() self.skeys[source_name] = source.get_handle()
sref = RelLib.SourceRef() sref = RelLib.SourceRef()
sref.set_base_handle(source.get_handle()) sref.set_reference_handle(source.get_handle())
return sref return sref
def decode(self,s): def decode(self,s):

View File

@ -139,7 +139,7 @@ class IndivCompleteReport(Report.Report):
self.normal_cell(name) self.normal_cell(name)
if self.use_srcs: if self.use_srcs:
for s in event.get_source_references(): for s in event.get_source_references():
src_handle = s.get_base_handle() src_handle = s.get_reference_handle()
src = self.database.get_source_from_handle(src_handle) src = self.database.get_source_from_handle(src_handle)
text = "%s [%s]" % (text,src.get_gramps_id()) text = "%s [%s]" % (text,src.get_gramps_id())
self.slist.append(s) self.slist.append(s)
@ -254,7 +254,7 @@ class IndivCompleteReport(Report.Report):
text = name.get_regular_name() text = name.get_regular_name()
if self.use_srcs: if self.use_srcs:
for s in name.get_source_references(): for s in name.get_source_references():
src_handle = s.get_base_handle() src_handle = s.get_reference_handle()
src = self.database.get_source_from_handle(src_handle) src = self.database.get_source_from_handle(src_handle)
text = "%s [%s]" % (text,src.get_gramps_id()) text = "%s [%s]" % (text,src.get_gramps_id())
self.slist.append(s) self.slist.append(s)
@ -342,7 +342,7 @@ class IndivCompleteReport(Report.Report):
for source in self.slist: for source in self.slist:
self.doc.start_row() self.doc.start_row()
s_handle = source.get_base_handle() s_handle = source.get_reference_handle()
src = self.database.get_source_from_handle(s_handle) src = self.database.get_source_from_handle(s_handle)
self.normal_cell(src.get_gramps_id()) self.normal_cell(src.get_gramps_id())
self.normal_cell(src.get_title()) self.normal_cell(src.get_title())
@ -424,7 +424,7 @@ class IndivCompleteReport(Report.Report):
if self.use_srcs: if self.use_srcs:
for s in name.get_source_references(): for s in name.get_source_references():
self.slist.append(s) self.slist.append(s)
src_handle = s.get_base_handle() src_handle = s.get_reference_handle()
src = self.database.get_source_from_handle(src_handle) src = self.database.get_source_from_handle(src_handle)
text = "%s [%s]" % (text,src.get_gramps_id()) text = "%s [%s]" % (text,src.get_gramps_id())
self.normal_cell(text) self.normal_cell(text)

View File

@ -1601,7 +1601,7 @@ class IndividualPage(BasePage):
nshl = [] nshl = []
for nsref in name.get_source_references(): for nsref in name.get_source_references():
self.src_refs.append(nsref) self.src_refs.append(nsref)
nsh = nsref.get_base_handle() nsh = nsref.get_reference_handle()
lnk = (self.cur_name, self.page_title, self.gid) lnk = (self.cur_name, self.page_title, self.gid)
if self.src_list.has_key(nsh): if self.src_list.has_key(nsh):
if self.person.handle not in self.src_list[nsh]: if self.person.handle not in self.src_list[nsh]:
@ -1902,7 +1902,7 @@ class IndividualPage(BasePage):
for sref in event.get_source_references(): for sref in event.get_source_references():
if self.exclude_private and sref.private: if self.exclude_private and sref.private:
continue continue
handle = sref.get_base_handle() handle = sref.get_reference_handle()
gid_list.append(sref) gid_list.append(sref)
if self.src_list.has_key(handle): if self.src_list.has_key(handle):

View File

@ -1165,7 +1165,7 @@ class TestcaseGenerator(Tool.Tool):
self.fill_object(s) self.fill_object(s)
self.db.add_source( s, self.trans) self.db.add_source( s, self.trans)
self.generated_sources.append( s.get_handle()) self.generated_sources.append( s.get_handle())
o.set_base_handle( choice( self.generated_sources)) o.set_reference_handle( choice( self.generated_sources))
if randint(0,1) == 1: if randint(0,1) == 1:
o.set_page( self.rand_text(self.NUMERIC)) o.set_page( self.rand_text(self.NUMERIC))
if randint(0,1) == 1: if randint(0,1) == 1:

View File

@ -324,7 +324,7 @@ class GeneWebWriter:
if reflist: if reflist:
for sr in reflist: for sr in reflist:
sbase = sr.get_base_handle() sbase = sr.get_reference_handle()
if sbase: if sbase:
source = self.db.get_source_from_handle(sbase) source = self.db.get_source_from_handle(sbase)
if source: if source:
@ -545,7 +545,7 @@ class GeneWebWriter:
ret = "" ret = ""
if reflist: if reflist:
for sr in reflist: for sr in reflist:
sbase = sr.get_base_handle() sbase = sr.get_reference_handle()
if sbase: if sbase:
source = self.db.get_source_from_handle(sbase) source = self.db.get_source_from_handle(sbase)
if source: if source: