* src/plugins/WriteGedcom.py: brought up to date

* src/gramps_main.py: beta warning


svn: r3204
This commit is contained in:
Don Allingham 2004-06-09 23:59:03 +00:00
parent 32a24df4d2
commit f0ca1ecf13
6 changed files with 176 additions and 152 deletions

View File

@ -1,3 +1,7 @@
2004-06-09 Don Allingham <dallingham@users.sourceforge.net>
* src/plugins/WriteGedcom.py: brought up to date
* src/gramps_main.py: beta warning
2004-06-02 Alex Roitman <shura@alex.neuro.umn.edu>
* src/MediaView.py: Pass parent to GlobalMediaProperties; typos.
* src/SelectObject.py: Typos.

View File

@ -115,6 +115,8 @@ class DbPrompter:
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = choose.get_filename()
print choose.get_filename()
print choose.get_uri()
if save and os.path.splitext(filename)[1] != ".grdb":
filename = filename + ".grdb"
self.db.read_file(filename)

View File

@ -336,12 +336,9 @@ class Place(SourceNote):
self.alt_loc, self.urls, self.media_list, self.source_list, self.note)
def unserialize(self,data):
try:
(self.id, self.title, self.long, self.lat, self.main_loc,
self.alt_loc, self.urls, self.media_list, self.source_list,
self.note) = data
except:
print data
(self.id, self.title, self.long, self.lat, self.main_loc,
self.alt_loc, self.urls, self.media_list, self.source_list,
self.note) = data
def get_url_list(self):
"""Return the list of URLs"""
@ -2956,7 +2953,6 @@ class GrampsDB:
If no such Person exists, a new Person is added to the database."""
data = self.person_map.get(str(val))
print data
if data:
person = Person()

View File

@ -1,3 +1,4 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2004 Donald N. Allingham
@ -115,12 +116,6 @@ class Gramps:
self.c_details = 6
self.cl = 0
if os.getuid() == 0:
WarningDialog(_("GRAMPS is being run as the 'root' user."),
_("This account is not meant for normal appication use. "
"Running user applications in the administrative account "
"is rarely a wise idea, and can open up potential "
"security risks."))
self.history = []
self.mhistory = []
@ -134,6 +129,16 @@ class Gramps:
self.db.set_pprefix(GrampsCfg.pprefix)
GrampsCfg.loadConfig(self.pref_callback)
if GrampsCfg.get_bool('/apps/gramps/betawarn') == 0:
WarningDialog(_("Use at your own risk"),
_("This is an unstable development version of GRAMPS. "
"It is intended as a technology preview. Do not trust your "
"family database to this development version. This version may "
"contain bugs which could corrupt your database."))
GrampsCfg.set_bool('/apps/gramps/betawarn',1)
self.RelClass = Plugins.relationship_class
self.relationship = self.RelClass(self.db)
self.gtop = gtk.glade.XML(const.gladeFile, "gramps", "gramps")

View File

@ -869,10 +869,13 @@ class GedcomParser:
self.refn[self.person.get_id()] = int(matches[2])
except:
pass
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
elif matches[1] in ["AFN","RFN","_UID"]:
attr = RelLib.Attribute()
attr.setType(matches[1])
attr.setValue(matches[2])
self.person.addAttribute(attr)
elif matches[1] in ["CHAN","ASSO","ANCI","DESI","RIN"]:
self.ignore_sub_junk(2)
elif matches[1] in ["ANCI","DESI","RIN","RFN","_UID"]:
pass
else:
event = RelLib.Event()
n = string.strip(matches[1])

View File

@ -17,7 +17,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
"Export to GEDCOM"
@ -58,7 +57,6 @@ import FrenchRepublic
import GedcomInfo
import Errors
import ansel_utf8
from gettext import gettext as _
from QuestionDialog import ErrorDialog
@ -112,14 +110,18 @@ _get_int = re.compile('([0-9]+)')
#
#
#-------------------------------------------------------------------------
def add_familys_sources(family,slist,private):
for event in family.get_event_list():
if private and event.get_privacy():
continue
for source_ref in event.get_source_references():
sbase = source_ref.get_base_id()
if sbase != None and not slist.has_key(sbase.get_id()):
slist[sbase.get_id()] = 1
def add_familys_sources(db,family_id,slist,private):
family = db.find_family_from_id(family_id)
for event_id in family.get_event_list():
if event_id:
event = db.find_event_from_id(event_id)
if private and event.get_privacy():
continue
for source_ref in event.get_source_references():
sbase = source_ref.get_base_id()
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
for attr in family.get_attribute_list():
if private and attr.get_privacy():
continue
@ -133,18 +135,20 @@ def add_familys_sources(family,slist,private):
#
#
#-------------------------------------------------------------------------
def add_persons_sources(person,slist,private):
def add_persons_sources(db,person,slist,private):
elist = person.get_event_list()[:]
elist.append(person.get_birth())
elist.append(person.get_death())
for event in elist:
if private and event.get_privacy():
continue
for source_ref in event.get_source_references():
sbase = source_ref.get_base_id()
if sbase != None and not slist.has_key(sbase.get_id()):
slist[sbase.get_id()] = 1
elist.append(person.get_birth_id())
elist.append(person.get_death_id())
for event_id in elist:
if event_id:
event = db.find_event_from_id(event_id)
if private and event.get_privacy():
continue
for source_ref in event.get_source_references():
sbase = source_ref.get_base_id()
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():
@ -167,8 +171,8 @@ def add_persons_sources(person,slist,private):
continue
for source_ref in name.get_source_references():
sbase = source_ref.get_base_id()
if sbase != None and not slist.has_key(sbase.get_id()):
slist[sbase.get_id()] = 1
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
#-------------------------------------------------------------------------
#
@ -204,13 +208,13 @@ def sortById(first,second):
#-------------------------------------------------------------------------
def make_date(subdate):
retval = ""
day = subdate.getDay()
mon = subdate.getMonth()
year = subdate.getYear()
mode = subdate.getModeVal()
day_valid = subdate.getDayValid()
mon_valid = subdate.getMonthValid()
year_valid = subdate.getYearValid()
day = subdate.get_day()
mon = subdate.get_month()
year = subdate.get_year()
mode = subdate.get_mode_val()
day_valid = subdate.get_day_valid()
mon_valid = subdate.get_month_valid()
year_valid = subdate.get_year_valid()
if _calmap.has_key(subdate.calendar.NAME):
(mmap,prefix) = _calmap[subdate.calendar.NAME]
@ -286,7 +290,6 @@ def gedcom_date(date):
#
#-------------------------------------------------------------------------
def ged_subdate(date):
if not date.getValid():
return ""
elif not date.getDayValid():
@ -342,7 +345,6 @@ def writeData(database,person):
#-------------------------------------------------------------------------
class GedcomWriter:
"""Writes a GEDCOM file from the passed database"""
def __init__(self,db,person,cl=0,name=""):
self.db = db
self.person = person
@ -359,14 +361,13 @@ class GedcomWriter:
self.pidmap = {}
self.sidval = 0
self.sidmap = {}
self.cl = cl
self.cl = cl
self.name = name
if self.cl:
self.cl_setup()
else:
glade_file = "%s/gedcomexport.glade" % os.path.dirname(__file__)
self.topDialog = gtk.glade.XML(glade_file,"gedcomExport","gramps")
self.topDialog.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
@ -488,8 +489,8 @@ class GedcomWriter:
self.plist[p] = 1
else:
try:
for p in cfilter.apply(self.db, self.db.get_person_id_map().values()):
self.plist[p.get_id()] = 1
for p in cfilter.apply(self.db, self.db.get_person_keys()):
self.plist[p] = 1
except Errors.FilterError, msg:
(m1,m2) = msg.messages()
ErrorDialog(m1,m2)
@ -499,10 +500,10 @@ class GedcomWriter:
self.slist = {}
for key in self.plist.keys():
p = self.db.get_person(key)
add_persons_sources(p,self.slist,self.private)
for family in p.get_family_id_list():
add_familys_sources(family,self.slist,self.private)
self.flist[family.get_id()] = 1
add_persons_sources(self.db,p,self.slist,self.private)
for family_id in p.get_family_id_list():
add_familys_sources(self.db,family_id,self.slist,self.private)
self.flist[family_id] = 1
Utils.destroy_passed_object(obj)
@ -562,10 +563,10 @@ class GedcomWriter:
for key in self.plist.keys():
p = self.db.get_person(key)
add_persons_sources(p,self.slist,self.private)
for family in p.get_family_id_list():
add_familys_sources(family,self.slist,self.private)
self.flist[family.get_id()] = 1
add_persons_sources(self.db,p,self.slist,self.private)
for family_id in p.get_family_id_list():
add_familys_sources(self.db,family_id,self.slist,self.private)
self.flist[family_id] = 1
self.export_data(self.name)
@ -586,7 +587,7 @@ class GedcomWriter:
self.progress.destroy()
return
date = string.split(time.ctime(time.time()))
date = time.ctime(time.time()).split()
self.writeln("0 HEAD")
self.writeln("1 SOUR GRAMPS")
@ -594,7 +595,7 @@ class GedcomWriter:
self.writeln("2 NAME GRAMPS")
if self.dest:
self.writeln("1 DEST %s" % self.dest)
self.writeln("1 DATE %s %s %s" % (date[2],string.upper(date[1]),date[4]))
self.writeln("1 DATE %s %s %s" % (date[2],date[1].upper(),date[4]))
if self.cnvtxt == ansel_utf8.utf8_to_ansel:
self.writeln("1 CHAR ANSEL")
elif self.cnvtxt == iso8859:
@ -697,25 +698,28 @@ class GedcomWriter:
def write_families(self):
nump = float(len(self.flist))
index = 0.0
for key in self.flist.keys():
family = self.db.get_family_id(key)
for family_id in self.flist.keys():
family = self.db.find_family_from_id(family_id)
father_alive = mother_alive = 0
self.writeln("0 @%s@ FAM" % self.fid(family.get_id()))
self.frefn(family)
person = family.get_father_id()
if person != None and self.plist.has_key(person.get_id()):
self.writeln("1 HUSB @%s@" % self.pid(person.get_id()))
self.writeln("0 @%s@ FAM" % self.fid(family_id))
self.frefn(family_id)
person_id = family.get_father_id()
if person_id != None and self.plist.has_key(person_id):
self.writeln("1 HUSB @%s@" % self.pid(person_id))
person = self.db.try_to_find_person_from_id(person_id)
father_alive = person.probably_alive(self.db)
person = family.get_mother_id()
if person != None and self.plist.has_key(person.get_id()):
self.writeln("1 WIFE @%s@" % self.pid(person.get_id()))
if person != None and self.plist.has_key(person_id):
self.writeln("1 WIFE @%s@" % self.pid(person_id))
person = self.db.try_to_find_person_from_id(person_id)
mother_alive = person.probably_alive(self.db)
if not self.restrict or ( not father_alive and not mother_alive ):
self.write_ord("SLGS",family.get_lds_sealing(),1,const.lds_ssealing)
for event in family.get_event_list():
for event_id in family.get_event_list():
event = self.db.find_event_from_id(event_id)
if self.private and event.get_privacy():
continue
name = event.get_name()
@ -734,25 +738,26 @@ class GedcomWriter:
self.dump_event_stats(event)
for person in family.get_child_id_list():
if not self.plist.has_key(person.get_id()):
for person_id in family.get_child_id_list():
if not self.plist.has_key(person_id):
continue
self.writeln("1 CHIL @%s@" % self.pid(person.get_id()))
self.writeln("1 CHIL @%s@" % self.pid(person_id))
person = self.db.try_to_find_person_from_id(person_id)
if self.adopt == GedcomInfo.ADOPT_FTW:
if person.get_main_parents_family_id() == family:
if person.get_main_parents_family_id() == family.get_id():
self.writeln('2 _FREL Natural')
self.writeln('2 _MREL Natural')
else:
for f in person.get_parent_family_id_list():
if f[0] == family:
if f[0] == family.get_id():
self.writeln('2 _FREL %s' % f[2])
self.writeln('2 _MREL %s' % f[1])
break
if self.adopt == GedcomInfo.ADOPT_LEGACY:
for f in person.getAltParentList():
if f[0] == family:
self.writeln('2 _STAT %s' % f[2])
break
for f in person.get_parent_family_id_list():
if f[0] == family.get_id():
self.writeln('2 _STAT %s' % f[2])
break
index = index + 1
if index % 100 == 0 and not self.cl:
@ -766,7 +771,7 @@ class GedcomWriter:
nump = float(len(self.slist))
index = 0.0
for key in self.slist.keys():
source = self.db.get_source(key)
source = self.db.try_to_find_source_from_id(key)
self.writeln("0 @%s@ SOUR" % self.sid(source.get_id()))
if source.get_title():
self.writeln("1 TITL %s" % fmtline(self.cnvtxt(source.get_title()),248,1,self.nl))
@ -774,8 +779,8 @@ class GedcomWriter:
self.writeln("1 AUTH %s" % self.cnvtxt(source.get_author()))
if source.get_publication_info():
self.writeln("1 PUBL %s" % self.cnvtxt(source.get_publication_info()))
if source.getAbbrev():
self.writeln("1 ABBR %s" % self.cnvtxt(source.getAbbrev()))
if source.get_abbreviation():
self.writeln("1 ABBR %s" % self.cnvtxt(source.get_abbreviation()))
if source.get_note():
self.write_long_text("NOTE",1,self.cnvtxt(source.get_note()))
index = index + 1
@ -820,16 +825,17 @@ class GedcomWriter:
self.writeln("1 SEX F")
if not restricted:
birth = person.get_birth()
if not (self.private and birth.get_privacy()):
if not birth.get_date_object().is_empty() or birth.get_place_name():
birth_id = person.get_birth_id()
birth = self.db.find_event_from_id(birth_id)
if birth_id and not (self.private and birth.get_privacy()):
if not birth.get_date_object().is_empty() or birth.get_place_id():
self.writeln("1 BIRT")
self.dump_event_stats(birth)
death = person.get_death()
if not (self.private and death.get_privacy()):
if not death.get_date_object().is_empty() or death.get_place_name():
death_id = person.get_death_id()
death = self.db.find_event_from_id(death_id)
if death_id and not (self.private and death.get_privacy()):
if not death.get_date_object().is_empty() or death.get_place_id():
self.writeln("1 DEAT")
self.dump_event_stats(death)
@ -839,7 +845,8 @@ class GedcomWriter:
self.write_ord("ENDL",person.get_lds_endowment(),1,const.lds_baptism)
self.write_ord("SLGC",person.get_lds_sealing(),1,const.lds_csealing)
for event in person.get_event_list():
for event_id in person.get_event_list():
event = self.db.find_event_from_id(event_id)
if self.private and event.get_privacy():
continue
name = event.get_name()
@ -854,8 +861,8 @@ class GedcomWriter:
self.writeln('1 ADOP')
fam = None
for f in person.get_parent_family_id_list():
mrel = string.lower(f[1])
frel = string.lower(f[2])
mrel = f[1].lower()
frel = f[2].lower()
if mrel=="adopted" or frel=="adopted":
fam = f[0]
break
@ -880,8 +887,8 @@ class GedcomWriter:
self.writeln('1 ADOP')
fam = None
for f in person.get_parent_family_id_list():
mrel = string.lower(f[1])
frel = string.lower(f[2])
mrel = f[1].lower()
frel = f[2].lower()
if mrel=="adopted" or frel=="adopted":
fam = f[0]
break
@ -898,6 +905,11 @@ class GedcomWriter:
if self.private and attr.get_privacy():
continue
name = attr.get_type()
if name in ["AFN", "RFN", "_UID"]:
self.writeln("1 %s %s" % ( name, attr.get_value()))
continue
if const.personalConstantAttributes.has_key(name):
val = const.personalConstantAttributes[name]
else:
@ -957,7 +969,7 @@ class GedcomWriter:
dirname = os.path.join (self.dirname, self.images_path)
basename = os.path.basename (path)
self.writeln('2 FILE %s' % os.path.join(self.images_path,
basename))
basename))
try:
os.mkdir (dirname)
except:
@ -971,15 +983,15 @@ class GedcomWriter:
"rb").xreadlines ())
for family in person.get_parent_family_id_list():
if self.flist.has_key(family[0].get_id()):
self.writeln("1 FAMC @%s@" % self.fid(family[0].get_id()))
if self.flist.has_key(family[0]):
self.writeln("1 FAMC @%s@" % self.fid(family[0]))
if self.adopt == GedcomInfo.ADOPT_PEDI:
if string.lower(family[1]) == "adopted":
if family[1].lower() == "adopted":
self.writeln("2 PEDI Adopted")
for family in person.get_family_id_list():
if family != None and self.flist.has_key(family.get_id()):
self.writeln("1 FAMS @%s@" % self.fid(family.get_id()))
for family_id in person.get_family_id_list():
if family_id != None and self.flist.has_key(family_id):
self.writeln("1 FAMS @%s@" % self.fid(family_id))
if not restricted:
if self.obje:
@ -1003,7 +1015,7 @@ class GedcomWriter:
def write_conc_ok(self,tag,level,note):
prefix = "%d %s" % (level,tag)
textlines = string.split(note,'\n')
textlines = note.split('\n')
if len(note) == 0:
self.writeln(prefix)
else:
@ -1032,7 +1044,7 @@ class GedcomWriter:
def write_conc_broken(self,tag,level,note):
prefix = "%d %s" % (level,tag)
textlines = string.split(note,'\n')
textlines = note.split('\n')
if len(note) == 0:
self.writeln(prefix)
else:
@ -1062,8 +1074,9 @@ class GedcomWriter:
def dump_event_stats(self,event):
dateobj = event.get_date_object()
self.print_date("2 DATE",dateobj)
if event.get_place_name():
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(event.get_place_name()),'\r',' '))
if event.get_place_id():
place_name = self.db.try_to_find_place_from_id(event.get_place_id()).get_title()
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(place_name),'\r',' '))
if event.get_cause():
self.writeln("2 CAUS %s" % self.cnvtxt(event.get_cause()))
if event.get_note():
@ -1080,8 +1093,9 @@ class GedcomWriter:
self.writeln('%d FAMC @%s@' % (index+1,self.fid(ord.get_family_id().get_id())))
if ord.get_temple():
self.writeln('%d TEMP %s' % (index+1,ord.get_temple()))
if ord.get_place_name():
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(ord.get_place_name()),'\r',' '))
if ord.get_place_id():
place_name = self.db.try_to_find_place_from_id(ord.get_place_id()).get_title()
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(place_name),'\r',' '))
if ord.get_status() != 0:
self.writeln("2 STAT %s" % self.cnvtxt(statlist[ord.get_status()]))
if ord.get_note():
@ -1095,7 +1109,7 @@ class GedcomWriter:
if val:
self.writeln("%s %s" % (prefix,self.cnvtxt(val)))
elif not date.is_empty ():
if date.isRange():
if date.is_range():
val = "FROM %s TO %s" % (make_date(start),
make_date(date.get_stop_date()))
else:
@ -1151,7 +1165,7 @@ class GedcomWriter:
if self.source_refs:
self.writeln("%d SOUR @%s@" %
(level,self.sid(ref.get_base_id().get_id())))
(level,self.sid(ref.get_base_id())))
if ref.get_page() != "":
self.write_long_text("PAGE",level+1,self.cnvtxt(ref.get_page()))
@ -1178,7 +1192,7 @@ class GedcomWriter:
if not ref.get_date().is_empty():
self.print_date("", ref.get_date())
else:
self.writeln("")
self.writeln("")
if ref.get_text():
ref_text = ref.get_text()
self.write_long_text("TEXT",level+1,self.cnvtxt(ref_text))
@ -1194,8 +1208,8 @@ class GedcomWriter:
if match:
self.writeln('1 REFN %d' % int(match.groups()[0]))
def frefn(self,family):
match = _get_int.search(family.get_id())
def frefn(self,family_id):
match = _get_int.search(family_id)
if match:
self.writeln('1 REFN %d' % int(match.groups()[0]))