* src/docgen/ODFDoc.py: Handle exception when file is not writeable

* src/docgen/ODSDoc.py: Handle exception when file is not writeable
* src/docgen/OpenOfficeDoc.py: Handle exception when file is not writeable
* src/docgen/OpenSpreadSheet.py: Handle exception when file is not writeable
* src/plugins/AncestorChart2.py: Remove Title option
* src/plugins/DecendChart.py: Remove Title option

svn: r6961
This commit is contained in:
Brian Matherly 2006-06-24 17:22:34 +00:00
parent d6253f07e7
commit d42baab67c
7 changed files with 48 additions and 31 deletions

View File

@ -1,3 +1,11 @@
2006-06-25 Brian Matherly <brian@gramps-project.org>
* src/docgen/ODFDoc.py: Handle exception when file is not writeable
* src/docgen/ODSDoc.py: Handle exception when file is not writeable
* src/docgen/OpenOfficeDoc.py: Handle exception when file is not writeable
* src/docgen/OpenSpreadSheet.py: Handle exception when file is not writeable
* src/plugins/AncestorChart2.py: Remove Title option
* src/plugins/DecendChart.py: Remove Title option
2006-06-23 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_WriteGedcom.py: Prevent writing empty value tags.
* src/images/Makefile.am (dist_pkgdata_DATA): Comment out map images.

View File

@ -46,6 +46,7 @@ import ImgManip
import FontScale
import Mime
import Utils
import Errors
#-------------------------------------------------------------------------
#
@ -512,8 +513,14 @@ class ODFDoc(BaseDoc.BaseDoc):
zfile.writestr(zipinfo,data)
def _write_zip(self):
zfile = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
try:
zfile = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
raise Errors.ReportError(errmsg)
except:
raise Errors.ReportError(_("Could not create %s") % self.filename)
t = time.localtime(time.time())[:6]
self._add_zip(zfile,"META-INF/manifest.xml",self.mfile.getvalue(),t)

View File

@ -210,7 +210,14 @@ class ODSDoc(SpreadSheetDoc):
self.f.write('<table:covered-table-cell/>\n')
def _write_zip(self):
file = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
try:
file = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
raise Errors.ReportError(errmsg)
except:
raise Errors.ReportError(_("Could not create %s") % self.filename)
file.write(self.manifest_xml,str("META-INF/manifest.xml"))
file.write(self.content_xml,str("content.xml"))
file.write(self.meta_xml,str("meta.xml"))

View File

@ -46,6 +46,7 @@ import ImgManip
import FontScale
import Mime
import Utils
import Errors
#-------------------------------------------------------------------------
#
@ -478,7 +479,13 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
zfile.writestr(zipinfo,data)
def _write_zip(self):
zfile = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
try:
zfile = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
raise Errors.ReportError(errmsg)
except:
raise Errors.ReportError(_("Could not create %s") % self.filename)
t = time.localtime(time.time())[:6]

View File

@ -203,8 +203,14 @@ class OpenSpreadSheet(SpreadSheetDoc):
self.f.write('<table:covered-table-cell/>\n')
def _write_zip(self):
the_file = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
try:
the_file = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
raise Errors.ReportError(errmsg)
except:
raise Errors.ReportError(_("Could not create %s") % self.filename)
the_file.write(self.manifest_xml,str("META-INF/manifest.xml"))
the_file.write(self.content_xml,str("content.xml"))
the_file.write(self.meta_xml,str("meta.xml"))

View File

@ -47,6 +47,7 @@ from SubstKeywords import SubstKeywords
from PluginUtils import register_report
from ReportBase import Report, ReportUtils, ReportOptions, \
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
import NameDisplay
pt2cm = ReportUtils.pt2cm
cm2pt = ReportUtils.cm2pt
@ -192,7 +193,9 @@ class AncestorChart(Report):
self.display = options_class.handler.options_dict['dispf']
self.force_fit = options_class.handler.options_dict['singlep']
self.compress = options_class.handler.options_dict['compress']
self.title = options_class.handler.options_dict['title'].strip()
name = NameDisplay.displayer.display_formal(person)
self.title = _("Ancestor Graph for %s") % name
self.map = {}
self.text = {}
@ -433,7 +436,6 @@ class AncestorChartOptions(ReportOptions):
self.options_dict = {
'singlep' : 1,
'compress' : 1,
'title' : '',
}
self.options_help = {
'singlep' : ("=0/1","Whether to scale to fit on a single page.",
@ -442,8 +444,6 @@ class AncestorChartOptions(ReportOptions):
'compress' : ("=0/1","Whether to compress chart.",
["Do not compress chart","Compress chart"],
True),
'title' : ("=str","Title string for the report",
"Whatever String You Wish"),
}
def enable_options(self):
@ -474,20 +474,12 @@ class AncestorChartOptions(ReportOptions):
self.compress.set_active(self.options_dict['compress'])
dialog.add_option('',self.compress)
self.title_box = gtk.Entry()
if self.options_dict['title']:
self.title_box.set_text(self.options_dict['title'])
else:
self.title_box.set_text(dialog.get_header(dialog.person.get_primary_name().get_name()))
dialog.add_option(_('Title'),self.title_box)
def parse_user_options(self,dialog):
"""
Parses the custom options that we have added.
"""
self.options_dict['singlep'] = int(self.scale.get_active ())
self.options_dict['compress'] = int(self.compress.get_active ())
self.options_dict['title'] = unicode(self.title_box.get_text()).strip()
def make_default_style(self,default_style):
"""Make the default output style for the Ancestor Chart report."""

View File

@ -131,8 +131,10 @@ class DescendChart(Report):
= options_class.get_report_generations()
self.display = options_class.handler.options_dict['dispf']
self.force_fit = options_class.handler.options_dict['singlep']
self.title = options_class.handler.options_dict['title'].strip()
self.max_gen = options_class.handler.options_dict['maxgen']
name = NameDisplay.displayer.display_formal(person)
self.title = _("Descendant Chart for %s") % name
self.map = {}
self.text = {}
@ -387,15 +389,12 @@ class DescendChartOptions(ReportOptions):
# Options specific for this report
self.options_dict = {
'singlep' : 1,
'title' : '',
'maxgen' : 32,
}
self.options_help = {
'singlep' : ("=0/1","Whether to scale to fit on a single page.",
["Do not scale to fit","Scale to fit"],
True),
'title' : ("=str","Title string for the report",
"Whatever String You Wish"),
}
def enable_options(self):
@ -416,14 +415,6 @@ class DescendChartOptions(ReportOptions):
"""
dialog.get_report_extra_textbox_info = self.get_textbox_info
self.title_box = gtk.Entry()
if self.options_dict['title']:
self.title_box.set_text(self.options_dict['title'])
else:
name = NameDisplay.displayer.display(dialog.person)
self.title_box.set_text(dialog.get_header(name))
dialog.add_option(_('Title'),self.title_box)
self.scale = gtk.CheckButton(_('Sc_ale to fit on a single page'))
self.scale.set_active(self.options_dict['singlep'])
dialog.add_option('',self.scale)
@ -438,7 +429,6 @@ class DescendChartOptions(ReportOptions):
Parses the custom options that we have added.
"""
self.options_dict['singlep'] = int(self.scale.get_active ())
self.options_dict['title'] = unicode(self.title_box.get_text()).strip()
self.options_dict['maxgen'] = int(self.max_gen.get_value_as_int())
def make_default_style(self,default_style):