fix wrong-import-order. first standard modules are imported, then others
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 28 Sep 2017 15:17:57 +0300
changeset 1832 0f1081928d65
parent 1831 56b48961cc68
child 1833 2269739dd098
fix wrong-import-order. first standard modules are imported, then others
BeremizIDE.py
PLCControler.py
PLCGenerator.py
PLCOpenEditor.py
ProjectController.py
connectors/PYRO/__init__.py
connectors/WAMP/__init__.py
controls/DebugVariablePanel/DebugVariableGraphicViewer.py
controls/DebugVariablePanel/DebugVariableItem.py
controls/LogViewer.py
controls/TextCtrlAutoComplete.py
docutil/docsvg.py
editors/LDViewer.py
graphics/GraphicCommons.py
i18n/mki18n.py
plcopen/plcopen.py
plcopen/structures.py
runtime/PLCObject.py
runtime/WampClient.py
svgui/pyjs/build.py
svgui/pyjs/jsonrpc/jsonrpc.py
svgui/pyjs/lib/pyjslib.py
svgui/svgui.py
targets/toolchain_gcc.py
targets/toolchain_makefile.py
tests/tools/check_source.sh
tests/tools/conftest.py
tests/tools/test_CustomIntCtrl.py
tests/tools/test_application.py
util/ProcessLogger.py
wxglade_hmi/wxglade_hmi.py
xmlclass/xmlclass.py
--- a/BeremizIDE.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/BeremizIDE.py	Thu Sep 28 15:17:57 2017 +0300
@@ -29,21 +29,20 @@
 import tempfile
 import shutil
 import random
+import re
 import time
-import version
-
-from types import ListType
-
+import types
+import commands
+from time import time as gettime
+from threading import Lock, Timer, currentThread
+
+import cPickle
 import wx.lib.buttons
 import wx.lib.statbmp
 import wx.stc
-import cPickle
-import types
-import re
-import commands
-from threading import Lock, Timer, currentThread
-from time import time as gettime
-
+
+
+import version
 import util.paths as paths
 from docutil import OpenHtmlFrame
 from editors.EditorPanel import EditorPanel
@@ -723,7 +722,7 @@
 
     def GenerateMenuRecursive(self, items, menu):
         for kind, infos in items:
-            if isinstance(kind, ListType):
+            if isinstance(kind, types.ListType):
                 text, id = infos
                 submenu = wx.Menu('')
                 self.GenerateMenuRecursive(kind, submenu)
--- a/PLCControler.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/PLCControler.py	Thu Sep 28 15:17:57 2017 +0300
@@ -25,15 +25,17 @@
 
 from xml.dom import minidom
 from types import StringType, UnicodeType, TupleType
-from lxml import etree
 from copy import deepcopy
 import os
 import sys
 import re
 import datetime
-import util.paths as paths
 from time import localtime
 from collections import OrderedDict, namedtuple
+
+from lxml import etree
+
+import util.paths as paths
 from util.TranslationCatalogs import NoTranslate
 from plcopen import *
 from graphics.GraphicCommons import *
--- a/PLCGenerator.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/PLCGenerator.py	Thu Sep 28 15:17:57 2017 +0300
@@ -22,10 +22,12 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+
+from types import *
+import re
 from plcopen import PLCOpenParser
 from plcopen.structures import *
-from types import *
-import re
+
 
 # Dictionary associating PLCOpen variable categories to the corresponding
 # IEC 61131-3 variable categories
--- a/PLCOpenEditor.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/PLCOpenEditor.py	Thu Sep 28 15:17:57 2017 +0300
@@ -25,15 +25,15 @@
 
 
 from __future__ import print_function
-import wx
 import os
 import sys
 import getopt
 
+import wx
+
 import version
 import util.paths as paths
 import util.ExceptionHandler
-
 from IDEFrame import IDEFrame, AppendMenu
 from IDEFrame import \
     TITLE, \
--- a/ProjectController.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/ProjectController.py	Thu Sep 28 15:17:57 2017 +0300
@@ -30,9 +30,7 @@
 import sys
 import traceback
 import time
-import features
 import shutil
-import wx
 import re
 import tempfile
 from math import ceil
