From 705f6e2365def280ceb9a9718c586a444c2541cf Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 20 Jul 2006 19:49:27 +0000 Subject: [PATCH] * src/plugins/GraphViz.py (GraphViz.__init__): Better error handling. svn: r7052 --- gramps2/ChangeLog | 1 + gramps2/src/plugins/GraphViz.py | 33 +++++++++++++-------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d753f25ba..2ddc2118a 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,5 @@ 2006-07-20 Alex Roitman + * src/plugins/GraphViz.py (GraphViz.__init__): Better error handling. * src/plugins/IndivComplete.py: Use NameDisplay. * src/plugins/FamilyGroup.py: Use NameDisplay. * src/GrampsCfg.py (add_name_panel): Minor UI improvements; diff --git a/gramps2/src/plugins/GraphViz.py b/gramps2/src/plugins/GraphViz.py index afd525944..ec2c51377 100644 --- a/gramps2/src/plugins/GraphViz.py +++ b/gramps2/src/plugins/GraphViz.py @@ -244,30 +244,23 @@ class GraphViz: the_buffer = self.get_report() - encoding_problem = False - try: - self.f = open(options_class.get_output(),'w') - self.f.write(the_buffer) - except UnicodeEncodeError: - if self.latin: + self.f = open(options_class.get_output(),'w') + if self.latin: + try: + self.f.write(the_buffer.encode('iso-8859-1', 'strict')) + except UnicodeEncodeError: self.f = open(options_class.get_output(),'w') self.f.write(the_buffer.encode('iso-8859-1', 'replace')) - encoding_problem = True - else: - raise Errors.ReporError( - _("Your data contains characters that cannot " - "be displayed. Most likely this is caused " - "by the incorrect character encoding.")) + ErrorDialog( + _("Your data contains characters that cannot be " + "converted to latin-1. These characters were " + "replaced with the question marks in the output. " + "To get these characters properly displayed, " + "unselect latin-1 option and try again.")) + else: + self.f.write(the_buffer) self.f.close() - if encoding_problem: - ErrorDialog( - _("Your data contains characters that cannot be " - "converted to latin-1. These characters were " - "replaced with the question marks in the output. " - "To get these characters properly displayed, " - "unselect latin-1 option and try again.")) - def get_report(self): "return string of the .dot file contents" self.person_handles = self.filter.apply(self.database,