[pep8] fix E201, E261, E202, W191 and E231
authorNoe Gaumont <ngaumont@logilab.fr>
Fri, 12 Apr 2019 10:02:58 +0200
changeset 202 5b3945773663
parent 201 fb1509b08c30
child 203 0156c401e901
[pep8] fix E201, E261, E202, W191 and E231
cubicweb_keyword/entities.py
cubicweb_keyword/hooks.py
cubicweb_keyword/migration/1.0.2_Any.py
cubicweb_keyword/views.py
--- a/cubicweb_keyword/entities.py	Fri Apr 12 09:55:44 2019 +0200
+++ b/cubicweb_keyword/entities.py	Fri Apr 12 10:02:58 2019 +0200
@@ -119,7 +119,7 @@
 class CodeKeyword(Keyword):
     __regid__ = 'CodeKeyword'
     rest_attr = 'code'
-    fetch_attrs, cw_fetch_order = fetch_config(['code','name'])
+    fetch_attrs, cw_fetch_order = fetch_config(['code', 'name'])
 
     def dc_title(self):
         return u'%s - %s' % (self.code, self.name)
--- a/cubicweb_keyword/hooks.py	Fri Apr 12 09:55:44 2019 +0200
+++ b/cubicweb_keyword/hooks.py	Fri Apr 12 10:02:58 2019 +0200
@@ -23,7 +23,7 @@
     def __call__(self):
         entity = self._cw.entity_from_eid(self.eidfrom)
         parent = self._cw.entity_from_eid(self.eidto)
-        parents = set([x.eid for x in chain([parent,], parent.cw_adapt_to('ITree').iterparents())])
+        parents = set([x.eid for x in chain([parent, ], parent.cw_adapt_to('ITree').iterparents())])
         children = set([x.eid for x in chain([entity], entity.cw_adapt_to('ITree').recurse_children())])
         if children & parents:
             msg = _('detected descendant_of cycle')
@@ -71,7 +71,7 @@
         parent = self._cw.entity_from_eid(self.eidto)
         for parent in chain([parent], parent.cw_adapt_to('ITree').iterparents()):
             self._cw.execute('DELETE K descendant_of P WHERE K eid %(k)s, '
-                            'P eid %(p)s', {'p':parent.eid, 'k': self.eidfrom})
+                            'P eid %(p)s', {'p': parent.eid, 'k': self.eidfrom})
 
 
 ## operations #################################################################
--- a/cubicweb_keyword/migration/1.0.2_Any.py	Fri Apr 12 09:55:44 2019 +0200
+++ b/cubicweb_keyword/migration/1.0.2_Any.py	Fri Apr 12 10:02:58 2019 +0200
@@ -1,1 +1,1 @@
-synchronize_eschema('Classification') # index removed
+synchronize_eschema('Classification')  # index removed
--- a/cubicweb_keyword/views.py	Fri Apr 12 09:55:44 2019 +0200
+++ b/cubicweb_keyword/views.py	Fri Apr 12 10:02:58 2019 +0200
@@ -55,7 +55,7 @@
         entity = self.cw_rset.get_entity(row, col)
         self.w(u'<h1 class="titleUnderline">%s</h1>'
                % xml_escape(entity.dc_long_title()))
-        rset = entity.related('subkeyword_of','object')
+        rset = entity.related('subkeyword_of', 'object')
         self.wview('treeview', rset, 'null')
 
 
@@ -69,18 +69,20 @@
 
 # skos views ############################################################
 
-SKOS_OPENING_ROOT=u'''<?xml version="1.0" encoding="UTF-8"?>
+
+SKOS_OPENING_ROOT = u'''<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE rdfs [
-	<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-	<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
-	<!ENTITY dc "http://purl.org/dc/elements/1.1/">
-	<!ENTITY dct "http://purl.org/dc/terms/">
+    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
+    <!ENTITY dc "http://purl.org/dc/elements/1.1/">
+    <!ENTITY dct "http://purl.org/dc/terms/">
 ]>
 <rdf:RDF  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
           xmlns:skos="http://www.w3.org/2004/02/skos/core#">
 '''
 SKOS_CLOSING_ROOT = u'</rdf:RDF>'
 
+
 class SkosView(EntityView):
     __regid__ = 'skos'
     content_type = 'application/xml'
@@ -186,8 +188,8 @@
                                        e.view('combobox'))):
             classification_name = e.cw_adapt_to('ITree').classification.name
             if scheme != classification_name:
-                vocab.append( (_(classification_name), None) )
-            vocab.append( (e.view('combobox'), e.eid) )
+                vocab.append((_(classification_name), None))
+            vocab.append((e.view('combobox'), e.eid))
         return vocab
 
 
@@ -212,14 +214,14 @@
         rqlst = self.rqlst
         rqlst.save_state()
         try:
-            mainvar = self.filtered_variable # X
-            keyword_var = rqlst.make_variable() # K
-            keyword_name_var = rqlst.make_variable() # KN
-            classif_var = rqlst.make_variable() # C
-            classif_name_var = rqlst.make_variable() # CN
-            rqlst.add_relation(keyword_var, 'applied_to', mainvar) # K applied_to X
-            rqlst.add_relation(keyword_var, 'name', keyword_name_var) # K name KN
-            rqlst.add_relation(keyword_var, 'included_in', classif_var) # K included_in C
+            mainvar = self.filtered_variable  # X
+            keyword_var = rqlst.make_variable()  # K
+            keyword_name_var = rqlst.make_variable()  # KN
+            classif_var = rqlst.make_variable()  # C
+            classif_name_var = rqlst.make_variable()  # CN
+            rqlst.add_relation(keyword_var, 'applied_to', mainvar)  # K applied_to X
+            rqlst.add_relation(keyword_var, 'name', keyword_name_var)  # K name KN
+            rqlst.add_relation(keyword_var, 'included_in', classif_var)  # K included_in C
             # C name "classification-name"
             rqlst.add_constant_restriction(classif_var, 'name', self.classification, 'String')
             rqlst.add_selected(keyword_var)
@@ -259,11 +261,11 @@
                                  {'x': eid}, 'x')
     if not kwrset:
         return self._cw._('No suitable classification scheme found')
-    classification = kwrset[0][2] # XXX what if we have several classifications ?
-    valid_keywords = set(kwname for _, kwname,_ in kwrset)
+    classification = kwrset[0][2]  # XXX what if we have several classifications ?
+    valid_keywords = set(kwname for _, kwname, _ in kwrset)
     user_keywords = set(kwlist)
     invalid_keywords = sorted(user_keywords - valid_keywords)
-    kweids = dict( (kwname, str(kweid)) for kweid, kwname, _ in kwrset if kwname in user_keywords )
+    kweids = dict((kwname, str(kweid)) for kweid, kwname, _ in kwrset if kwname in user_keywords)
     if invalid_keywords:
         for keyword in invalid_keywords:
             neweid = self.cursor.execute('INSERT Keyword K: K name %(name)s, K included_in C WHERE C eid %(c)s',