diff --git a/ChangeLog b/ChangeLog index e713c5f61..f1f81d6d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-06-25 Brian Matherly + * 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 * src/GrampsDb/_WriteGedcom.py: Prevent writing empty value tags. * src/images/Makefile.am (dist_pkgdata_DATA): Comment out map images. diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index bf465cade..bcd3fe848 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -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) diff --git a/src/docgen/ODSDoc.py b/src/docgen/ODSDoc.py index cd4c8d3bc..358eecb1b 100644 --- a/src/docgen/ODSDoc.py +++ b/src/docgen/ODSDoc.py @@ -210,7 +210,14 @@ class ODSDoc(SpreadSheetDoc): self.f.write('\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")) diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index 419f1cf1e..9dde9a9b4 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -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] diff --git a/src/docgen/OpenSpreadSheet.py b/src/docgen/OpenSpreadSheet.py index c2c44cf5b..31bccbedf 100644 --- a/src/docgen/OpenSpreadSheet.py +++ b/src/docgen/OpenSpreadSheet.py @@ -203,8 +203,14 @@ class OpenSpreadSheet(SpreadSheetDoc): self.f.write('\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")) diff --git a/src/plugins/AncestorChart2.py b/src/plugins/AncestorChart2.py index e5a73de84..e18a12eda 100644 --- a/src/plugins/AncestorChart2.py +++ b/src/plugins/AncestorChart2.py @@ -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.""" diff --git a/src/plugins/DescendChart.py b/src/plugins/DescendChart.py index ce152bccf..40377203d 100644 --- a/src/plugins/DescendChart.py +++ b/src/plugins/DescendChart.py @@ -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):