--- a/CodeFileTreeNode.py Thu Oct 04 12:09:23 2018 +0300
+++ b/CodeFileTreeNode.py Thu Oct 04 17:24:40 2018 +0300
@@ -27,8 +27,9 @@
+from builtins import str as text +from copy import deepcopy -from copy import deepcopy
from xmlclass import GenerateParserFromXSDstring
@@ -124,7 +125,7 @@
self.GetCTRoot().logger.write_warning(XSDSchemaErrorMessage.format(a1=fname, a2=lnum, a3=src))
self.CreateCodeFileBuffer(True)
- msg = _("Couldn't load confnode parameters {a1} :\n {a2}").format(a1=self.CTNName(), a2=unicode(exc))
+ msg = _("Couldn't load confnode parameters {a1} :\n {a2}").format(a1=self.CTNName(), a2=text(exc)) self.GetCTRoot().logger.write_error(msg)
self.GetCTRoot().logger.write_error(traceback.format_exc())
--- a/ConfigTreeNode.py Thu Oct 04 12:09:23 2018 +0300
+++ b/ConfigTreeNode.py Thu Oct 04 17:24:40 2018 +0300
@@ -36,10 +36,11 @@
+from builtins import str as text from xmlclass import GenerateParserFromXSDstring
from PLCControler import LOCATION_CONFNODE
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
@@ -277,7 +278,7 @@
if CTNLDFLAGS is not None:
# LDFLAGS can be either string
- if isinstance(CTNLDFLAGS, (str, unicode)):
+ if isinstance(CTNLDFLAGS, (str, text)): elif isinstance(CTNLDFLAGS, list):
@@ -627,7 +628,7 @@
self.MandatoryParams = ("BaseParams", self.BaseParams)
- msg = _("Couldn't load confnode base parameters {a1} :\n {a2}").format(a1=ConfNodeName, a2=unicode(exc))
+ msg = _("Couldn't load confnode base parameters {a1} :\n {a2}").format(a1=ConfNodeName, a2=text(exc)) self.GetCTRoot().logger.write_error(msg)
self.GetCTRoot().logger.write_error(traceback.format_exc())
@@ -644,7 +645,7 @@
self.CTNParams = (name, obj)
- msg = _("Couldn't load confnode parameters {a1} :\n {a2}").format(a1=ConfNodeName, a2=unicode(exc))
+ msg = _("Couldn't load confnode parameters {a1} :\n {a2}").format(a1=ConfNodeName, a2=text(exc)) self.GetCTRoot().logger.write_error(msg)
self.GetCTRoot().logger.write_error(traceback.format_exc())
@@ -657,6 +658,6 @@
self.CTNAddChild(pname, ptype)
- msg = _("Could not add child \"{a1}\", type {a2} :\n{a3}\n").format(a1=pname, a2=ptype, a3=unicode(exc))
+ msg = _("Could not add child \"{a1}\", type {a2} :\n{a3}\n").format(a1=pname, a2=ptype, a3=text(exc)) self.GetCTRoot().logger.write_error(msg)
self.GetCTRoot().logger.write_error(traceback.format_exc())
--- a/IDEFrame.py Thu Oct 04 12:09:23 2018 +0300
+++ b/IDEFrame.py Thu Oct 04 17:24:40 2018 +0300
@@ -26,6 +26,7 @@
from types import TupleType
+from builtins import str as text @@ -108,7 +109,7 @@
def DecodeFileSystemPath(path, is_base64=True):
path = base64.decodestring(path)
- return unicode(path, sys.getfilesystemencoding())
+ return text(path, sys.getfilesystemencoding()) def AppendMenu(parent, help, id, kind, text):
--- a/connectors/WAMP/__init__.py Thu Oct 04 12:09:23 2018 +0300
+++ b/connectors/WAMP/__init__.py Thu Oct 04 17:24:40 2018 +0300
@@ -28,6 +28,7 @@
from threading import Thread, Event
+from builtins import str as text from twisted.internet import reactor, threads
from autobahn.twisted import wamp
@@ -83,7 +84,7 @@
# create a WAMP application session factory
component_config = types.ComponentConfig(
session_factory = wamp.ApplicationSessionFactory(
@@ -109,7 +110,7 @@
reactor.run(installSignalHandlers=False)
def WampSessionProcMapper(funcname):
- wampfuncname = unicode('.'.join((ID, funcname)))
+ wampfuncname = text('.'.join((ID, funcname))) def catcher_func(*args, **kwargs):
if _WampSession is not None:
--- a/controls/VariablePanel.py Thu Oct 04 12:09:23 2018 +0300
+++ b/controls/VariablePanel.py Thu Oct 04 17:24:40 2018 +0300
@@ -26,6 +26,7 @@
from __future__ import absolute_import
from types import TupleType, StringType, UnicodeType
+from builtins import str as text @@ -607,7 +608,7 @@
model = re.compile("%[IQM][XBWLD]?(.*\.|)")
prefix = model.match(old_location).group(0)
addr = int(re.split(model, old_location)[-1]) + 1
- row_content.Location = prefix + unicode(addr)
+ row_content.Location = prefix + text(addr) if not row_content.Class:
row_content.Class = self.DefaultTypes.get(self.Filter, self.Filter)
--- a/dialogs/ForceVariableDialog.py Thu Oct 04 12:09:23 2018 +0300
+++ b/dialogs/ForceVariableDialog.py Thu Oct 04 17:24:40 2018 +0300
@@ -25,6 +25,7 @@
from __future__ import absolute_import
+from builtins import str as text @@ -200,7 +201,7 @@
def ToggleBoolValue(self, event):
value = self.ToggleButton.GetValue()
- self.ValueTextCtrl.SetValue(unicode(value))
+ self.ValueTextCtrl.SetValue(text(value)) --- a/editors/CodeFileEditor.py Thu Oct 04 12:09:23 2018 +0300
+++ b/editors/CodeFileEditor.py Thu Oct 04 17:24:40 2018 +0300
@@ -25,6 +25,7 @@
from __future__ import absolute_import
+from builtins import str as text @@ -32,6 +33,7 @@
from six.moves import xrange
from plcopen.plcopen import TestTextElement
from plcopen.structures import TestIdentifier, IEC_KEYWORDS, DefaultType
from controls import CustomGrid, CustomTable
@@ -630,7 +632,7 @@
- return unicode(self.data[row].get(self.GetColLabelValue(col, False), ""))
+ return text(self.data[row].get(self.GetColLabelValue(col, False), "")) def _updateColAttrs(self, grid):
--- a/etherlab/CommonEtherCATFunction.py Thu Oct 04 12:09:23 2018 +0300
+++ b/etherlab/CommonEtherCATFunction.py Thu Oct 04 17:24:40 2018 +0300
@@ -9,8 +9,10 @@
# See COPYING file for copyrights details.
from __future__ import absolute_import
+from builtins import str as text mailbox_protocols = ["AoE", "EoE", "CoE", "FoE", "SoE", "VoE"]
@@ -894,7 +896,7 @@
for element in device.getType().getcontent():
- if data != "" and isinstance(data, unicode):
+ if data != "" and isinstance(data, text): for vendor_spec_string in vendor_spec_strings:
if data == vendor_spec_string:
self.OrderIdx = vendor_spec_strings.index(data)+1
@@ -913,7 +915,7 @@
# element2-1; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<GroupType>
data = device.getGroupType()
- if data is not None and isinstance(data, unicode):
+ if data is not None and isinstance(data, text): for vendor_spec_string in vendor_spec_strings:
if data == vendor_spec_string:
self.GroupIdx = vendor_spec_strings.index(data)+1
@@ -937,7 +939,7 @@
for device_item in group_etc["devices"]:
if device == device_item[1]:
- if data is not None and isinstance(data, unicode):
+ if data is not None and isinstance(data, text): for vendor_spec_string in vendor_spec_strings:
if data == vendor_spec_string:
self.GroupIdx = vendor_spec_strings.index(data)+1
@@ -961,7 +963,7 @@
for device_item in group_etc["devices"]:
if device == device_item[1]:
- if data != "" and isinstance(data, unicode):
+ if data != "" and isinstance(data, text): for vendor_spec_string in vendor_spec_strings:
if data == vendor_spec_string:
@@ -980,7 +982,7 @@
for element in device.getName():
if element.getLcId() == 1 or element.getLcId() == 1033:
data = element.getcontent()
- if data != "" and isinstance(data, unicode):
+ if data != "" and isinstance(data, text): for vendor_spec_string in vendor_spec_strings:
if data == vendor_spec_string:
self.NameIdx = vendor_spec_strings.index(data)+1
@@ -1000,7 +1002,7 @@
# element5-1; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Image16x14>
if device.getcontent() is not None:
data = device.getcontent()
- if data is not None and isinstance(data, unicode):
+ if data is not None and isinstance(data, text): for vendor_spec_string in vendor_spec_strings:
if data == vendor_spec_string:
self.ImgIdx = vendor_spec_strings.index(data)+1
@@ -1024,7 +1026,7 @@
for device_item in group_etc["devices"]:
if device == device_item[1]:
- if data is not None and isinstance(data, unicode):
+ if data is not None and isinstance(data, text): for vendor_spec_string in vendor_spec_strings:
if data == vendor_spec_string:
self.ImgIdx = vendor_spec_strings.index(data)+1
--- a/etherlab/etherlab.py Thu Oct 04 12:09:23 2018 +0300
+++ b/etherlab/etherlab.py Thu Oct 04 17:24:40 2018 +0300
@@ -13,8 +13,9 @@
+from builtins import str as text
@@ -227,7 +228,7 @@
self.GetCTRoot().logger.write_warning(
XSDSchemaErrorMessage % (filepath + error))
- self.modules_infos, error = None, unicode(exc)
+ self.modules_infos, error = None, text(exc) if self.modules_infos is not None:
--- a/py_ext/PythonFileCTNMixin.py Thu Oct 04 12:09:23 2018 +0300
+++ b/py_ext/PythonFileCTNMixin.py Thu Oct 04 17:24:40 2018 +0300
@@ -27,8 +27,9 @@
from __future__ import absolute_import
+from builtins import str as text import util.paths as paths
from xmlclass import GenerateParserFromXSD
from CodeFileTreeNode import CodeFile
@@ -74,7 +75,7 @@
self.CreateCodeFileBuffer(False)
self.GetCTRoot().logger.write_error(
--- a/runtime/WampClient.py Thu Oct 04 12:09:23 2018 +0300
+++ b/runtime/WampClient.py Thu Oct 04 17:24:40 2018 +0300
@@ -28,6 +28,7 @@
+from builtins import str as text from autobahn.twisted import wamp
from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS
from autobahn.wamp import types, auth
@@ -131,7 +132,7 @@
yield self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions)
for name in SubscribedEvents:
- yield self.subscribe(GetCallee(name), unicode(name))
+ yield self.subscribe(GetCallee(name), text(name)) --- a/svgui/pyjs/jsonrpc/django/jsonrpc.py Thu Oct 04 12:09:23 2018 +0300
+++ b/svgui/pyjs/jsonrpc/django/jsonrpc.py Thu Oct 04 17:24:40 2018 +0300
@@ -4,6 +4,7 @@
from __future__ import absolute_import
+from builtins import str as text from django.core.serializers import serialize
@@ -74,7 +75,7 @@
for errorval in form.errors[error]:
- d[error].append(unicode(errorval))
+ d[error].append(text(errorval)) @@ -101,7 +102,7 @@
field_type = field.__class__.__name__
for n, m in field.error_messages.items():
res['error_messages'] = msgs
if field_type in ['ComboField', 'MultiValueField', 'SplitDateTimeField']:
res['fields'] = map(describe_field, field.fields)
--- a/svgui/pyjs/pyjs.py Thu Oct 04 12:09:23 2018 +0300
+++ b/svgui/pyjs/pyjs.py Thu Oct 04 17:24:40 2018 +0300
@@ -22,6 +22,7 @@
+from builtins import str as text from six.moves import cStringIO
# the standard location for builtins (e.g. pyjslib) can be
@@ -1359,7 +1360,7 @@
elif isinstance(node.value, basestring):
- if isinstance(node.value, unicode):
+ if isinstance(node.value, text): return "String('%s')" % escapejs(v)
--- a/svgui/svgui_server.py Thu Oct 04 12:09:23 2018 +0300
+++ b/svgui/svgui_server.py Thu Oct 04 17:24:40 2018 +0300
@@ -25,6 +25,7 @@
from __future__ import absolute_import
+from builtins import str as text from nevow import tags, loaders
import simplejson as json # pylint: disable=import-error
@@ -122,13 +123,13 @@
def HMIinitialisation(self):
for gadget in svguiWidgets.values():
- gadgets.append(unicode(json.dumps(gadget, default=get_object_init_state, indent=2), 'ascii'))
+ gadgets.append(text(json.dumps(gadget, default=get_object_init_state, indent=2), 'ascii')) d = self.callRemote('init', gadgets)
d.addCallback(self.HMIinitialised)
def sendData(self, data):
- return self.callRemote('receiveData', unicode(json.dumps(data, default=get_object_current_state, indent=2), 'ascii'))
+ return self.callRemote('receiveData', text(json.dumps(data, default=get_object_current_state, indent=2), 'ascii')) def setattr(self, id, attrname, value):
@@ -139,7 +140,7 @@
gad = SvguiWidget(args[0], id, **kwargs)
- gadget = [unicode(json.dumps(gad, default=get_object_init_state, indent=2), 'ascii')]
+ gadget = [text(json.dumps(gad, default=get_object_init_state, indent=2), 'ascii')] interface = website.getHMI()
if isinstance(interface, SVGUI_HMI) and interface.initialised:
interface.callRemote('init', gadget)
--- a/tests/tools/check_source.sh Thu Oct 04 12:09:23 2018 +0300
+++ b/tests/tools/check_source.sh Thu Oct 04 17:24:40 2018 +0300
@@ -357,6 +357,7 @@
# python3 compatibility checks
enable=$enable,W1648 # (bad-python3-import) Module moved in Python 3
enable=$enable,W1613 # (xrange-builtin) xrange built-in referenced
+ enable=$enable,W1612 # (unicode-builtin) unicode built-in referenced --- a/util/paths.py Thu Oct 04 12:09:23 2018 +0300
+++ b/util/paths.py Thu Oct 04 17:24:40 2018 +0300
@@ -26,11 +26,12 @@
from __future__ import absolute_import
+from builtins import str as text if isinstance(file, str):
- file = unicode(file, sys.getfilesystemencoding())
+ file = text(file, sys.getfilesystemencoding()) --- a/xmlclass/xmlclass.py Thu Oct 04 12:09:23 2018 +0300
+++ b/xmlclass/xmlclass.py Thu Oct 04 17:24:40 2018 +0300
@@ -32,6 +32,8 @@
from xml.dom import minidom
from xml.sax.saxutils import unescape
from collections import OrderedDict
+from builtins import str as text from six.moves import xrange
@@ -50,9 +52,9 @@
def NodeSetAttr(node, name, value):
attr = minidom.Attr(name)
- attr.childNodes[0] = text
+ attr.childNodes[0] = txt @@ -138,13 +140,13 @@
if len(attr.childNodes) == 1:
- return unicode(unescape(attr.childNodes[0].data))
+ return text(unescape(attr.childNodes[0].data))
for node in attr.childNodes:
if not (node.nodeName == "#text" and node.data.strip() == u''):
- text += unicode(unescape(node.data))
+ txt += text(unescape(node.data))