--- a/BeremizIDE.py Wed Oct 03 15:47:59 2018 +0300
+++ b/BeremizIDE.py Thu Oct 04 11:25:42 2018 +0300
@@ -35,7 +35,7 @@
from time import time as gettime
from threading import Lock, Timer, currentThread
+from six.moves import cPickle --- a/Beremiz_service.py Wed Oct 03 15:47:59 2018 +0300
+++ b/Beremiz_service.py Thu Oct 04 11:25:42 2018 +0300
@@ -32,7 +32,7 @@
from threading import Thread, Semaphore, Lock
+from six.moves import builtins @@ -143,7 +143,7 @@
if __name__ == '__main__':
- __builtin__.__dict__['_'] = lambda x: x
+ builtins.__dict__['_'] = lambda x: x # TODO: add a cmdline parameter if Trying Preloading Xenomai makes problem
@@ -162,12 +162,12 @@
- loc = __builtin__.__dict__.get('loc', None)
+ loc = builtins.__dict__.get('loc', None) wx.LogGui.EnableLogging(False)
wx.LogGui.EnableLogging(True)
- __builtin__.__dict__['loc'] = loc
+ builtins.__dict__['loc'] = loc # Define location for searching translation files
loc.AddCatalogLookupPathPrefix(localedir)
@@ -186,8 +186,8 @@
return wx.GetTranslation(message).encode(default_locale)
if __name__ == '__main__':
- __builtin__.__dict__['_'] = unicode_translation
- # __builtin__.__dict__['_'] = wx.GetTranslation
+ builtins.__dict__['_'] = unicode_translation + # builtins.__dict__['_'] = wx.GetTranslation # Life is hard... have a candy.
--- a/IDEFrame.py Wed Oct 03 15:47:59 2018 +0300
+++ b/IDEFrame.py Thu Oct 04 11:25:42 2018 +0300
@@ -24,13 +24,13 @@
from __future__ import absolute_import
from types import TupleType
+from six.moves import cPickle from editors.EditorPanel import EditorPanel
from editors.SFCViewer import SFC_Viewer
--- a/controls/TextCtrlAutoComplete.py Wed Oct 03 15:47:59 2018 +0300
+++ b/controls/TextCtrlAutoComplete.py Thu Oct 04 11:25:42 2018 +0300
@@ -24,7 +24,7 @@
from __future__ import absolute_import
+from six.moves import cPickle --- a/docutil/docpdf.py Wed Oct 03 15:47:59 2018 +0300
+++ b/docutil/docpdf.py Thu Oct 04 11:25:42 2018 +0300
@@ -34,16 +34,16 @@
" Return version of Adobe Acrobat executable or None"
- adobesoft = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe')
- for index in range(_winreg.QueryInfoKey(adobesoft)[0]):
- key = _winreg.EnumKey(adobesoft, index)
+ from six.moves import winreg + adobesoft = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe') + for index in range(winreg.QueryInfoKey(adobesoft)[0]): + key = winreg.EnumKey(adobesoft, index) if "acrobat" in key.lower():
- acrokey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key)
- for index in range(_winreg.QueryInfoKey(acrokey)[0]):
- numver = _winreg.EnumKey(acrokey, index)
+ acrokey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key) + for index in range(winreg.QueryInfoKey(acrokey)[0]): + numver = winreg.EnumKey(acrokey, index) - res = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver))
+ res = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver)) --- a/docutil/docsvg.py Wed Oct 03 15:47:59 2018 +0300
+++ b/docutil/docsvg.py Thu Oct 04 11:25:42 2018 +0300
@@ -31,13 +31,13 @@
""" Return the Inkscape path """
+ from six.moves import winreg - svgexepath = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE,
- 'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
+ svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, + 'Software\\Classes\\svgfile\\shell\\Inkscape\\command') - svgexepath = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE,
- 'Software\\Classes\\inkscape.svg\\shell\\open\\command')
+ svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, + 'Software\\Classes\\inkscape.svg\\shell\\open\\command') svgexepath = svgexepath.replace('"%1"', '')
return svgexepath.replace('"', '')
--- a/runtime/PLCObject.py Wed Oct 03 15:47:59 2018 +0300
+++ b/runtime/PLCObject.py Thu Oct 04 11:25:42 2018 +0300
@@ -23,7 +23,6 @@
from __future__ import absolute_import
from threading import Thread, Lock, Semaphore, Event, Condition
@@ -33,6 +32,7 @@
import _ctypes # pylint: disable=wrong-import-order
+from six.moves import _thread from runtime.typemapping import TypeTranslator
from runtime.loglevels import LogLevelsDefault, LogLevelsCount
@@ -104,7 +104,7 @@
meant to be called by worker thread (blocking)
- self._threadID = thread.get_ident()
+ self._threadID = _thread.get_ident() job(*args, **kwargs).do()
@@ -128,7 +128,7 @@
_job = job(*args, **kwargs)
- if self._threadID == thread.get_ident() or self._threadID is None:
+ if self._threadID == _thread.get_ident() or self._threadID is None: # if caller is worker thread execute immediately
--- a/svgui/pyjs/build.py Wed Oct 03 15:47:59 2018 +0300
+++ b/svgui/pyjs/build.py Thu Oct 04 11:25:42 2018 +0300
@@ -10,7 +10,7 @@
from os.path import join, basename, abspath, split, isfile, isdir
from optparse import OptionParser
-from cStringIO import StringIO
+from six.moves import cStringIO from svgui.pyjs import pyjs
@@ -254,7 +254,7 @@
# the selector templ is added to the selectScript function
select_tmpl = """O(["true","%s"],"%s");"""
- script_selectors = StringIO()
+ script_selectors = cStringIO() for platform, file_prefix in app_files:
print(select_tmpl % (platform, file_prefix), file=script_selectors)
@@ -453,7 +453,7 @@
mod_cache_html_output = open(join(output, mod_cache_name), "w")
- mod_cache_html_output = StringIO()
+ mod_cache_html_output = cStringIO() print(mod_cache_html_template % dict(
--- a/svgui/pyjs/pyjs.py Wed Oct 03 15:47:59 2018 +0300
+++ b/svgui/pyjs/pyjs.py Thu Oct 04 11:25:42 2018 +0300
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# pylint: disable=no-absolute-import
+# pylint: disable=no-absolute-import,bad-python3-import from __future__ import print_function
@@ -22,7 +22,7 @@
+from six.moves import cStringIO # the standard location for builtins (e.g. pyjslib) can be
# over-ridden by changing this. it defaults to sys.prefix
@@ -1443,7 +1443,7 @@
raise TranslationError("varargs are not supported in Lambdas", node)
raise TranslationError("kwargs are not supported in Lambdas", node)
- res = cStringIO.StringIO()
arg_names = list(node.argnames)
function_args = ", ".join(arg_names)
for child in node.getChildNodes():
@@ -1534,7 +1534,7 @@
- output = cStringIO.StringIO()
mod = compiler.parseFile(file_name)
Translator(module_name, module_name, module_name, src, debug, mod, output)
@@ -1683,7 +1683,7 @@
file_name = self.findFile(module_name + self.extension)
- output = cStringIO.StringIO()
@@ -1718,8 +1718,8 @@
def translate(self, module_name, is_app=True, debug=False,
- app_code = cStringIO.StringIO()
- lib_code = cStringIO.StringIO()
self.library_modules = []
--- a/tests/tools/check_source.sh Wed Oct 03 15:47:59 2018 +0300
+++ b/tests/tools/check_source.sh Thu Oct 04 11:25:42 2018 +0300
@@ -347,6 +347,9 @@
enable=$enable,W0612 # (unused-variable) Unused variable 'X'
enable=$enable,C0330 # (bad-continuation) Wrong hanging indentation before block
enable=$enable,R0123 # (literal-comparison) Comparison to literal
+ # python3 compatibility checks + enable=$enable,W1648 # (bad-python3-import) Module moved in Python 3 --- a/util/TranslationCatalogs.py Wed Oct 03 15:47:59 2018 +0300
+++ b/util/TranslationCatalogs.py Thu Oct 04 11:25:42 2018 +0300
@@ -25,14 +25,14 @@
from __future__ import absolute_import
+from six.moves import builtins -__builtin__.__dict__['_'] = wx.GetTranslation
+builtins.__dict__['_'] = wx.GetTranslation --- a/xmlclass/xmlclass.py Wed Oct 03 15:47:59 2018 +0300
+++ b/xmlclass/xmlclass.py Thu Oct 04 11:25:42 2018 +0300
@@ -31,7 +31,6 @@
from xml.dom import minidom
from xml.sax.saxutils import unescape
-from new import classobj
from collections import OrderedDict
@@ -1168,7 +1167,7 @@
classmembers["getElementInfos"] = generateGetElementInfos(self, classinfos)
classmembers["setElementValue"] = generateSetElementValue(self, classinfos)
- class_definition = classobj(str(name), bases, classmembers)
+ class_definition = type(str(name), bases, classmembers) setattr(class_definition, "__getattr__", generateGetattrMethod(self, class_definition, classinfos))
setattr(class_definition, "__setattr__", generateSetattrMethod(self, class_definition, classinfos))