Fix Py2 file encoding errors
svn: r21424
This commit is contained in:
parent
400523c7f3
commit
3d0fa7a00a
@ -38,6 +38,8 @@ from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
import time
|
||||
import os
|
||||
import io
|
||||
from gramps.gen.constfunc import cuni
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.get_translation().gettext
|
||||
import sys
|
||||
@ -1169,20 +1171,17 @@ class GrampletPane(Gtk.ScrolledWindow):
|
||||
return # something is the matter
|
||||
filename = self.configfile
|
||||
try:
|
||||
if win() and not sys.version_info[0] < 3:
|
||||
fp = open(filename, "w", encoding='utf-8')
|
||||
else:
|
||||
fp = open(filename, "w")
|
||||
fp = io.open(filename, "w", encoding='utf-8')
|
||||
except IOError:
|
||||
print("Failed writing '%s'; gramplets not saved" % filename)
|
||||
return
|
||||
fp.write(";; Gramps gramplets file" + NL)
|
||||
fp.write((";; Automatically created at %s" %
|
||||
time.strftime("%Y/%m/%d %H:%M:%S")) + NL + NL)
|
||||
fp.write("[Gramplet View Options]" + NL)
|
||||
fp.write(("column_count=%d" + NL) % self.column_count)
|
||||
fp.write(("pane_position=%d" + NL) % self.pane_position)
|
||||
fp.write(("pane_orientation=%s" + NL) % self.pane_orientation)
|
||||
fp.write(cuni(";; Gramps gramplets file" + NL))
|
||||
fp.write(cuni((";; Automatically created at %s" %
|
||||
time.strftime("%Y/%m/%d %H:%M:%S")) + NL + NL))
|
||||
fp.write(cuni("[Gramplet View Options]" + NL))
|
||||
fp.write(cuni(("column_count=%d" + NL) % self.column_count))
|
||||
fp.write(cuni(("pane_position=%d" + NL) % self.pane_position))
|
||||
fp.write(cuni(("pane_orientation=%s" + NL) % self.pane_orientation))
|
||||
fp.write(NL)
|
||||
# showing gramplets:
|
||||
for col in range(self.column_count):
|
||||
|
@ -36,7 +36,7 @@ from __future__ import print_function
|
||||
import re
|
||||
import locale
|
||||
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
from gramps.gen.constfunc import STRTYPE, cuni
|
||||
"""
|
||||
HTML operations.
|
||||
|
||||
@ -417,14 +417,14 @@ class Html(list):
|
||||
elif self.indent:
|
||||
tabs += indent
|
||||
if self.inline: # if inline, write all list and
|
||||
method('%s%s' % (tabs, self)) # nested list elements
|
||||
method(cuni('%s%s' % (tabs, self))) # nested list elements
|
||||
#
|
||||
else:
|
||||
for item in self[:]: # else write one at a time
|
||||
if isinstance(item, Html): # recurse if nested Html class
|
||||
item.write(method=method, indent=indent, tabs=tabs)
|
||||
else:
|
||||
method('%s%s' % (tabs, item)) # else write the line
|
||||
method(cuni('%s%s' % (tabs, item))) # else write the line
|
||||
#
|
||||
def addXML(self, version=1.0, encoding="UTF-8", standalone="no"):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user