From 939d74f25d183bba9d0dbbb2d79e39f48bdf40d6 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 26 Oct 2004 03:20:38 +0000 Subject: [PATCH] * src/docgen/HtmlDoc.py: fix typo * src/docgen/OpenOfficeDoc.py: don't use temporary files * src/plugins/PatchNames.py: pychecker fixes * src/plugins/RelCalc.py: pychecker fixes * src/plugins/ReorderIds.py: pychecker fixes * src/plugins/Verify.py: pychecker fixes * src/plugins/WebPage.py: pychecker fixes * src/plugins/WriteFtree.py: pychecker fixes * src/plugins/WriteGeneWeb.py: pychecker fixes svn: r3674 --- gramps2/ChangeLog | 12 + gramps2/src/StartupDialog.py | 4 +- gramps2/src/docgen/HtmlDoc.py | 2 +- gramps2/src/docgen/OpenOfficeDoc.py | 1080 +++++++++++++-------------- gramps2/src/plugins/PatchNames.py | 38 +- gramps2/src/plugins/RelCalc.py | 8 +- gramps2/src/plugins/ReorderIds.py | 54 +- gramps2/src/plugins/Verify.py | 1 + gramps2/src/plugins/WebPage.py | 1 + gramps2/src/plugins/WriteFtree.py | 1 - gramps2/src/plugins/WriteGeneWeb.py | 11 +- 11 files changed, 599 insertions(+), 613 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index dd5dee38b..615206d83 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,15 @@ +2004-10-25 Don Allingham + * src/StartupDialog.py: handle delete event + * src/docgen/HtmlDoc.py: fix typo + * src/docgen/OpenOfficeDoc.py: don't use temporary files + * src/plugins/PatchNames.py: pychecker fixes + * src/plugins/RelCalc.py: pychecker fixes + * src/plugins/ReorderIds.py: pychecker fixes + * src/plugins/Verify.py: pychecker fixes + * src/plugins/WebPage.py: pychecker fixes + * src/plugins/WriteFtree.py: pychecker fixes + * src/plugins/WriteGeneWeb.py: pychecker fixes + 2004-10-24 Don Allingham * src/gramps.glade: change "Edit..." buttons to an image * src/plugins/CountAncestors.py: handle duplicates across diff --git a/gramps2/src/StartupDialog.py b/gramps2/src/StartupDialog.py index 0902b979f..068563df2 100644 --- a/gramps2/src/StartupDialog.py +++ b/gramps2/src/StartupDialog.py @@ -21,6 +21,7 @@ # $Id$ import const +import gtk import gtk.glade import gnome import gnome.ui @@ -56,8 +57,7 @@ class StartupDialog: d.add(self.build_page_last()) d.connect('cancel',self.close) - self.w.connect("destroy_event", self.close) - + self.w.connect("delete_event", gtk.quit) self.w.show_all() def close(self,obj): diff --git a/gramps2/src/docgen/HtmlDoc.py b/gramps2/src/docgen/HtmlDoc.py index 0ac6b966b..7ba526250 100644 --- a/gramps2/src/docgen/HtmlDoc.py +++ b/gramps2/src/docgen/HtmlDoc.py @@ -181,7 +181,7 @@ class HtmlDoc(BaseDoc.BaseDoc): if top_add == 1: mymsg = _("The marker '' was not in the template") - QuestionDilaog.ErrorDialog(_("Template Error"),mymsg) + QuestionDialog.ErrorDialog(_("Template Error"),mymsg) def load_template(self): if self.template: diff --git a/gramps2/src/docgen/OpenOfficeDoc.py b/gramps2/src/docgen/OpenOfficeDoc.py index be4111a8f..aba1679c6 100644 --- a/gramps2/src/docgen/OpenOfficeDoc.py +++ b/gramps2/src/docgen/OpenOfficeDoc.py @@ -26,11 +26,11 @@ # #------------------------------------------------------------------------- import os -import tempfile import string import zipfile import time import locale +from cStringIO import StringIO from math import pi, cos, sin, fabs #------------------------------------------------------------------------- @@ -65,7 +65,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): def __init__(self,styles,type,template,orientation=BaseDoc.PAPER_PORTRAIT): BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation) - self.f = None + self.cntnt = None self.filename = None self.level = 0 self.time = "0000-00-00T00:00:00" @@ -87,15 +87,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): else: self.filename = filename - self.filename = os.path.normpath(os.path.abspath(filename)) - - try: - self.content_xml = tempfile.mktemp() - self.f = open(self.content_xml,"wb") - except IOError,msg: - raise Errors.ReportError(_("Could not create %s") % self.content_xml, msg) - except: - raise Errors.ReportError(_("Could not create %s") % self.content_xml) + self.filename = os.path.normpath(os.path.abspath(self.filename)) + self.cntnt = StringIO() def init(self): @@ -106,269 +99,270 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): else: self.lang = "en-US" - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('') - self.f.write('') - self.f.write('\n') - self.f.write('') - self.f.write('') - self.f.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('') + self.cntnt.write('') + self.cntnt.write('\n') + self.cntnt.write('') + self.cntnt.write('') + self.cntnt.write('\n') for style_name in self.draw_styles.keys(): style = self.draw_styles[style_name] - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('\n') - self.f.write('\n') + self.cntnt.write('draw:stroke="none" ') + self.cntnt.write('draw:shadow="hidden" ') + self.cntnt.write('style:run-through="background" ') + self.cntnt.write('/>\n') + self.cntnt.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') for style_name in self.style_list.keys(): style = self.style_list[style_name] - self.f.write('\n' % style_name) - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('\n' % style_name) + self.cntnt.write('\n') + self.cntnt.write('\n') - self.f.write('\n') - self.f.write('\n') + self.cntnt.write(' 0: - self.f.write('fo:keep-with-next="true" ') + self.cntnt.write('fo:keep-with-next="true" ') align = style.get_alignment() if align == BaseDoc.PARA_ALIGN_LEFT: - self.f.write('fo:text-align="start" ') + self.cntnt.write('fo:text-align="start" ') elif align == BaseDoc.PARA_ALIGN_RIGHT: - self.f.write('fo:text-align="end" ') + self.cntnt.write('fo:text-align="end" ') elif align == BaseDoc.PARA_ALIGN_CENTER: - self.f.write('fo:text-align="center" ') - self.f.write('style:justify-single-word="false" ') + self.cntnt.write('fo:text-align="center" ') + self.cntnt.write('style:justify-single-word="false" ') else: - self.f.write('fo:text-align="justify" ') - self.f.write('style:justify-single-word="false" ') + self.cntnt.write('fo:text-align="justify" ') + self.cntnt.write('style:justify-single-word="false" ') font = style.get_font() if font.get_type_face() == BaseDoc.FONT_SANS_SERIF: - self.f.write('style:font-name="Arial" ') + self.cntnt.write('style:font-name="Arial" ') else: - self.f.write('style:font-name="Times New Roman" ') - self.f.write('fo:font-size="' + str(font.get_size()) + 'pt" ') + self.cntnt.write('style:font-name="Times New Roman" ') + self.cntnt.write('fo:font-size="%dpt" ' % font.get_size()) + self.cntnt.write('style:font-size-asian="%dpt" ' % font.get_size()) color = font.get_color() - self.f.write('fo:color="#%02x%02x%02x" ' % color) + self.cntnt.write('fo:color="#%02x%02x%02x" ' % color) if font.get_bold(): - self.f.write('fo:font-weight="bold" ') + self.cntnt.write('fo:font-weight="bold" ') if font.get_italic(): - self.f.write('fo:font-style="italic" ') + self.cntnt.write('fo:font-style="italic" ') if font.get_underline(): - self.f.write('style:text-underline="single" ') - self.f.write('style:text-underline-color="font-color" ') - self.f.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) - self.f.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) - self.f.write('fo:margin-left="%.2fcm" ' % style.get_left_margin()) - self.f.write('fo:margin-top="0cm" ') - self.f.write('fo:margin-bottom="0.212cm"') - self.f.write('/>\n') - self.f.write('\n') + self.cntnt.write('style:text-underline="single" ') + self.cntnt.write('style:text-underline-color="font-color" ') + self.cntnt.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) + self.cntnt.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) + self.cntnt.write('fo:margin-left="%.2fcm" ' % style.get_left_margin()) + self.cntnt.write('fo:margin-top="0cm" ') + self.cntnt.write('fo:margin-bottom="0.212cm"') + self.cntnt.write('/>\n') + self.cntnt.write('\n') - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('' % font.get_size()) - self.f.write('\n') + self.cntnt.write('fo:font-style="italic" ') + self.cntnt.write('fo:font-size="%dpt"/>' % font.get_size()) + self.cntnt.write('style:font-size-asian="%dpt" ' % font.get_size()) + self.cntnt.write('\n') for style_name in self.table_styles.keys(): style = self.table_styles[style_name] - self.f.write('\n') + self.cntnt.write('\n') table_width = float(self.get_usable_width()) table_width_str = "%.4f" % table_width - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') for col in range(0,style.get_columns()): - self.f.write('') + self.cntnt.write('') width = table_width * float(style.get_column_width(col)/100.0) width_str = "%.4f" % width - self.f.write('' % width_str) - self.f.write('\n') + self.cntnt.write('' % width_str) + self.cntnt.write('\n') for cell in self.cell_styles.keys(): cell_style = self.cell_styles[cell] - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('\n') - self.f.write('\n') + self.cntnt.write(' fo:border-right="none"') + self.cntnt.write('/>\n') + self.cntnt.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') #Begin photo style - self.f.write('') - self.f.write('') - self.f.write('\n') + self.cntnt.write('') + self.cntnt.write('') + self.cntnt.write('\n') - self.f.write('') - self.f.write('') - self.f.write('\n') + self.cntnt.write('') + self.cntnt.write('') + self.cntnt.write('\n') - self.f.write('') - self.f.write('') - self.f.write('\n') + self.cntnt.write('') + self.cntnt.write('') + self.cntnt.write('\n') - self.f.write('') - self.f.write('') - self.f.write('\n') + self.cntnt.write('') + self.cntnt.write('') + self.cntnt.write('\n') #end of Photo style edits - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('\n') + self.cntnt.write('\n') def close(self): - self.f.write('\n') - self.f.write('\n') - self.f.close() + self.cntnt.write('\n') + self.cntnt.write('\n') self._write_styles_file() self._write_manifest() self._write_meta_file() @@ -404,257 +398,261 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): tag = base.replace('.','_') if self.new_cell: - self.f.write('') + self.cntnt.write('') if pos == "left": - self.f.write('\n') + self.cntnt.write('draw:name="%s" ' % tag) + self.cntnt.write('text:anchor-type="paragraph" ') + self.cntnt.write('svg:width="%.3fcm" ' % act_width) + self.cntnt.write('svg:height="%.3fcm" ' % act_height) + self.cntnt.write('draw:z-index="0" ') + self.cntnt.write('xlink:href="#Pictures/') + self.cntnt.write(base) + self.cntnt.write('" xlink:type="simple" xlink:show="embed" ') + self.cntnt.write('xlink:actuate="onLoad"/>\n') if self.new_cell: - self.f.write('\n') + self.cntnt.write('\n') def start_table(self,name,style_name): - self.f.write('\n' % style_name) + self.cntnt.write('\n' % style_name) table = self.table_styles[style_name] for col in range(0,table.get_columns()): - self.f.write('\n') + self.cntnt.write('\n') def end_table(self): - self.f.write('\n') + self.cntnt.write('\n') def start_row(self): - self.f.write('\n') + self.cntnt.write('\n') def end_row(self): - self.f.write('\n') + self.cntnt.write('\n') def start_cell(self,style_name,span=1): self.span = span - self.f.write(' 1: - self.f.write(' table:number-columns-spanned="%s">\n' % span) + self.cntnt.write(' table:number-columns-spanned="%s">\n' % span) else: - self.f.write('>\n') + self.cntnt.write('>\n') self.new_cell = 1 def end_cell(self): - self.f.write('\n') + self.cntnt.write('\n') for col in range(1,self.span): - self.f.write('\n') + self.cntnt.write('\n') self.new_cell = 0 def start_bold(self): - self.f.write('') + self.cntnt.write('') def end_bold(self): - self.f.write('') + self.cntnt.write('') + + def _add_zip(self,zfile,name,data,t): + zipinfo = zipfile.ZipInfo(name.encode('latin-1')) + zipinfo.date_time = t + zipinfo.compress_type = zipfile.ZIP_DEFLATED + zfile.writestr(zipinfo,data) def _write_zip(self): - file = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED) - 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")) - file.write(self.styles_xml,str("styles.xml")) + zfile = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED) + + t = time.localtime(time.time())[:6] + + self._add_zip(zfile,"META-INF/manifest.xml",self.mfile.getvalue(),t) + self._add_zip(zfile,"content.xml",self.cntnt.getvalue(),t) + self._add_zip(zfile,"meta.xml",self.meta.getvalue(),t) + self._add_zip(zfile,"styles.xml",self.sfile.getvalue(),t) + + self.mfile.close() + self.cntnt.close() + self.meta.close() + self.sfile.close() for image in self.media_list: - base = os.path.basename(image[0]) - file.write(image[0], str("Pictures/%s" % base)) - file.close() + try: + ifile = open(image[0]) + base = os.path.basename(image[0]) + self._add_zip(zfile,"Pictures/%s" % base, ifile.read(),t) + ifile.close() + except: + print "Could not open %s" % image[0] + zfile.close() - os.unlink(self.manifest_xml) - os.unlink(self.content_xml) - os.unlink(self.meta_xml) - os.unlink(self.styles_xml) - def _write_styles_file(self): - self.styles_xml = tempfile.mktemp() - - 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: - pass - raise Errors.ReportError(_("Could not create %s") % self.styles_xml) + self.sfile = StringIO() - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') for key in self.style_list.keys(): style = self.style_list[key] - self.f.write('\n') - self.f.write('\n') + self.sfile.write(' 0: - self.f.write('fo:keep-with-next="true" ') + self.sfile.write('fo:keep-with-next="true" ') align = style.get_alignment() if align == BaseDoc.PARA_ALIGN_LEFT: - self.f.write('fo:text-align="start" ') + self.sfile.write('fo:text-align="start" ') elif align == BaseDoc.PARA_ALIGN_RIGHT: - self.f.write('fo:text-align="end" ') + self.sfile.write('fo:text-align="end" ') elif align == BaseDoc.PARA_ALIGN_CENTER: - self.f.write('fo:text-align="center" ') - self.f.write('style:justify-single-word="false" ') + self.sfile.write('fo:text-align="center" ') + self.sfile.write('style:justify-single-word="false" ') else: - self.f.write('fo:text-align="justify" ') - self.f.write('style:justify-single-word="false" ') + self.sfile.write('fo:text-align="justify" ') + self.sfile.write('style:justify-single-word="false" ') font = style.get_font() if font.get_type_face() == BaseDoc.FONT_SANS_SERIF: - self.f.write('style:font-name="Arial" ') + self.sfile.write('style:font-name="Arial" ') else: - self.f.write('style:font-name="Times New Roman" ') - self.f.write('fo:font-size="' + str(font.get_size()) + 'pt" ') + self.sfile.write('style:font-name="Times New Roman" ') + self.sfile.write('fo:font-size="' + str(font.get_size()) + 'pt" ') color = font.get_color() - self.f.write('fo:color="#%02x%02x%02x" ' % color) + self.sfile.write('fo:color="#%02x%02x%02x" ' % color) if font.get_bold(): - self.f.write('fo:font-weight="bold" ') + self.sfile.write('fo:font-weight="bold" ') if font.get_italic(): - self.f.write('fo:font-style="italic" ') + self.sfile.write('fo:font-style="italic" ') if font.get_underline(): - self.f.write('style:text-underline="single" ') - self.f.write('style:text-underline-color="font-color" ') - self.f.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) - self.f.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) - self.f.write('fo:margin-left="%.2fcm" ' % style.get_left_margin()) - self.f.write('fo:margin-top="0cm" ') - self.f.write('fo:margin-bottom="0.212cm"') - self.f.write('/>\n') - self.f.write('\n') + self.sfile.write('style:text-underline="single" ') + self.sfile.write('style:text-underline-color="font-color" ') + self.sfile.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) + self.sfile.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) + self.sfile.write('fo:margin-left="%.2fcm" ' % style.get_left_margin()) + self.sfile.write('fo:margin-top="0cm" ') + self.sfile.write('fo:margin-bottom="0.212cm"') + self.sfile.write('/>\n') + self.sfile.write('\n') # Current no leading number format for headers - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.close() + self.sfile.write('style:print-orientation="landscape" ') + self.sfile.write('fo:margin-top="%.2fcm" ' % self.tmargin) + self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.bmargin) + self.sfile.write('fo:margin-left="%.2fcm" ' % self.lmargin) + self.sfile.write('fo:margin-right="%.2fcm" ' % self.rmargin) + self.sfile.write('style:footnote-max-height="0cm">\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') + self.sfile.write('\n') def page_break(self): self.new_page = 1 def start_page(self): - self.f.write('\n') + self.cntnt.write('\n') def end_page(self): - self.f.write('\n') + self.cntnt.write('\n') def start_paragraph(self,style_name,leader=None): style = self.style_list[style_name] @@ -665,21 +663,21 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): else: name = style_name if self.level == 0: - self.f.write('' % name) + self.cntnt.write('' % name) else: - self.f.write('\n') + self.cntnt.write('\n') if leader != None: - self.f.write(leader) - self.f.write('\n') + self.cntnt.write(leader) + self.cntnt.write('\n') self.new_cell = 0 def end_paragraph(self): if self.level == 0: - self.f.write('\n') + self.cntnt.write('\n') else: - self.f.write('\n') + self.cntnt.write('\n') self.new_cell = 1 def write_note(self,text,format,style_name): @@ -697,9 +695,9 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): text = text.replace('</super>','') self.start_paragraph(style_name) - self.f.write('') - self.f.write(text) - self.f.write('') + self.cntnt.write('') + self.cntnt.write(text) + self.cntnt.write('') self.end_paragraph() elif format == 0: for line in text.split('\n\n'): @@ -717,92 +715,70 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): text = text.replace('<super>', '') text = text.replace('</super>','') - self.f.write(text) + self.cntnt.write(text) def _write_manifest(self): - self.manifest_xml = tempfile.mktemp() + self.mfile = StringIO() - 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: - pass - raise Errors.ReportError(_("Could not create %s") % self.manifest_xml) - - - self.f.write('\n') - self.f.write('') - self.f.write('') + self.mfile.write('\n') + self.mfile.write('') + self.mfile.write('') for image in self.media_list: i = image[0] base = os.path.basename(i) - self.f.write('') - self.f.write('') - self.f.write('') - self.f.write('') - self.f.write('') - self.f.write('\n') - self.f.close() + self.mfile.write('') + self.mfile.write('') + self.mfile.write('') + self.mfile.write('') + self.mfile.write('') + self.mfile.write('\n') def _write_meta_file(self): - name = self.name - self.meta_xml = tempfile.mktemp() + self.meta = StringIO() - 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: - pass - raise Errors.ReportError(_("Could not create %s") % self.meta_xml) - - self.f.write('\n') - self.f.write('\n'); - self.f.write('\n') - self.f.write('') - self.f.write(const.progName + ' ' + const.version) - self.f.write('\n') - self.f.write('') - self.f.write(name) - self.f.write('\n') - self.f.write('') - self.f.write(self.time) - self.f.write('\n') - self.f.write('') - self.f.write(name) - self.f.write('\n') - self.f.write('') - self.f.write(self.time) - self.f.write('\n') - self.f.write('0-00-00T00:00:00\n') - self.f.write('%s\n' % self.lang) - self.f.write('1\n') - self.f.write('PT0S\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.write('\n') - self.f.close() + self.meta.write('\n') + self.meta.write('\n'); + self.meta.write('\n') + self.meta.write('') + self.meta.write(const.progName + ' ' + const.version) + self.meta.write('\n') + self.meta.write('') + self.meta.write(self.name) + self.meta.write('\n') + self.meta.write('') + self.meta.write(self.time) + self.meta.write('\n') + self.meta.write('') + self.meta.write(self.name) + self.meta.write('\n') + self.meta.write('') + self.meta.write(self.time) + self.meta.write('\n') + self.meta.write('0-00-00T00:00:00\n') + self.meta.write('%s\n' % self.lang) + self.meta.write('1\n') + self.meta.write('PT0S\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') + self.meta.write('\n') def rotate_text(self,style,text,x,y,angle): @@ -822,20 +798,20 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): rangle = -((pi/180.0) * angle) - self.f.write('') - self.f.write('' % pname) + self.cntnt.write('translate (%.3fcm %.3fcm)"' % (xloc,yloc)) + self.cntnt.write('>') + self.cntnt.write('' % pname) - self.f.write('\n' % pname) + self.cntnt.write('\n' % pname) self.write_text(string.join(text,'\n')) - self.f.write('\n\n\n') + self.cntnt.write('\n\n\n') def draw_path(self,style,path): minx = 9e12 @@ -849,34 +825,34 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): maxx = max(point[0],maxx) maxy = max(point[1],maxy) - self.f.write('\n') + self.cntnt.write(' %d,%d' % (x1,y1)) + self.cntnt.write('"/>\n') def draw_line(self,style,x1,y1,x2,y2): - self.f.write('\n') + self.cntnt.write('\n') def draw_text(self,style,text,x,y): box_style = self.draw_styles[style] @@ -890,32 +866,32 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): sw = pt2cm(FontScale.string_width(font,text))*1.3 - self.f.write('' % float(y)) - self.f.write('' % para_name) - self.f.write('' % para_name) - self.f.write(text) - self.f.write('') - self.f.write('\n') + self.cntnt.write('svg:x="%.3fcm" ' % float(x)) + self.cntnt.write('svg:y="%.3fcm">' % float(y)) + self.cntnt.write('' % para_name) + self.cntnt.write('' % para_name) + self.cntnt.write(text) + self.cntnt.write('') + self.cntnt.write('\n') def draw_bar(self,style,x,y,x2,y2): box_style = self.draw_styles[style] - self.f.write('' % float(y)) - self.f.write('\n') + self.cntnt.write('' % float(y)) + self.cntnt.write('\n') def draw_box(self,style,text,x,y): box_style = self.draw_styles[style] @@ -923,33 +899,33 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): shadow_width = box_style.get_shadow_space() if box_style.get_shadow(): - self.f.write('\n' % (float(y)+shadow_width)) - self.f.write('\n') + self.cntnt.write('\n' % (float(y)+shadow_width)) + self.cntnt.write('\n') - self.f.write('\n' % float(y)) + self.cntnt.write('\n' % float(y)) if text != "": - self.f.write('' % para_name) - self.f.write('' % para_name) + self.cntnt.write('' % para_name) + self.cntnt.write('' % para_name) text = text.replace('\t','') text = text.replace('\n','') - self.f.write(text) - self.f.write('') - self.f.write('\n') - self.f.write('\n') + self.cntnt.write(text) + self.cntnt.write('') + self.cntnt.write('\n') + self.cntnt.write('\n') def center_text(self,style,text,x,y): box_style = self.draw_styles[style] @@ -959,20 +935,20 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): size = 1.1*(FontScale.string_width(font,text)/72.0) * 2.54 - self.f.write('\n' % float(y)) + self.cntnt.write('svg:x="%.3fcm" ' % (x-(size/2.0))) + self.cntnt.write('svg:y="%.3fcm">\n' % float(y)) if text != "": - self.f.write('' % para_name) - self.f.write(text) - self.f.write('\n') - self.f.write('\n') + self.cntnt.write('' % para_name) + self.cntnt.write(text) + self.cntnt.write('\n') + self.cntnt.write('\n') #------------------------------------------------------------------------ # diff --git a/gramps2/src/plugins/PatchNames.py b/gramps2/src/plugins/PatchNames.py index a0305a47c..9450b2055 100644 --- a/gramps2/src/plugins/PatchNames.py +++ b/gramps2/src/plugins/PatchNames.py @@ -100,8 +100,6 @@ class PatchNames: groups = match.groups() self.nick_list.append((key,groups[0],groups[1])) - msg = "" - if self.nick_list or self.title_list: self.display() else: @@ -158,23 +156,23 @@ class PatchNames: for (id,name,nick) in self.nick_list: p = self.db.get_person_from_handle(id) - iter = self.model.append() - self.model.set_value(iter,0,1) - self.model.set_value(iter,1,id) - self.model.set_value(iter,2,_('Nickname')) - self.model.set_value(iter,3,nick) - self.model.set_value(iter,4,p.get_primary_name().get_name()) - self.nick_hash[id] = iter + handle = self.model.append() + self.model.set_value(handle,0,1) + self.model.set_value(handle,1,id) + self.model.set_value(handle,2,_('Nickname')) + self.model.set_value(handle,3,nick) + self.model.set_value(handle,4,p.get_primary_name().get_name()) + self.nick_hash[id] = handle for (id,title,nick) in self.title_list: p = self.db.get_person_from_handle(id) - iter = self.model.append() - self.model.set_value(iter,0,1) - self.model.set_value(iter,1,id) - self.model.set_value(iter,2,_('Title')) - self.model.set_value(iter,3,nick) - self.model.set_value(iter,4,p.get_primary_name().get_name()) - self.title_hash[id] = iter + handle = self.model.append() + self.model.set_value(handle,0,1) + self.model.set_value(handle,1,id) + self.model.set_value(handle,2,_('Title')) + self.model.set_value(handle,3,nick) + self.model.set_value(handle,4,p.get_primary_name().get_name()) + self.title_hash[id] = handle self.add_itself_to_menu() self.window.show() @@ -202,8 +200,8 @@ class PatchNames: def on_ok_clicked(self,obj): for grp in self.nick_list: - iter = self.nick_hash[grp[0]] - val = self.model.get_value(iter,0) + handle = self.nick_hash[grp[0]] + val = self.model.get_value(handle,0) if val: p = self.db.get_person_from_handle(grp[0]) name = p.get_primary_name() @@ -212,8 +210,8 @@ class PatchNames: self.db.commit_person(p,self.trans) for grp in self.title_list: - iter = self.title_hash[grp[0]] - val = self.model.get_value(iter,0) + handle = self.title_hash[grp[0]] + val = self.model.get_value(handle,0) if val: p = self.db.get_person_from_handle(grp[0]) name = p.get_primary_name() diff --git a/gramps2/src/plugins/RelCalc.py b/gramps2/src/plugins/RelCalc.py index 82f3ae3fa..a1fa99718 100644 --- a/gramps2/src/plugins/RelCalc.py +++ b/gramps2/src/plugins/RelCalc.py @@ -137,12 +137,12 @@ class RelCalc: self.window.present() def on_apply_clicked(self,obj): - model,iter = self.clist.get_selected() - if not iter: + model,node = self.clist.get_selected() + if not node: return - id = self.clist.get_object(iter) - other_person = self.db.get_person_from_handle(id) + handle = self.clist.get_object(node) + other_person = self.db.get_person_from_handle(handle) (rel_string,common) = self.relationship.get_relationship(self.person,other_person) length = len(common) diff --git a/gramps2/src/plugins/ReorderIds.py b/gramps2/src/plugins/ReorderIds.py index 6941b1058..7efec924c 100644 --- a/gramps2/src/plugins/ReorderIds.py +++ b/gramps2/src/plugins/ReorderIds.py @@ -73,55 +73,55 @@ class ReorderIds: for x in data_map.keys(): key_list.append(x) - for id in key_list: + for handle in key_list: # attempt to extract integer, if we can't, treat it as a # duplicate - match = _findint.match(id) + match = _findint.match(handle) if match: - # get the integer, build the new id. Make sure it + # get the integer, build the new handle. Make sure it # hasn't already been chosen. If it has, put this - # in the duplicate id list + # in the duplicate handle list try: index = match.groups()[0] - newid = prefix % int(index) - if newid == id: - newids[newid] = id + newhandle = prefix % int(index) + if newhandle == handle: + newids[newhandle] = handle continue - elif data_map.has_key(newid): - dups.append(id) + elif data_map.has_key(newhandle): + dups.append(handle) else: - data = data_map[id] - data_map[newid] = data - newids[newid] = id - data.set_handle(newid) - del data_map[id] + data = data_map[handle] + data_map[newhandle] = data + newids[newhandle] = handle + data.set_handle(newhandle) + del data_map[handle] if update: - update(newid,id) + update(newhandle,handle) except: - dups.append(id) + dups.append(handle) else: - dups.append(id) + dups.append(handle) # go through the duplicates, looking for the first availble - # id that matches the new scheme. + # handle that matches the new scheme. index = 0 - for id in dups: + for handle in dups: while 1: - newid = prefix % index - if not newids.has_key(newid): + newhandle = prefix % index + if not newids.has_key(newhandle): break index = index + 1 - newids[newid] = newid - data = data_map[id] - data.set_handle(newid) - data_map[newid] = data + newids[newhandle] = newhandle + data = data_map[handle] + data.set_handle(newhandle) + data_map[newhandle] = data if update: - update(newid,id) - del data_map[id] + update(newhandle,handle) + del data_map[handle] #------------------------------------------------------------------------- # diff --git a/gramps2/src/plugins/Verify.py b/gramps2/src/plugins/Verify.py index dba6af6f3..979d17588 100644 --- a/gramps2/src/plugins/Verify.py +++ b/gramps2/src/plugins/Verify.py @@ -50,6 +50,7 @@ import gtk.glade #------------------------------------------------------------------------ import RelLib import Utils +import Date from gettext import gettext as _ diff --git a/gramps2/src/plugins/WebPage.py b/gramps2/src/plugins/WebPage.py index 97d12f4dd..5f1b86995 100644 --- a/gramps2/src/plugins/WebPage.py +++ b/gramps2/src/plugins/WebPage.py @@ -56,6 +56,7 @@ import DateHandler import Sort import Report import Errors +import Utils from QuestionDialog import ErrorDialog from gettext import gettext as _ diff --git a/gramps2/src/plugins/WriteFtree.py b/gramps2/src/plugins/WriteFtree.py index f2a39bbb9..446d140e3 100644 --- a/gramps2/src/plugins/WriteFtree.py +++ b/gramps2/src/plugins/WriteFtree.py @@ -165,7 +165,6 @@ class FtreeWriter: id_name = {} for key in self.plist: pn = self.db.get_person_from_handle(key).get_primary_name() - fn = "" sn = pn.get_surname() items = pn.get_first_name().split() if len(items) > 0: diff --git a/gramps2/src/plugins/WriteGeneWeb.py b/gramps2/src/plugins/WriteGeneWeb.py index 88b72fe02..7d14dd66d 100644 --- a/gramps2/src/plugins/WriteGeneWeb.py +++ b/gramps2/src/plugins/WriteGeneWeb.py @@ -400,9 +400,8 @@ class GeneWebWriter: retval = self.get_full_person_info(person) return retval - def rem_spaces(self,string): - string = string.replace(' ','_') - return string + def rem_spaces(self,str): + return str.replace(' ','_') def get_ref_name(self,person): surname = self.rem_spaces( person.get_primary_name().get_surname()) @@ -514,11 +513,11 @@ class GeneWebWriter: cal_type = "" if cal == Date.CAL_HEBREW: - type = "H" + cal_type = "H" elif cal == Date.CAL_FRENCH: - type = "F" + cal_type = "F" elif cal == Date.CAL_JULIAN: - type = "J" + cal_type = "J" mode_prefix = "" if mode == Date.MOD_ABOUT: