Change file extentions in reports when different filetype is chosen
svn: r1534
This commit is contained in:
parent
4d5f13b00e
commit
4247f38dbb
@ -20,13 +20,17 @@
|
||||
|
||||
class ReportError(Exception):
|
||||
"""Error used to report Report errors"""
|
||||
def __init__(self,value):
|
||||
def __init__(self,value,value2=""):
|
||||
Exception.__init__(self)
|
||||
self.value = value
|
||||
self.value2 = value2
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def messages(self):
|
||||
return (self.value,self.value2)
|
||||
|
||||
class GedcomError(Exception):
|
||||
"""Error used to report GEDCOM errors"""
|
||||
def __init__(self,value):
|
||||
|
@ -106,9 +106,9 @@ class ErrorDialog:
|
||||
|
||||
label1 = self.xml.get_widget('label1')
|
||||
label2 = self.xml.get_widget('label2')
|
||||
label1.set_text('<span weight="bold" size="larger">%s</span>' % msg1)
|
||||
label1.set_text('<span weight="bold" size="larger">%s</span>' % str(msg1))
|
||||
label1.set_use_markup(gtk.TRUE)
|
||||
label2.set_text(msg2)
|
||||
label2.set_text(str(msg2))
|
||||
self.top.show()
|
||||
self.top.run()
|
||||
self.top.destroy()
|
||||
|
@ -451,6 +451,12 @@ class ReportDialog:
|
||||
|
||||
self.output_notebook.set_current_page(self.notebook_page)
|
||||
|
||||
if not self.get_target_is_directory():
|
||||
fname = self.target_fileentry.get_full_path(0)
|
||||
(path,ext) = os.path.splitext(fname)
|
||||
fname = path + obj.get_data('ext')
|
||||
self.target_fileentry.set_filename(fname)
|
||||
|
||||
# Does this report format use styles?
|
||||
if self.style_button:
|
||||
self.style_button.set_sensitive(obj.get_data("styles"))
|
||||
|
@ -63,7 +63,14 @@ class AbiWordDoc(TextDoc.TextDoc):
|
||||
else:
|
||||
self.filename = filename
|
||||
|
||||
self.f = open(self.filename,"w")
|
||||
try:
|
||||
self.f = open(self.filename,"w")
|
||||
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)
|
||||
|
||||
self.f.write('<?xml version="1.0"?>\n')
|
||||
self.f.write('<!DOCTYPE abiword PUBLIC "-//ABISOURCE//DTD AWML')
|
||||
self.f.write('1.0 Strict//EN" "http://www.abisource.com/awml.dtd">\n')
|
||||
|
@ -217,7 +217,14 @@ class HtmlDoc(TextDoc.TextDoc):
|
||||
|
||||
self.base = os.path.dirname(self.filename)
|
||||
|
||||
self.f = open(self.filename,"w")
|
||||
try:
|
||||
self.f = open(self.filename,"w")
|
||||
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)
|
||||
|
||||
if self.meta:
|
||||
match = t_keyword_line_re.match(self.file_header)
|
||||
if match:
|
||||
@ -319,9 +326,15 @@ class HtmlDoc(TextDoc.TextDoc):
|
||||
if name == 'template.html':
|
||||
continue
|
||||
fname = '%s/%s' % (self.base,name)
|
||||
f = open(fname, 'wb')
|
||||
f.write(self.map[name].read())
|
||||
f.close()
|
||||
try:
|
||||
f = open(fname, 'wb')
|
||||
f.write(self.map[name].read())
|
||||
f.close()
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") % fname, msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") % fname)
|
||||
|
||||
def add_photo(self,name,pos,x,y):
|
||||
self.empty = 0
|
||||
|
@ -74,7 +74,14 @@ class LaTeXDoc(TextDoc.TextDoc):
|
||||
self.filename = filename + ".tex"
|
||||
else:
|
||||
self.filename = filename
|
||||
self.f = open(self.filename,"w")
|
||||
|
||||
try:
|
||||
self.f = open(self.filename,"w")
|
||||
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)
|
||||
|
||||
# Font size control seems to be limited. For now, ignore
|
||||
# any style constraints, and use 12pt has the default
|
||||
|
@ -72,6 +72,9 @@ class OpenDrawDoc(DrawDoc.DrawDoc):
|
||||
try:
|
||||
self.content_xml = tempfile.mktemp()
|
||||
self.f = open(self.content_xml,"wb")
|
||||
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)
|
||||
|
||||
|
@ -77,8 +77,11 @@ class OpenOfficeDoc(TextDoc.TextDoc):
|
||||
try:
|
||||
self.content_xml = tempfile.mktemp()
|
||||
self.f = open(self.content_xml,"wb")
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") % self.content_xml, msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError("Could not create %s" % self.filename)
|
||||
raise Errors.ReportError("Could not create %s" % self.content_xml)
|
||||
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<office:document-content ')
|
||||
@ -333,7 +336,14 @@ class OpenOfficeDoc(TextDoc.TextDoc):
|
||||
|
||||
def _write_styles_file(self):
|
||||
self.styles_xml = tempfile.mktemp()
|
||||
self.f = open(self.styles_xml,"wb")
|
||||
|
||||
try:
|
||||
self.f = open(self.styles_xml,"wb")
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") % self.styles_xml, msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError((_("Could not create %s") % self.styles_xml)
|
||||
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<office:document-styles ')
|
||||
@ -505,7 +515,15 @@ class OpenOfficeDoc(TextDoc.TextDoc):
|
||||
|
||||
def _write_manifest(self):
|
||||
self.manifest_xml = tempfile.mktemp()
|
||||
self.f = open(self.manifest_xml,"wb")
|
||||
|
||||
try:
|
||||
self.f = open(self.manifest_xml,"wb")
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") % self.manifest_xml, msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") % self.manifest_xml)
|
||||
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<manifest:manifest ')
|
||||
self.f.write('xmlns:manifest="http://openoffice.org/2001/manifest">')
|
||||
@ -533,7 +551,15 @@ class OpenOfficeDoc(TextDoc.TextDoc):
|
||||
def _write_meta_file(self):
|
||||
name = self.name
|
||||
self.meta_xml = tempfile.mktemp()
|
||||
self.f = open(self.meta_xml,"wb")
|
||||
|
||||
try:
|
||||
self.f = open(self.meta_xml,"wb")
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") % self.meta_xml, msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") % self.meta_xml)
|
||||
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<office:document-meta ')
|
||||
self.f.write('xmlns:office="http://openoffice.org/2000/office" ')
|
||||
|
@ -74,7 +74,13 @@ class PSDrawDoc(DrawDoc.DrawDoc):
|
||||
else:
|
||||
self.filename = filename
|
||||
|
||||
self.f = open(self.filename,"w")
|
||||
try:
|
||||
self.f = open(self.filename,"w")
|
||||
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)
|
||||
|
||||
self.f.write('%!PS-Adobe-3.0\n')
|
||||
self.f.write('%%LanguageLevel: 2\n')
|
||||
|
@ -150,7 +150,13 @@ class PdfDoc(TextDoc.TextDoc):
|
||||
self.in_table = 0
|
||||
|
||||
def close(self):
|
||||
self.doc.build(self.story)
|
||||
try:
|
||||
self.doc.build(self.story)
|
||||
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)
|
||||
|
||||
def end_page(self):
|
||||
self.story.append(PageBreak())
|
||||
|
@ -78,7 +78,12 @@ class PdfDrawDoc(DrawDoc.DrawDoc):
|
||||
self.f.setAuthor(self.name)
|
||||
|
||||
def close(self):
|
||||
self.f.save()
|
||||
try:
|
||||
self.f.save()
|
||||
except IOError,msg:
|
||||
raise Errors.ReportError(_("Could not create %s") % self.filename,msg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") % self.filename)
|
||||
|
||||
def start_paragraph(self,style_name):
|
||||
pass
|
||||
|
@ -64,7 +64,14 @@ class RTFDoc(TextDoc.TextDoc):
|
||||
else:
|
||||
self.filename = filename
|
||||
|
||||
self.f = open(self.filename,"w")
|
||||
try:
|
||||
self.f = open(self.filename,"w")
|
||||
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)
|
||||
|
||||
self.f.write('{\\rtf1\\ansi\\ansicpg1252\\deff0\n')
|
||||
self.f.write('{\\fonttbl\n')
|
||||
self.f.write('{\\f0\\froman\\fcharset0\\fprq0 Times New Roman;}\n')
|
||||
|
@ -34,6 +34,7 @@ import Plugins
|
||||
from intl import gettext as _
|
||||
import TextDoc
|
||||
import DrawDoc
|
||||
import Errors
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -74,7 +75,13 @@ class SvgDrawDoc(DrawDoc.DrawDoc):
|
||||
name = "%s-%d.svg" % (self.root,self.page)
|
||||
else:
|
||||
name = "%s.svg" % self.root
|
||||
self.f = open(name,"w")
|
||||
|
||||
try:
|
||||
self.f = open(name,"w")
|
||||
except IOError,msg:
|
||||
raise Errors.ReportError(_("Could not create %s") % name, msg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") % name)
|
||||
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n')
|
||||
self.f.write('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" ')
|
||||
|
@ -126,11 +126,7 @@ class AncestorChart:
|
||||
self.print_page(index, generation, page)
|
||||
page = page + 1
|
||||
generation = generation + 3
|
||||
try:
|
||||
self.doc.close()
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
self.doc.close()
|
||||
|
||||
def calc(self):
|
||||
"""
|
||||
@ -259,7 +255,8 @@ class AncestorChartDialog(Report.DrawReportDialog):
|
||||
self.max_gen, self.doc, self.report_text)
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -271,7 +271,8 @@ class AncestorReportDialog(Report.TextReportDialog):
|
||||
self.max_gen, self.doc, self.pg_brk)
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -344,7 +344,8 @@ class DescendantReportDialog(Report.DrawReportDialog):
|
||||
self.person, self.target_path, self.doc)
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -167,7 +167,8 @@ class DescendantReportDialog(Report.TextReportDialog):
|
||||
MyReport.report()
|
||||
MyReport.end()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -760,7 +760,8 @@ class DetAncestorReportDialog(TextReportDialog):
|
||||
|
||||
MyReport.write_report(rptOpt)
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -449,7 +449,8 @@ class FamilyGroupDialog(Report.TextReportDialog):
|
||||
MyReport.setup()
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -759,7 +759,8 @@ class FtmAncestorReportDialog(Report.TextReportDialog):
|
||||
self.max_gen, self.doc, self.pg_brk)
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -1153,7 +1153,8 @@ class FtmDescendantReportDialog(Report.TextReportDialog):
|
||||
self.max_gen, self.doc, self.pg_brk)
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -544,7 +544,8 @@ class IndivSummaryDialog(Report.TextReportDialog):
|
||||
MyReport.setup()
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -384,7 +384,8 @@ class IndivSummaryDialog(Report.TextReportDialog):
|
||||
MyReport.setup()
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -141,7 +141,7 @@ def importData(database, filename, cb=None):
|
||||
g = GedcomParser(database,filename,statusTop)
|
||||
except IOError,msg:
|
||||
Utils.destroy_passed_object(statusWindow)
|
||||
ErrorDialog(_("%s could not be opened\n") % filename + str(msg))
|
||||
ErrorDialog(_("%s could not be opened\n") % filename,str(msg))
|
||||
return
|
||||
except:
|
||||
Utils.destroy_passed_object(statusWindow)
|
||||
@ -154,12 +154,12 @@ def importData(database, filename, cb=None):
|
||||
except IOError,msg:
|
||||
Utils.destroy_passed_object(statusWindow)
|
||||
errmsg = _("%s could not be opened\n") % filename
|
||||
ErrorDialog(errmsg + str(msg))
|
||||
ErrorDialog(errmsg,str(msg))
|
||||
return
|
||||
except Errors.GedcomError, val:
|
||||
msg = str(val)
|
||||
(m1,m2) = val.messages()
|
||||
Utils.destroy_passed_object(statusWindow)
|
||||
ErrorDialog(msg)
|
||||
ErrorDialog(m1,m2)
|
||||
return
|
||||
except:
|
||||
import DisplayTrace
|
||||
|
@ -410,7 +410,8 @@ class TimeLineDialog(Report.DrawReportDialog):
|
||||
MyReport.setup()
|
||||
MyReport.write_report()
|
||||
except Errors.ReportError, msg:
|
||||
ErrorDialog(str(msg))
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
Loading…
Reference in New Issue
Block a user