[style] Make cubicweb/web/views/wdoc.py flake8-clean 3.26
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 28 Jun 2018 09:43:23 +0200
branch3.26
changeset 12330 6e620df7d4c3
parent 12329 d0bf06146782
child 12331 3cddf6a5473a
[style] Make cubicweb/web/views/wdoc.py flake8-clean
cubicweb/web/views/wdoc.py
flake8-ok-files.txt
--- a/cubicweb/web/views/wdoc.py	Thu Jun 28 09:38:38 2018 +0200
+++ b/cubicweb/web/views/wdoc.py	Thu Jun 28 09:43:23 2018 +0200
@@ -23,15 +23,10 @@
 
 from itertools import chain
 from os.path import join
-from bisect import bisect_right
-from datetime import date
 
 from six import text_type
 
-from logilab.common.changelog import ChangeLog
-from logilab.common.date import strptime, todate
 from logilab.common.registry import yes
-from logilab.mtconverter import CHARSET_DECL_RGX
 
 from cubicweb.predicates import match_form_params
 from cubicweb.view import StartupView
@@ -46,10 +41,11 @@
 except ImportError:
     from elementtree.ElementTree import parse
 
+
 def build_toc_index(node, index):
     try:
         nodeidx = node.attrib['resource']
-        assert not nodeidx in index, nodeidx
+        assert nodeidx not in index, nodeidx
         index[nodeidx] = node
     except KeyError:
         pass
@@ -57,6 +53,7 @@
         build_toc_index(child, index)
         child.parent = node
 
+
 def get_insertion_point(section, index):
     if section.attrib.get('insertafter'):
         snode = index[section.attrib['insertafter']]
@@ -73,6 +70,7 @@
         node, idx = None, None
     return node, idx
 
+
 def build_toc(config):
     alltocfiles = reversed(tuple(config.locate_all_files('toc.xml')))
     maintoc = parse(next(alltocfiles)).getroot()
@@ -95,6 +93,7 @@
             build_toc_index(section, index)
     return index
 
+
 def title_for_lang(node, lang):
     fallback_title = None
     for title in node.findall('title'):
@@ -105,11 +104,13 @@
             fallback_title = text_type(title.text)
     return fallback_title
 
+
 def subsections(node):
     return [child for child in node if child.tag == 'section']
 
 # help views ##################################################################
 
+
 class InlineHelpView(StartupView):
     __select__ = match_form_params('fid')
     __regid__ = 'wdoc'
@@ -143,7 +144,6 @@
             self.navigation_links(node)
 
     def navigation_links(self, node):
-        req = self._cw
         parent = node.parent
         if parent is None:
             return
@@ -167,7 +167,7 @@
         self.w(u'<span class="%s">' % htmlclass)
         self.w(u'%s : ' % self._cw._(msgid))
         self.w(u'<a href="%s">%s</a>' % (
-            self._cw.build_url('doc/'+node.attrib['resource']),
+            self._cw.build_url('doc/' + node.attrib['resource']),
             title_for_lang(node, self._cw.lang)))
         self.w(u'</span>\n')
 
@@ -180,14 +180,13 @@
         self.w(u'<ul class="docsum">')
         for child in sub:
             self.w(u'<li><a href="%s">%s</a>' % (
-                self._cw.build_url('doc/'+child.attrib['resource']),
+                self._cw.build_url('doc/' + child.attrib['resource']),
                 title_for_lang(child, self._cw.lang)))
             self.subsections_links(child, False)
             self.w(u'</li>')
         self.w(u'</ul>\n')
 
 
-
 class InlineHelpImageView(StartupView):
     __regid__ = 'wdocimages'
     __select__ = match_form_params('fid')
@@ -208,7 +207,6 @@
         self.w(open(join(resourcedir, rid)).read())
 
 
-
 class HelpAction(action.Action):
     __regid__ = 'help'
     __select__ = yes()
--- a/flake8-ok-files.txt	Thu Jun 28 09:38:38 2018 +0200
+++ b/flake8-ok-files.txt	Thu Jun 28 09:43:23 2018 +0200
@@ -122,6 +122,7 @@
 cubicweb/web/views/json.py
 cubicweb/web/views/searchrestriction.py
 cubicweb/web/views/staticcontrollers.py
+cubicweb/web/views/wdoc.py
 cubicweb/web/views/workflow.py
 cubicweb/web/views/uicfg.py
 cubicweb/web/webctl.py