clean-up: fix PEP8 E701 multiple statements on one line (colon)
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 16 Aug 2017 16:37:45 +0300
changeset 1756 08e4394ff4fb
parent 1755 624b9694cb0d
child 1757 0de89da92ee0
clean-up: fix PEP8 E701 multiple statements on one line (colon)
BeremizIDE.py
ProjectController.py
controls/EnhancedStatusBar.py
dialogs/DiscoveryDialog.py
dialogs/SFCDivergenceDialog.py
i18n/mki18n.py
runtime/NevowServer.py
runtime/WampClient.py
svgui/pyjs/pyjs.py
util/ProcessLogger.py
util/Zeroconf.py
--- a/BeremizIDE.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/BeremizIDE.py	Wed Aug 16 16:37:45 2017 +0300
@@ -149,7 +149,8 @@
             self.output.Freeze()
             self.lock.acquire()
             for s, style in self.stack:
-                if style is None: style = self.black_white
+                if style is None:
+                    style = self.black_white
                 if style != self.black_white:
                     self.output.StartStyling(self.output.GetLength(), 0xff)
 
--- a/ProjectController.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/ProjectController.py	Wed Aug 16 16:37:45 2017 +0300
@@ -803,8 +803,10 @@
         H_files.remove("LOCATED_VARIABLES.h")
         H_files = map(lambda filename: os.path.join(buildpath, filename), H_files)
         for H_file in H_files:
-            with file(H_file, 'r') as original: data = original.read()
-            with file(H_file, 'w') as modified: modified.write('#include "beremiz.h"\n' + data)
+            with file(H_file, 'r') as original:
+                data = original.read()
+            with file(H_file, 'w') as modified:
+                modified.write('#include "beremiz.h"\n' + data)
 
         self.logger.write(_("Extracting Located Variables...\n"))
         # Keep track of generated located variables for later use by self._Generate_C
--- a/controls/EnhancedStatusBar.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/controls/EnhancedStatusBar.py	Wed Aug 16 16:37:45 2017 +0300
@@ -238,7 +238,8 @@
         try:
             self.RemoveChild(self._items[pos].widget)
             self._items[pos].widget.Destroy()
-        except KeyError: pass
+        except KeyError:
+            pass
 
         self._items[pos] = EnhancedStatusBarItem(widget, pos, horizontalalignment, verticalalignment)
 
--- a/dialogs/DiscoveryDialog.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/dialogs/DiscoveryDialog.py	Wed Aug 16 16:37:45 2017 +0300
@@ -140,11 +140,13 @@
         self.LatestSelection = None
 
     def __del__(self):
-        if self.Browser is not None: self.Browser.cancel()
+        if self.Browser is not None:
+            self.Browser.cancel()
         self.ZeroConfInstance.close()
 
     def RefreshList(self):
-        if self.Browser is not None: self.Browser.cancel()
+        if self.Browser is not None:
+            self.Browser.cancel()
         self.Browser = ServiceBrowser(self.ZeroConfInstance, service_type, self)
 
     def OnRefreshButton(self, event):
--- a/dialogs/SFCDivergenceDialog.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/dialogs/SFCDivergenceDialog.py	Wed Aug 16 16:37:45 2017 +0300
@@ -81,7 +81,8 @@
             self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
             self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
             self.TypeRadioButtons[type] = radio_button
-            if first: focusbtn = type
+            if first:
+                focusbtn = type
             first = False
 
         # Create label for number of divergence sequences
--- a/i18n/mki18n.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/i18n/mki18n.py	Wed Aug 16 16:37:45 2017 +0300
@@ -110,6 +110,11 @@
     return languageDict
 
 
+def verbosePrint(verbose, str):
+    if verbose:
+        print str
+
+
 def processCustomFiles(filein, fileout, regexp, prefix=''):
     appfil_file = open(filein, 'r')
     messages_file = open(fileout, 'r')
@@ -183,7 +188,7 @@
     #   --files-from=app.fil        : The list of files is taken from the file: app.fil
     #   --output=                   : specifies the name of the output file (using a .pot extension)
     cmd = 'xgettext -s --no-wrap --language=Python --files-from=' + filelist + ' --output=' + fileout + ' --package-name ' + applicationName
