small fixes for Py3

master
idziubenko 3 years ago
parent 15e94c1388
commit 0ff7ce47bc

6
.gitignore vendored

@ -0,0 +1,6 @@
revert_changes_to_vmachine
push_to_vmachine*
.vscode
*.pyc
*.pyo
*.bak

@ -129,7 +129,7 @@ class Import:
""" """
self.ns = ns self.ns = ns
self.location = location self.location = location
self.filter = TnsFilter() self._filter = TnsFilter()
def setfilter(self, filter): def setfilter(self, filter):
""" """
@ -137,7 +137,7 @@ class Import:
@param filter: A filter to set. @param filter: A filter to set.
@type filter: L{TnsFilter} @type filter: L{TnsFilter}
""" """
self.filter = filter self._filter = filter
def apply(self, root): def apply(self, root):
""" """
@ -147,7 +147,7 @@ class Import:
@param root: A schema root. @param root: A schema root.
@type root: L{Element} @type root: L{Element}
""" """
if not self.filter.match(root, self.ns): if not self._filter.match(root, self.ns):
return return
if self.exists(root): if self.exists(root):
return return

@ -21,7 +21,7 @@ import hashlib
import crypt import crypt
import string import string
from random import choice from random import choice
from base64 import encodestring as _b64enc from base64 import encodebytes as _b64enc
b64encode = lambda x: _b64enc(x).rstrip() b64encode = lambda x: _b64enc(x).rstrip()
try: try:

@ -327,7 +327,7 @@ class ColorTerminalOutput(SaveAttrOutput):
""" """
Создать ESC строку Создать 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]) return "%s%s%s" % (attrs[0], ";".join(attrs[1:-1]), attrs[-1])
def outputText(self, s): def outputText(self, s):

@ -13,10 +13,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import absolute_import # from __future__ import absolute_import
from .output import BaseOutput, BasePositionOutput from .output import BaseOutput, BasePositionOutput
from calculate.lib.utils.text import _uu8 from calculate.lib.utils.text import _uu8
from io import IOBase
class Print(object): class Print(object):
""" """
@ -28,7 +28,7 @@ class Print(object):
self.output = output self.output = output
self.position_controller = position_controller self.position_controller = position_controller
self.buffer = [] self.buffer = []
if isinstance(printfunc, file): if isinstance(printfunc, IOBase):
self.printfunc = printfunc.write self.printfunc = printfunc.write
self.flush = printfunc.flush self.flush = printfunc.flush
else: else:

@ -811,8 +811,9 @@ def readLinesFile(filename, grab=False):
yield line.rstrip('\n') yield line.rstrip('\n')
except (OSError, IOError): except (OSError, IOError):
pass pass
finally: # at least in python3, yield should give StopIteration automatically
raise StopIteration # finally:
# raise StopIteration
def isEmptyFile(filename, grab=False): def isEmptyFile(filename, grab=False):

Loading…
Cancel
Save