@@ -43,6 +41,9 @@
 from weakref import WeakKeyDictionary
 from itertools import izip
 
+import wx
+
+import features
 import targets
 import connectors
 import util.paths as paths
--- a/connectors/PYRO/__init__.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/connectors/PYRO/__init__.py	Thu Sep 28 15:17:57 2017 +0300
@@ -24,16 +24,18 @@
 
 
 from __future__ import print_function
-import Pyro
-import Pyro.core
-import Pyro.util
-from Pyro.errors import PyroError
 import traceback
 from time import sleep
 import copy
 import socket
 import os.path
 
+import Pyro
+import Pyro.core
+import Pyro.util
+from Pyro.errors import PyroError
+
+
 service_type = '_PYRO._tcp.local.'
 # this module attribute contains a list of DNS-SD (Zeroconf) service types
 # supported by this connector confnode.
--- a/connectors/WAMP/__init__.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/connectors/WAMP/__init__.py	Thu Sep 28 15:17:57 2017 +0300
@@ -27,13 +27,15 @@
 import sys
 import traceback
 import atexit
+from threading import Thread, Event
+
 from twisted.internet import reactor, threads
 from autobahn.twisted import wamp
 from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS
 from autobahn.wamp import types
 from autobahn.wamp.exception import TransportLost
 from autobahn.wamp.serializer import MsgPackSerializer
-from threading import Thread, Event
+
 
 _WampSession = None
 _WampConnection = None
--- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Thu Sep 28 15:17:57 2017 +0300
@@ -24,10 +24,10 @@
 
 from types import TupleType
 from time import time as gettime
+from distutils.version import LooseVersion
+
 import numpy
-
 import wx
-
 import matplotlib
 import matplotlib.pyplot
 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
@@ -36,13 +36,11 @@
 from mpl_toolkits.mplot3d import Axes3D
 
 from editors.DebugViewer import REFRESH_PERIOD
-
 from DebugVariableItem import DebugVariableItem
 from DebugVariableViewer import *
 from GraphButton import GraphButton
 
 
-from distutils.version import LooseVersion
 if LooseVersion(matplotlib.__version__) >= LooseVersion("1.5.0"):
     from cycler import cycler
 
--- a/controls/DebugVariablePanel/DebugVariableItem.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/controls/DebugVariablePanel/DebugVariableItem.py	Thu Sep 28 15:17:57 2017 +0300
@@ -22,9 +22,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+import binascii
 import numpy
-import binascii
-
 from graphics.DebugDataConsumer import DebugDataConsumer, TYPE_TRANSLATOR
 
 # -------------------------------------------------------------------------------
--- a/controls/LogViewer.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/controls/LogViewer.py	Thu Sep 28 15:17:57 2017 +0300
@@ -25,15 +25,16 @@
 
 from datetime import datetime
 from time import time as gettime
+from weakref import proxy
+
 import numpy
-
 import wx
 
 from controls.CustomToolTip import CustomToolTip, TOOLTIP_WAIT_PERIOD
 from editors.DebugViewer import DebugViewer, REFRESH_PERIOD
 from targets.typemapping import LogLevelsCount, LogLevels
 from util.BitmapLibrary import GetBitmap
-from weakref import proxy
+
 
 THUMB_SIZE_RATIO = 1. / 8.
 
--- a/controls/TextCtrlAutoComplete.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/controls/TextCtrlAutoComplete.py	Thu Sep 28 15:17:57 2017 +0300
@@ -22,8 +22,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+import cPickle
 import wx
-import cPickle
 
 MAX_ITEM_COUNT = 10
 MAX_ITEM_SHOWN = 6
--- a/docutil/docsvg.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/docutil/docsvg.py	Thu Sep 28 15:17:57 2017 +0300
@@ -22,9 +22,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-import wx
 import os
 import subprocess
+import wx
 
 
 def get_inkscape_path():
--- a/editors/LDViewer.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/editors/LDViewer.py	Thu Sep 28 15:17:57 2017 +0300
@@ -22,10 +22,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-import wx
 import time
 from types import *
 
+import wx
+
 from Viewer import *
 
 
--- a/graphics/GraphicCommons.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/graphics/GraphicCommons.py	Thu Sep 28 15:17:57 2017 +0300
@@ -22,12 +22,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-import wx
+
 from math import *
 from types import *
 import datetime
 from threading import Lock, Timer
 
+import wx
 from graphics.ToolTipProducer import ToolTipProducer
 from graphics.DebugDataConsumer import DebugDataConsumer
 
--- a/i18n/mki18n.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/i18n/mki18n.py	Thu Sep 28 15:17:57 2017 +0300
@@ -81,8 +81,8 @@
 from __future__ import print_function
 import os
 import sys
+import re
 import wx
-import re
 
 # -----------------------------------------------------------------------------
 # Global variables
--- a/plcopen/plcopen.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/plcopen/plcopen.py	Thu Sep 28 15:17:57 2017 +0300
@@ -23,12 +23,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-from xmlclass import *
 from types import *
 import os
 import re
+from collections import OrderedDict
+
 from lxml import etree
-from collections import OrderedDict
+
+from xmlclass import *
 import util.paths as paths
 
 """
--- a/plcopen/structures.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/plcopen/structures.py	Thu Sep 28 15:17:57 2017 +0300
@@ -24,8 +24,9 @@
 
 import string
 import re
+from collections import OrderedDict
+
 from plcopen import LoadProject
-from collections import OrderedDict
 from definitions import *
 
 TypeHierarchy = dict(TypeHierarchy_list)
--- a/runtime/PLCObject.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/runtime/PLCObject.py	Thu Sep 28 15:17:57 2017 +0300
@@ -21,7 +21,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-import Pyro.core as pyro
+
 from threading import Timer, Thread, Lock, Semaphore, Event
 import ctypes
 import os
@@ -29,8 +29,11 @@
 import types
 import sys
 import traceback
+from time import time
+
+import Pyro.core as pyro
+
 from targets.typemapping import LogLevelsDefault, LogLevelsCount, TypeTranslator, UnpackDebugBuffer
-from time import time
 
 
 if os.name in ("nt", "ce"):
--- a/runtime/WampClient.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/runtime/WampClient.py	Thu Sep 28 15:17:57 2017 +0300
@@ -24,13 +24,15 @@
 
 from __future__ import print_function
 import sys
+import json
+
 from autobahn.twisted import wamp
 from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS
 from twisted.internet.defer import inlineCallbacks
 from autobahn.wamp import types
 from autobahn.wamp.serializer import MsgPackSerializer
 from twisted.internet.protocol import ReconnectingClientFactory
-import json
+
 
 _WampSession = None
 _PySrv = None
--- a/svgui/pyjs/build.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/svgui/pyjs/build.py	Thu Sep 28 15:17:57 2017 +0300
@@ -4,18 +4,16 @@
 import sys
 import os
 import shutil
+import time
+import re
+from hashlib import md5
 from copy import copy
 from os.path import join, dirname, basename, abspath, split, isfile, isdir
 from optparse import OptionParser
+from cStringIO import StringIO
+
 import pyjs
-import time
-from cStringIO import StringIO
-try:
-    # Python 2.5 and above
-    from hashlib import md5
-except Exception:
-    import md5
-import re
+
 
 usage = """
   usage: %prog [options] <application module name or path>
--- a/svgui/pyjs/jsonrpc/jsonrpc.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/svgui/pyjs/jsonrpc/jsonrpc.py	Thu Sep 28 15:17:57 2017 +0300
@@ -1,6 +1,6 @@
-import gluon.contrib.simplejson as simplejson
 import types
 import sys
+import gluon.contrib.simplejson as simplejson
 
 
 class JSONRPCServiceBase:
--- a/svgui/pyjs/lib/pyjslib.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/svgui/pyjs/lib/pyjslib.py	Thu Sep 28 15:17:57 2017 +0300
@@ -233,7 +233,7 @@
 
 # as comment on line 20 says
 # import sys should be below
-import sys  # noqa
+import sys  # noqa # pylint: disable=C0411
 
 
 class BaseException:
--- a/svgui/svgui.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/svgui/svgui.py	Thu Sep 28 15:17:57 2017 +0300
@@ -23,11 +23,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-import wx
 import os
 import sys
 import shutil
 
