From 6f6d2f5ad2d2566249e8e5ccca9d9b8fec15545f Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sat, 22 Apr 2006 05:13:21 +0000 Subject: [PATCH] 2006-04-21 Alex Roitman * src/PluginUtils/_ReportUtils.py (buried_str): Typo. * src/plugins/DetDescendantReport.py (write_children): Use child_refs. * src/plugins/DetAncestralReport.py (write_children): Use child_refs. * src/plugins/IndivComplete.py (write_fact): Use new event type. * src/docgen/KwordDoc.py (KwordDoc.close): Use tarile. svn: r6413 --- gramps2/ChangeLog | 7 +++++ gramps2/src/PluginUtils/_ReportUtils.py | 2 +- gramps2/src/docgen/KwordDoc.py | 33 ++++++++++++++-------- gramps2/src/plugins/DetAncestralReport.py | 5 ++-- gramps2/src/plugins/DetDescendantReport.py | 11 ++++---- gramps2/src/plugins/IndivComplete.py | 3 +- 6 files changed, 40 insertions(+), 21 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index b95723eb4..14b24323b 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2006-04-21 Alex Roitman + * src/PluginUtils/_ReportUtils.py (buried_str): Typo. + * src/plugins/DetDescendantReport.py (write_children): Use child_refs. + * src/plugins/DetAncestralReport.py (write_children): Use child_refs. + * src/plugins/IndivComplete.py (write_fact): Use new event type. + * src/docgen/KwordDoc.py (KwordDoc.close): Use tarile. + 2006-04-21 Don Allingham * src/StartupDialog.py: fix close * src/plugins/Desbrowser.py: Use ActivPersonTool diff --git a/gramps2/src/PluginUtils/_ReportUtils.py b/gramps2/src/PluginUtils/_ReportUtils.py index eda9f59f1..8f488263d 100644 --- a/gramps2/src/PluginUtils/_ReportUtils.py +++ b/gramps2/src/PluginUtils/_ReportUtils.py @@ -1989,7 +1989,7 @@ def buried_str(database,person,person_name=None,empty_date="",empty_place=""): burial = None for event_ref in person.get_event_ref_list(): event = database.get_event_from_handle(event_ref.ref) - if event and int(event.get_type()) == RelLib.Event.BURIAL: + if event and int(event.get_type()) == RelLib.EventType.BURIAL: burial = event break diff --git a/gramps2/src/docgen/KwordDoc.py b/gramps2/src/docgen/KwordDoc.py index 563f7181b..f5b789d31 100644 --- a/gramps2/src/docgen/KwordDoc.py +++ b/gramps2/src/docgen/KwordDoc.py @@ -27,8 +27,8 @@ #------------------------------------------------------------------------ import time import cStringIO -import gzip import os +import tarfile from gettext import gettext as _ #------------------------------------------------------------------------ @@ -38,7 +38,6 @@ from gettext import gettext as _ #------------------------------------------------------------------------ import BaseDoc import Errors -from TarFile import TarFile from PluginUtils import register_text_doc import ImgManip import Mime @@ -254,7 +253,7 @@ class KwordDoc(BaseDoc.BaseDoc): self.f.write('\n') try: - tar = TarFile(self.filename) + archive = tarfile.open(self.filename,'w:gz') except IOError, msg: text = _("Could not open %s") % self.filename Errors.ReportError(text + "\n" + str(msg)) @@ -262,15 +261,27 @@ class KwordDoc(BaseDoc.BaseDoc): except: Errors.ReportError(_("Could not open %s") % self.filename) return - - tar.add_file("documentinfo.xml",self.mtime,self.m) - tar.add_file("maindoc.xml",self.mtime,self.f) - for filedata in self.media_list: - f = open(filedata[0],"r") - tar.add_file(filedata[1],self.mtime,f) - f.close() - tar.close() + tarinfo = tarfile.TarInfo('documentinfo.xml') + tarinfo.size = len(self.m.getvalue()) + tarinfo.mtime = self.mtime + tarinfo.uid = os.getuid() + tarinfo.gid = os.getgid() + self.m.seek(0) + archive.addfile(tarinfo,self.m) + + tarinfo = tarfile.TarInfo('maindoc.xml') + tarinfo.size = len(self.f.getvalue()) + tarinfo.mtime = self.mtime + tarinfo.uid = os.getuid() + tarinfo.gid = os.getgid() + self.f.seek(0) + archive.addfile(tarinfo,self.f) + + for filedata in self.media_list: + archive.add(filedata[0]) + + archive.close() self.f.close() self.m.close() diff --git a/gramps2/src/plugins/DetAncestralReport.py b/gramps2/src/plugins/DetAncestralReport.py index d96ea4486..3eecae67a 100644 --- a/gramps2/src/plugins/DetAncestralReport.py +++ b/gramps2/src/plugins/DetAncestralReport.py @@ -382,7 +382,7 @@ class DetAncestorReport(Report.Report): """ List children. """ - if not family.get_child_handle_list(): + if not family.get_child_ref_list(): return mother_handle = family.get_mother_handle() @@ -405,7 +405,8 @@ class DetAncestorReport(Report.Report): self.doc.end_paragraph() cnt = 1 - for child_handle in family.get_child_handle_list(): + for child_ref in family.get_child_ref_list(): + child_handle = child_ref.ref child = self.database.get_person_from_handle(child_handle) child_name = _nd.display(child) diff --git a/gramps2/src/plugins/DetDescendantReport.py b/gramps2/src/plugins/DetDescendantReport.py index a60a1a3aa..b39da9743 100644 --- a/gramps2/src/plugins/DetDescendantReport.py +++ b/gramps2/src/plugins/DetDescendantReport.py @@ -150,10 +150,10 @@ class DetDescendantReport(Report.Report): index = 0 for family_handle in person.get_family_handle_list(): family = self.database.get_family_from_handle(family_handle) - for child_handle in family.get_child_handle_list(): - child = self.database.get_family_from_handle(child_handle) + for child_ref in family.get_child_ref_list(): + child = self.database.get_family_from_handle(child_ref.ref) ix = max(self.map.keys()) - self.apply_filter(child_handle, ix+1, + self.apply_filter(child_ref.ref, ix+1, pid+HENRY[index], cur_gen+1) index += 1 @@ -410,7 +410,7 @@ class DetDescendantReport(Report.Report): """ List children. """ - if not family.get_child_handle_list(): + if not family.get_child_ref_list(): return mother_handle = family.get_mother_handle() @@ -433,7 +433,8 @@ class DetDescendantReport(Report.Report): self.doc.end_paragraph() cnt = 1 - for child_handle in family.get_child_handle_list(): + for child_ref in family.get_child_ref_list(): + child_handle = child_ref.ref child = self.database.get_person_from_handle(child_handle) child_name = _nd.display(child) diff --git a/gramps2/src/plugins/IndivComplete.py b/gramps2/src/plugins/IndivComplete.py index 955b78eee..f3f4927cd 100644 --- a/gramps2/src/plugins/IndivComplete.py +++ b/gramps2/src/plugins/IndivComplete.py @@ -113,8 +113,7 @@ class IndivCompleteReport(Report.Report): def write_fact(self,event): if event == None: return - evtType = event.get_type() - name = Utils.format_event( evtType ) + name = str(event.get_type()) date = DateHandler.get_date(event) place_handle = event.get_place_handle() if place_handle: