From d5e63a30d508dc84a7515a10cc2021a2e7ea6c32 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Sun, 24 Mar 2013 00:10:34 +0000 Subject: [PATCH] more open=>io.open changes, as John advised svn: r21728 --- gramps/gen/plug/_options.py | 3 ++- gramps/gen/plug/_pluginreg.py | 4 +--- gramps/gen/plug/docgen/stylesheet.py | 5 +++-- gramps/gen/plug/report/_book.py | 7 ++++--- gramps/gen/plug/report/_options.py | 5 +++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gramps/gen/plug/_options.py b/gramps/gen/plug/_options.py index c04810698..fa96b5509 100644 --- a/gramps/gen/plug/_options.py +++ b/gramps/gen/plug/_options.py @@ -35,6 +35,7 @@ General option handling, including saving and parsing. from __future__ import print_function import os +import io #------------------------------------------------------------------------- # @@ -198,7 +199,7 @@ class OptionListCollection(object): """ Saves the current OptionListCollection to the associated file. """ - f = open(self.filename,"w") + f = io.open(self.filename, "w", encoding='utf-8') f.write("\n") f.write('\n') diff --git a/gramps/gen/plug/_pluginreg.py b/gramps/gen/plug/_pluginreg.py index 08aa49883..f94934d89 100644 --- a/gramps/gen/plug/_pluginreg.py +++ b/gramps/gen/plug/_pluginreg.py @@ -1083,9 +1083,7 @@ class PluginRegister(object): full_filename = os.path.join(dir, filename) if sys.version_info[0] < 3: full_filename = full_filename.encode(glocale.getfilesystemencoding()) - fd = open(full_filename, "r") - else: - fd = io.open(full_filename, 'r', encoding = 'utf-8') + fd = io.open(full_filename, 'r', encoding = 'utf-8') stream = fd.read() fd.close() if os.path.exists(os.path.join(os.path.dirname(full_filename), diff --git a/gramps/gen/plug/docgen/stylesheet.py b/gramps/gen/plug/docgen/stylesheet.py index d4e372dd0..016de3b4b 100644 --- a/gramps/gen/plug/docgen/stylesheet.py +++ b/gramps/gen/plug/docgen/stylesheet.py @@ -31,6 +31,7 @@ #------------------------------------------------------------------------- import os from xml.sax.saxutils import escape +import io def escxml(string): """ @@ -148,7 +149,7 @@ class StyleSheetList(object): """ Saves the current StyleSheet definitions to the associated file. """ - xml_file = open(self.__file, "w") + xml_file = io.open(self.__file, "w", encoding='utf-8') xml_file.write("\n") xml_file.write('\n') @@ -211,7 +212,7 @@ class StyleSheetList(object): if os.path.isfile(self.__file): parser = make_parser() parser.setContentHandler(SheetParser(self)) - the_file = open(self.__file) + the_file = io.open(self.__file, encoding='utf-8') parser.parse(the_file) the_file.close() except (IOError, OSError, SAXParseException): diff --git a/gramps/gen/plug/report/_book.py b/gramps/gen/plug/report/_book.py index bb37ead68..7279d137c 100644 --- a/gramps/gen/plug/report/_book.py +++ b/gramps/gen/plug/report/_book.py @@ -31,6 +31,8 @@ # Standard Python modules # #------------------------------------------------------------------------- +import os +import io from ...const import GRAMPS_LOCALE as glocale _ = glocale.get_translation().gettext @@ -41,7 +43,6 @@ _ = glocale.get_translation().gettext #------------------------------------------------------------------------ import logging log = logging.getLogger(".Book") -import os #------------------------------------------------------------------------- # @@ -318,7 +319,7 @@ class BookList(object): """ Saves the current BookList to the associated file. """ - f = open(self.file, "w") + f = io.open(self.file, "w", encoding='utf-8') f.write("\n") f.write('\n') for name in sorted(self.bookmap): # enable a diff of archived copies @@ -370,7 +371,7 @@ class BookList(object): try: p = make_parser() p.setContentHandler(BookParser(self, self.dbase)) - the_file = open(self.file) + the_file = io.open(self.file, encoding='utf-8') p.parse(the_file) the_file.close() except (IOError, OSError, ValueError, SAXParseException, KeyError, diff --git a/gramps/gen/plug/report/_options.py b/gramps/gen/plug/report/_options.py index 7f13996f0..379b89f58 100644 --- a/gramps/gen/plug/report/_options.py +++ b/gramps/gen/plug/report/_options.py @@ -36,6 +36,7 @@ Report option handling, including saving and parsing. import os import copy from xml.sax.saxutils import escape +import io def escxml(d): return escape(d, { '"' : '"' } ) @@ -475,7 +476,7 @@ class OptionListCollection(_options.OptionListCollection): if os.path.isfile(self.filename): p = make_parser() p.setContentHandler(OptionParser(self)) - the_file = open(self.filename) + the_file = io.open(self.filename, encoding = 'utf-8') p.parse(the_file) the_file.close() except (IOError, OSError, SAXParseException): @@ -965,7 +966,7 @@ class DocOptionListCollection(_options.OptionListCollection): if os.path.isfile(self.filename): p = make_parser() p.setContentHandler(DocOptionParser(self)) - the_file = open(self.filename) + the_file = io.open(self.filename, encoding = 'utf-8') p.parse(the_file) the_file.close() except (IOError, OSError, SAXParseException):