pep8 on runtime/NevowServer.py
authorEdouard Tisserant
Mon, 06 Aug 2018 15:36:09 +0200
changeset 2246 51047284cb0e
parent 2245 fe3394697b02
child 2247 921ba5658183
pep8 on runtime/NevowServer.py
runtime/NevowServer.py
--- a/runtime/NevowServer.py	Mon Aug 06 14:30:43 2018 +0200
+++ b/runtime/NevowServer.py	Mon Aug 06 15:36:09 2018 +0200
@@ -59,6 +59,7 @@
     def HMIinitialisation(self):
         self.HMIinitialised(None)
 
+
 class DefaultPLCStartedHMI(PLCHMI):
     docFactory = loaders.stan(
         tags.div(render=tags.directive('liveElement'))[
@@ -128,6 +129,7 @@
         for child in self.liveFragmentChildren[:]:
             child.detach()
 
+
 class ConfigurableBindings(configurable.Configurable):
 
     def __init__(self):
@@ -140,77 +142,84 @@
     def addExtension(self, name, desc, fields, btnlabel, callback):
         def _bind(ctx):
             return annotate.MethodBinding(
-                'action_'+name,
+                'action_' + name,
                 annotate.Method(arguments=[
                     annotate.Argument(*field)
                     for field in fields],
-                    label = desc),
-                action = btnlabel)
-        setattr(self, 'bind_'+name, _bind)
-            
-        setattr(self, 'action_'+name, callback)
+                    label=desc),
+                action=btnlabel)
+        setattr(self, 'bind_' + name, _bind)
+
+        setattr(self, 'action_' + name, callback)
 
         self.bindingsNames.append(name)
 
 ConfigurableSettings = ConfigurableBindings()
 
+
 class ISettings(annotate.TypedInterface):
-    platform = annotate.String(label = _("Platform"),
-                           default = platform.system() + " " + platform.release(),
-                           immutable = True)
+    platform = annotate.String(label=_("Platform"),
+                               default=platform.system(
+    ) + " " + platform.release(),
+        immutable=True)
     # TODO version ?
 
     def sendLogMessage(
-        ctx = annotate.Context(),
-        level = annotate.Choice(LogLevels,
-                                required=True, 
-                                label=_("Log message level")),
-        message = annotate.String(label=_("Message text"))):
+        ctx=annotate.Context(),
+        level=annotate.Choice(LogLevels,
+                              required=True,
+                              label=_("Log message level")),
+            message=annotate.String(label=_("Message text"))):
             pass
-    sendLogMessage = annotate.autocallable(sendLogMessage, 
-                                           label=_("Send a message to the log"),
+    sendLogMessage = annotate.autocallable(sendLogMessage,
+                                           label=_(
+                                               "Send a message to the log"),
                                            action=_("Send"))
 
 customSettingsURLs = {
 }
 
+
 class SettingsPage(rend.Page):
     # We deserve a slash
     addSlash = True
-    
+
     # This makes webform_css url answer some default CSS
     child_webform_css = webform.defaultCSS
 
     implements(ISettings)
 
-
-    docFactory = loaders.stan([tags.html[
-                                   tags.head[
-                                       tags.title[_("Beremiz Runtime Settings")],
-                                       tags.link(rel='stylesheet',
-                                                 type='text/css', 
-                                                 href=url.here.child("webform_css"))
-                                   ],
-                                   tags.body[ 
-                                       tags.h1["Runtime settings:"],
-                                       webform.renderForms('staticSettings'),
-                                       tags.h2["Extensions settings:"],
-                                       webform.renderForms('dynamicSettings'),
-                                   ]]])
+    docFactory = loaders.stan([
+        tags.html[
+            tags.head[
+                tags.title[_("Beremiz Runtime Settings")],
+                tags.link(rel='stylesheet',
+                          type='text/css',
+                          href=url.here.child("webform_css"))
+            ],
+            tags.body[
+                tags.h1["Runtime settings:"],
+                webform.renderForms('staticSettings'),
+                tags.h2["Extensions settings:"],
+                webform.renderForms('dynamicSettings'),
+            ]
+        ]
+    ])
 
     def configurable_staticSettings(self, ctx):
         return configurable.TypedInterfaceConfigurable(self)
 
     def configurable_dynamicSettings(self, ctx):
         return ConfigurableSettings
-    
+
     def sendLogMessage(self, level, message, **kwargs):
         level = LogLevelsDict[level]
         if _PySrv.plcobj is not None:
-            _PySrv.plcobj.LogMessage(level, "Web form log message: " + message )
+            _PySrv.plcobj.LogMessage(
+                level, "Web form log message: " + message)
 
     def locateChild(self, ctx, segments):
-        if segments[0] in customSettingsURLs :
+        if segments[0] in customSettingsURLs:
             return customSettingsURLs[segments[0]](ctx, segments)
         return super(SettingsPage, self).locateChild(ctx, segments)
 
@@ -222,12 +231,14 @@
                                    tags.head(render=tags.directive('liveglue'))[
                                        tags.title[PAGE_TITLE],
                                        tags.link(rel='stylesheet',
-                                                 type='text/css', 
+                                                 type='text/css',
                                                  href=url.here.child("webform_css"))
                                    ],
                                    tags.body[
                                        tags.div[
-                                           tags.div(render=tags.directive("MainPage")),
+                                           tags.div(
+                                               render=tags.directive(
+                                                   "MainPage")),
                                        ]]]])
     MainPage = MainPage()
     PLCHMI = PLCHMI
@@ -237,7 +248,8 @@
 
     def __init__(self, plcState=False, *a, **kw):
         super(WebInterface, self).__init__(*a, **kw)
-        self.jsModules.mapping[u'WebInterface'] = paths.AbsNeighbourFile(__file__, 'webinterface.js')
+        self.jsModules.mapping[u'WebInterface'] = paths.AbsNeighbourFile(
+            __file__, 'webinterface.js')
         self.plcState = plcState
         self.MainPage.setPLCState(plcState)
 
@@ -287,7 +299,6 @@
         # print "We will be called back when the client disconnects"
 
 
-
 def RegisterWebsite(port):
     website = WebInterface()
     site = appserver.NevowSite(website)
@@ -298,6 +309,7 @@
 
 
 class statuslistener(object):
+
     def __init__(self, site):
         self.oldstate = None
         self.site = site
@@ -318,4 +330,3 @@
 def SetServer(pysrv):
     global _PySrv
     _PySrv = pysrv
-