From 04b45a983120c7fd5abc2e9c70e1b4bdf2e42e27 Mon Sep 17 00:00:00 2001 From: parmentelat Date: Thu, 13 Dec 2018 10:27:55 +0100 Subject: [PATCH] get rid of the codecs library, that caused bytes vs str issues, for no benefit; means all is utf-8 --- plc_config.py | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/plc_config.py b/plc_config.py index 178834d..e076032 100644 --- a/plc_config.py +++ b/plc_config.py @@ -8,7 +8,6 @@ # Copyright (C) 2006 The Trustees of Princeton University # -import codecs import os import re import sys @@ -699,12 +698,12 @@ DO NOT EDIT. This file was automatically generated at # Get rid of the surrounding newlines return header.strip().split(os.linesep) - def output_shell(self, show_comments=True, encoding="utf-8"): + def output_shell(self, show_comments=True): """ Return variables as a shell script. """ - buf = codecs.lookup(encoding)[3](StringIO()) + buf = StringIO() buf.writelines(["# " + line + os.linesep for line in self._header()]) for (category_id, (category, variables)) in self._variables.items(): @@ -724,12 +723,12 @@ DO NOT EDIT. This file was automatically generated at return buf.getvalue() - def output_php(self, encoding="utf-8"): + def output_php(self): """ Return variables as a PHP script. """ - buf = codecs.lookup(encoding)[3](StringIO()) + buf = StringIO() buf.write(" section of configuration. """ - if self._dom is None or \ - not self._dom.getElementsByTagName("comps"): + if (self._dom is None or not self._dom.getElementsByTagName("comps")): return comps = self._dom.getElementsByTagName("comps")[0] impl = xml.dom.minidom.getDOMImplementation() doc = impl.createDocument(None, "comps", None) - buf = codecs.lookup(encoding)[3](StringIO()) + buf = StringIO() # Pop it off the DOM temporarily parent = comps.parentNode parent.removeChild(comps) doc.replaceChild(comps, doc.documentElement) - doc.writexml(buf, encoding=encoding) + doc.writexml(buf) # Put it back parent.appendChild(comps) -- 2.43.0