-    if verbose: print cmd
+    verbosePrint(verbose, cmd)
     os.system(cmd)
 
     XSD_STRING_MODEL = re.compile("<xsd\:(?:element|attribute) name=\"([^\"]*)\"[^\>]*\>")
@@ -194,7 +199,7 @@
 
     # generate messages.po
     cmd = 'msginit --no-wrap --no-translator -i %s -l en_US.UTF-8 -o messages.po' % (fileout)
-    if verbose: print cmd
+    verbosePrint(verbose, cmd)
     os.system(cmd)
 
     languageDict = getlanguageDict()
@@ -206,7 +211,7 @@
             langPOfileName = "%s_%s.po" % (applicationName, langCode)
             if os.path.exists(langPOfileName):
                 cmd = 'msgmerge -s --no-wrap "%s" %s > "%s.new"' % (langPOfileName, fileout, langPOfileName)
-                if verbose: print cmd
+                verbosePrint(verbose, cmd)
                 os.system(cmd)
     os.chdir(currentDir)
 
@@ -234,14 +239,14 @@
                 for fileName in listOf_extraPo:
                     fileList += ("%s_%s.po " % (fileName, langCode))
                 cmd = "msgcat -s --no-wrap %s %s > %s.cat" % (langPOfileName, fileList, langPOfileName)
-                if verbose: print cmd
+                verbosePrint(verbose, cmd)
                 os.system(cmd)
                 if targetDir is None:
                     pass
                 else:
                     mo_targetDir = "%s/%s/LC_MESSAGES" % (targetDir, langCode)
                     cmd = "msgfmt --output-file=%s/%s.mo %s_%s.po.cat" % (mo_targetDir, applicationName, applicationName, langCode)
-                    if verbose: print cmd
+                    verbosePrint(verbose, cmd)
                     os.system(cmd)
     os.chdir(currentDir)
 
