From 0ff7ce47bc8ea627e2a46be293cf6b867b91c909 Mon Sep 17 00:00:00 2001 From: idziubenko Date: Tue, 6 Jul 2021 14:46:31 +0300 Subject: [PATCH] small fixes for Py3 --- .gitignore | 6 ++++++ pym/calculate/contrib/suds/xsd/doctor.py | 6 +++--- pym/calculate/lib/encrypt.py | 2 +- pym/calculate/lib/utils/colortext/output.py | 2 +- pym/calculate/lib/utils/colortext/printing.py | 6 +++--- pym/calculate/lib/utils/files.py | 5 +++-- 6 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35ea017 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +revert_changes_to_vmachine +push_to_vmachine* +.vscode +*.pyc +*.pyo +*.bak \ No newline at end of file diff --git a/pym/calculate/contrib/suds/xsd/doctor.py b/pym/calculate/contrib/suds/xsd/doctor.py index 5a52e76..454cd49 100755 --- a/pym/calculate/contrib/suds/xsd/doctor.py +++ b/pym/calculate/contrib/suds/xsd/doctor.py @@ -129,7 +129,7 @@ class Import: """ self.ns = ns self.location = location - self.filter = TnsFilter() + self._filter = TnsFilter() def setfilter(self, filter): """ @@ -137,7 +137,7 @@ class Import: @param filter: A filter to set. @type filter: L{TnsFilter} """ - self.filter = filter + self._filter = filter def apply(self, root): """ @@ -147,7 +147,7 @@ class Import: @param root: A schema root. @type root: L{Element} """ - if not self.filter.match(root, self.ns): + if not self._filter.match(root, self.ns): return if self.exists(root): return diff --git a/pym/calculate/lib/encrypt.py b/pym/calculate/lib/encrypt.py index f0e96ac..bdb753b 100644 --- a/pym/calculate/lib/encrypt.py +++ b/pym/calculate/lib/encrypt.py @@ -21,7 +21,7 @@ import hashlib import crypt import string from random import choice -from base64 import encodestring as _b64enc +from base64 import encodebytes as _b64enc b64encode = lambda x: _b64enc(x).rstrip() try: diff --git a/pym/calculate/lib/utils/colortext/output.py b/pym/calculate/lib/utils/colortext/output.py index 5a6fc29..fb05dc0 100644 --- a/pym/calculate/lib/utils/colortext/output.py +++ b/pym/calculate/lib/utils/colortext/output.py @@ -327,7 +327,7 @@ class ColorTerminalOutput(SaveAttrOutput): """ Создать ESC строку """ - attrs = map(str, ['%s[' % self.escSymb] + attrs + ['m']) + attrs = list(map(str, ['%s[' % self.escSymb] + attrs + ['m'])) return "%s%s%s" % (attrs[0], ";".join(attrs[1:-1]), attrs[-1]) def outputText(self, s): diff --git a/pym/calculate/lib/utils/colortext/printing.py b/pym/calculate/lib/utils/colortext/printing.py index 5061184..0348cd4 100644 --- a/pym/calculate/lib/utils/colortext/printing.py +++ b/pym/calculate/lib/utils/colortext/printing.py @@ -13,10 +13,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import +# from __future__ import absolute_import from .output import BaseOutput, BasePositionOutput from calculate.lib.utils.text import _uu8 - +from io import IOBase class Print(object): """ @@ -28,7 +28,7 @@ class Print(object): self.output = output self.position_controller = position_controller self.buffer = [] - if isinstance(printfunc, file): + if isinstance(printfunc, IOBase): self.printfunc = printfunc.write self.flush = printfunc.flush else: diff --git a/pym/calculate/lib/utils/files.py b/pym/calculate/lib/utils/files.py index 9e62998..6948176 100644 --- a/pym/calculate/lib/utils/files.py +++ b/pym/calculate/lib/utils/files.py @@ -811,8 +811,9 @@ def readLinesFile(filename, grab=False): yield line.rstrip('\n') except (OSError, IOError): pass - finally: - raise StopIteration + # at least in python3, yield should give StopIteration automatically + # finally: + # raise StopIteration def isEmptyFile(filename, grab=False):