2006-07-19 Alex Roitman <shura@gramps-project.org>

* src/plugins/GraphViz.py (GraphViz.__init__): Take care of the
	encoding errors.
	


svn: r7046
This commit is contained in:
Alex Roitman 2006-07-19 23:42:50 +00:00
parent 853094a4a2
commit 6325153e02
2 changed files with 26 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2006-07-19 Alex Roitman <shura@gramps-project.org>
* src/plugins/GraphViz.py (GraphViz.__init__): Take care of the
encoding errors.
2006-07-19 Zsolt Foldvari <zsolt.foldvari@nokia.com> 2006-07-19 Zsolt Foldvari <zsolt.foldvari@nokia.com>
* src/GrampsCfg.py: UI improvements. * src/GrampsCfg.py: UI improvements.
* src/Config/_GrampsIniKeys.py: Proper key retrieval. * src/Config/_GrampsIniKeys.py: Proper key retrieval.

View File

@ -63,6 +63,7 @@ import DateHandler
import const import const
from BaseDoc import PAPER_LANDSCAPE from BaseDoc import PAPER_LANDSCAPE
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
import Errors
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -243,13 +244,30 @@ class GraphViz:
self.filter = filters[filter_num] self.filter = filters[filter_num]
the_buffer = self.get_report() the_buffer = self.get_report()
encoding_problem = False
try:
self.f = open(options_class.get_output(),'w') self.f = open(options_class.get_output(),'w')
if self.latin:
self.f.write(the_buffer.encode('iso-8859-1', 'replace'))
else:
self.f.write(the_buffer) self.f.write(the_buffer)
except UnicodeEncodeError:
if self.latin:
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."))
self.f.close() 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): def get_report(self):
"return string of the .dot file contents" "return string of the .dot file contents"
self.person_handles = self.filter.apply(self.database, self.person_handles = self.filter.apply(self.database,