@@ -263,10 +268,11 @@
     called xx/LC_MESSAGES where 'xx' corresponds to the 2-letter language
     code.
     """
+
     if targetDir is None:
         targetDir = './locale'
-    if verbose:
-        print "Target directory for .mo files is: %s" % targetDir
+
+    verbosePrint(verbose, "Target directory for .mo files is: %s" % targetDir)
 
     if applicationDomain is None:
         applicationName = fileBaseOf(applicationDirectoryPath, withPath=0)
@@ -287,7 +293,7 @@
                 if not os.path.exists(mo_targetDir):
                     mkdir(mo_targetDir)
                 cmd = 'msgfmt --output-file="%s/%s.mo" "%s_%s.po"' % (mo_targetDir, applicationName, applicationName, langCode)
-                if verbose: print cmd
+                verbosePrint(verbose, cmd)
                 os.system(cmd)
     os.chdir(currentDir)
 
@@ -445,6 +451,15 @@
     option['verbose'] = 0
     option['domain'] = None
     option['moTarget'] = None
+    optionKey = {
+        '-e':         'forceEnglish',
+        '-m':         'mo',
+        '-p':         'po',
+        '-v':         'verbose',
+        '--domain':   'domain',
+        '--moTarget': 'moTarget',
+    }
+
     try:
         optionList, pargs = getopt.getopt(sys.argv[1:], validOptions, validLongOptions)
     except getopt.GetoptError, e:
@@ -454,12 +469,7 @@
         if (opt == '-h'):
             printUsage()
             sys.exit(0)
-        elif (opt == '-e'):         option['forceEnglish'] = 1
-        elif (opt == '-m'):         option['mo'] = 1
-        elif (opt == '-p'):         option['po'] = 1
-        elif (opt == '-v'):         option['verbose'] = 1
-        elif (opt == '--domain'):   option['domain'] = val
-        elif (opt == '--moTarget'): option['moTarget'] = val
+        option[optionKey[opt]] = 1 if val == '' else val
     if len(pargs) == 0:
         appDirPath = os.getcwd()
         if option['verbose']:
--- a/runtime/NevowServer.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/runtime/NevowServer.py	Wed Aug 16 16:37:45 2017 +0300
@@ -198,7 +198,8 @@
         if state != self.oldstate:
             action = {'Started': self.site.PLCStarted,
                       'Stopped': self.site.PLCStopped}.get(state, None)
-            if action is not None: action ()
+            if action is not None:
+                action()
             self.oldstate = state
 
 
--- a/runtime/WampClient.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/runtime/WampClient.py	Wed Aug 16 16:37:45 2017 +0300
@@ -57,7 +57,8 @@
     global _PySrv
     names = name.split('.')
     obj = _PySrv.plcobj
-    while names: obj = getattr(obj, names.pop(0))
+    while names:
+        obj = getattr(obj, names.pop(0))
     return obj
 
 
--- a/svgui/pyjs/pyjs.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/svgui/pyjs/pyjs.py	Wed Aug 16 16:37:45 2017 +0300
@@ -409,7 +409,8 @@
                 default_pos += 1
 
             #self._default_args_handler(node, arg_names, current_klass)
-            if node.kwargs: arg_names += ["pyjslib.Dict(__kwargs)"]
+            if node.kwargs:
+                arg_names += ["pyjslib.Dict(__kwargs)"]
             print >>self.output, "    var __r = "+"".join(["[", ", ".join(arg_names), "]"])+";"
             if node.varargs:
                 self._varargs_handler(node, "__args", arg_names, current_klass)
@@ -426,10 +427,13 @@
 
         arg_names = list(node.argnames)
         normal_arg_names = list(arg_names)
-        if node.kwargs: kwargname = normal_arg_names.pop()
-        if node.varargs: varargname = normal_arg_names.pop()
+        if node.kwargs:
+            kwargname = normal_arg_names.pop()
+        if node.varargs:
+            varargname = normal_arg_names.pop()
         declared_arg_names = list(normal_arg_names)
-        if node.kwargs: declared_arg_names.append(kwargname)
+        if node.kwargs:
+            declared_arg_names.append(kwargname)
 
         function_args = "(" + ", ".join(declared_arg_names) + ")"
         print >>self.output, "%s = function%s {" % (function_name, function_args)
@@ -538,7 +542,8 @@
         if kwargs or star_arg_name:
             if not star_arg_name:
                 star_arg_name = 'null'
-            try: call_this, method_name = call_name.rsplit(".", 1)
+            try:
+                call_this, method_name = call_name.rsplit(".", 1)
             except ValueError:
                 # Must be a function call ...
                 return ("pyjs_kwargs_function_call("+call_name+", "
@@ -886,10 +891,13 @@
             #    raise TranslationError("first arg not 'self' (in _method)", node)
 
         normal_arg_names = arg_names[1:]
-        if node.kwargs: kwargname = normal_arg_names.pop()
-        if node.varargs: varargname = normal_arg_names.pop()
+        if node.kwargs:
+            kwargname = normal_arg_names.pop()
+        if node.varargs:
+            varargname = normal_arg_names.pop()
         declared_arg_names = list(normal_arg_names)
-        if node.kwargs: declared_arg_names.append(kwargname)
+        if node.kwargs:
+            declared_arg_names.append(kwargname)
 
         function_args = "(" + ", ".join(declared_arg_names) + ")"
 
--- a/util/ProcessLogger.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/util/ProcessLogger.py	Wed Aug 16 16:37:45 2017 +0300
@@ -57,10 +57,12 @@
                 self.retval = self.Proc.returncode
 
             outchunk = self.fd.readline()
-            if self.callback: self.callback(outchunk)
+            if self.callback:
+                self.callback(outchunk)
         while outchunk != '' and not self.killed:
             outchunk = self.fd.readline()
-            if self.callback: self.callback(outchunk)
+            if self.callback:
+                self.callback(outchunk)
         if self.endcallback:
             try:
                 err = self.Proc.wait()
--- a/util/Zeroconf.py	Wed Aug 16 15:18:57 2017 +0300
+++ b/util/Zeroconf.py	Wed Aug 16 16:37:45 2017 +0300
@@ -1518,7 +1518,8 @@
                                 out.addAnswer(msg, DNSAddress(question.name, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address))
 
                     service = self.services.get(question.name.lower(), None)
-                    if not service: continue
+                    if not service:
+                        continue
 
                     if question.type == _TYPE_SRV or question.type == _TYPE_ANY:
                         out.addAnswer(msg, DNSService(question.name, _TYPE_SRV, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.priority, service.weight, service.port, service.server))