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