+import wx
 from pyjs import translate
 
 import util.paths as paths
--- a/targets/toolchain_gcc.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/targets/toolchain_gcc.py	Thu Sep 28 15:17:57 2017 +0300
@@ -26,8 +26,10 @@
 import os
 import re
 import operator
+import hashlib
+
 from util.ProcessLogger import ProcessLogger
-import hashlib
+
 
 includes_re = re.compile('\s*#include\s*["<]([^">]*)[">].*')
 
--- a/targets/toolchain_makefile.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/targets/toolchain_makefile.py	Thu Sep 28 15:17:57 2017 +0300
@@ -25,10 +25,11 @@
 import os
 import re
 import operator
+import hashlib
+import time
+
 from util.ProcessLogger import ProcessLogger
-import hashlib
 
-import time
 
 includes_re = re.compile('\s*#include\s*["<]([^">]*)[">].*')
 
--- a/tests/tools/check_source.sh	Thu Sep 28 12:20:40 2017 +0300
+++ b/tests/tools/check_source.sh	Thu Sep 28 15:17:57 2017 +0300
@@ -204,12 +204,12 @@
     enable=$enable,E1601          # print statement used
     enable=$enable,C0325          # (superfluous-parens) Unnecessary parens after keyword    
     enable=$enable,W0404          # reimported module    
-    # enable=$enable,C1001          # (old-style-class) Old-style class defined. Problem with PyJS
+    enable=$enable,C0411          # (wrong-import-order), ] standard import "import x" comes before "import y"
 
     # enable=$enable,W0403        # relative import
     # enable=$enable,W0622        # (redefined-builtin) Redefining built-in
     # enable=$enable,W0612        # unused-variable
-
+    # enable=$enable,C1001        # (old-style-class) Old-style class defined. Problem with PyJS
     # enable=
 
     options=
--- a/tests/tools/conftest.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/tests/tools/conftest.py	Thu Sep 28 15:17:57 2017 +0300
@@ -24,9 +24,10 @@
 
 import os
 import sys
+import time
+
 import pytest
 import xvfbwrapper
-import time
 
 # append module root directory to sys.path
 sys.path.append(
--- a/tests/tools/test_CustomIntCtrl.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/tests/tools/test_CustomIntCtrl.py	Thu Sep 28 15:17:57 2017 +0300
@@ -23,8 +23,9 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 import unittest
+import time
+
 import wx
-import time
 
 import conftest
 import controls.CustomIntCtrl
--- a/tests/tools/test_application.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/tests/tools/test_application.py	Thu Sep 28 15:17:57 2017 +0300
@@ -27,10 +27,11 @@
 import os
 import sys
 import unittest
+import time
+import traceback
+
 import pytest
 import wx
-import time
-import traceback
 import ddt
 
 import conftest
--- a/util/ProcessLogger.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/util/ProcessLogger.py	Thu Sep 28 15:17:57 2017 +0300
@@ -25,10 +25,10 @@
 import os
 import sys
 import time
-import wx
 import subprocess
 import ctypes
 from threading import Timer, Lock, Thread, Semaphore
+import wx
 if os.name == 'posix':
     from signal import SIGTERM, SIGKILL
 
--- a/wxglade_hmi/wxglade_hmi.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/wxglade_hmi/wxglade_hmi.py	Thu Sep 28 15:17:57 2017 +0300
@@ -23,12 +23,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-import wx
+
 import os
 import sys
 import shutil
 from xml.dom import minidom
 
+import wx
+
 import util.paths as paths
 from py_ext import PythonFileCTNMixin
 
--- a/xmlclass/xmlclass.py	Thu Sep 28 12:20:40 2017 +0300
+++ b/xmlclass/xmlclass.py	Thu Sep 28 15:17:57 2017 +0300
@@ -31,10 +31,11 @@
 from types import *
 from xml.dom import minidom
 from xml.sax.saxutils import escape, unescape, quoteattr
-from lxml import etree
 from new import classobj
 from collections import OrderedDict
 
+from lxml import etree
+
 
 def CreateNode(name):
     node = minidom.Node()