# HG changeset patch # User Sylvain Thénault # Date 1489166482 -3600 # Node ID 9056a41d91ba992a79a36d36c75d41e36a65ee88 # Parent d19f7ec36d33a16edb5dd0897c6448864cd16a89 Fix flake8 some errors diff -r d19f7ec36d33 -r 9056a41d91ba cubicweb/entities/authobjs.py --- a/cubicweb/entities/authobjs.py Fri Mar 10 18:18:51 2017 +0100 +++ b/cubicweb/entities/authobjs.py Fri Mar 10 18:21:22 2017 +0100 @@ -17,8 +17,6 @@ # with CubicWeb. If not, see . """entity classes user and group entities""" - - from six import string_types, text_type from logilab.common.decorators import cached diff -r d19f7ec36d33 -r 9056a41d91ba cubicweb/repoapi.py --- a/cubicweb/repoapi.py Fri Mar 10 18:18:51 2017 +0100 +++ b/cubicweb/repoapi.py Fri Mar 10 18:21:22 2017 +0100 @@ -15,8 +15,8 @@ # # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -"""Official API to access the content of a repository -""" +"""Official API to access the content of a repository.""" + from warnings import warn from six import add_metaclass @@ -27,8 +27,6 @@ from cubicweb.server.session import Connection -### public API ###################################################### - def get_repository(uri=None, config=None, vreg=None): """get a repository for the given URI or config/vregistry (in case we're loading the repository for a client, eg web server, configuration). @@ -42,6 +40,7 @@ assert config is not None, 'get_repository(config=config)' return config.repository(vreg) + def connect(repo, login, **kwargs): """Take credential and return associated Connection. @@ -59,7 +58,7 @@ raises an AuthenticationError if anonymous usage is not allowed """ anoninfo = getattr(repo.config, 'anonymous_user', lambda: None)() - if anoninfo is None: # no anonymous user + if anoninfo is None: # no anonymous user raise AuthenticationError('anonymous access is not authorized') anon_login, anon_password = anoninfo # use vreg's repository cache diff -r d19f7ec36d33 -r 9056a41d91ba cubicweb/sobjects/notification.py --- a/cubicweb/sobjects/notification.py Fri Mar 10 18:18:51 2017 +0100 +++ b/cubicweb/sobjects/notification.py Fri Mar 10 18:21:22 2017 +0100 @@ -25,10 +25,8 @@ from six import text_type from logilab.common.textutils import normalize_text -from logilab.common.deprecation import class_renamed, class_moved, deprecated from logilab.common.registry import yes -from cubicweb.entity import Entity from cubicweb.view import Component, EntityView from cubicweb.server.hook import SendMailOp from cubicweb.mail import construct_message_id, format_mail @@ -54,7 +52,7 @@ elif mode == 'default-dest-addrs': lang = self._cw.vreg.property_value('ui.language') dests = zip(self._cw.vreg.config['default-dest-addrs'], repeat(lang)) - else: # mode == 'none' + else: # mode == 'none' dests = [] return dests @@ -75,8 +73,8 @@ msgid_timestamp = True # to be defined on concrete sub-classes - content = None # body of the mail - message = None # action verb of the subject + content = None # body of the mail + message = None # action verb of the subject # this is usually the method to call def render_and_send(self, **kwargs): @@ -168,7 +166,7 @@ def format_section(self, attr, value): return '%(attr)s\n%(ul)s\n%(value)s\n' % { - 'attr': attr, 'ul': '-'*len(attr), 'value': value} + 'attr': attr, 'ul': '-' * len(attr), 'value': value} def subject(self): entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) @@ -182,12 +180,12 @@ entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) for key, val in kwargs.items(): if val and isinstance(val, text_type) and val.strip(): - kwargs[key] = self._cw._(val) + kwargs[key] = self._cw._(val) kwargs.update({'user': self.user_data['login'], 'eid': entity.eid, 'etype': entity.dc_type(), 'url': entity.absolute_url(), - 'title': entity.dc_long_title(),}) + 'title': entity.dc_long_title()}) return kwargs @@ -249,8 +247,8 @@ def subject(self): entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) - return u'%s #%s (%s)' % (self._cw.__('New %s' % entity.e_schema), - entity.eid, self.user_data['login']) + return u'%s #%s (%s)' % (self._cw.__('New %s' % entity.e_schema), + entity.eid, self.user_data['login']) def format_value(value): @@ -315,5 +313,5 @@ def subject(self): entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) - return u'%s #%s (%s)' % (self._cw.__('Updated %s' % entity.e_schema), - entity.eid, self.user_data['login']) + return u'%s #%s (%s)' % (self._cw.__('Updated %s' % entity.e_schema), + entity.eid, self.user_data['login']) diff -r d19f7ec36d33 -r 9056a41d91ba cubicweb/utils.py --- a/cubicweb/utils.py Fri Mar 10 18:18:51 2017 +0100 +++ b/cubicweb/utils.py Fri Mar 10 18:21:22 2017 +0100 @@ -19,8 +19,6 @@ from __future__ import division - - import base64 import decimal import datetime @@ -50,6 +48,7 @@ # initialize random seed from current time random.seed() + def admincnx(appid): from cubicweb import repoapi from cubicweb.cwconfig import CubicWebConfiguration diff -r d19f7ec36d33 -r 9056a41d91ba cubicweb/web/views/authentication.py --- a/cubicweb/web/views/authentication.py Fri Mar 10 18:18:51 2017 +0100 +++ b/cubicweb/web/views/authentication.py Fri Mar 10 18:21:22 2017 +0100 @@ -17,8 +17,6 @@ # with CubicWeb. If not, see . """user authentication component""" - - from logilab.common.deprecation import class_renamed from logilab.common.textutils import unormalize @@ -29,7 +27,8 @@ from cubicweb.server.session import Connection -class NoAuthInfo(Exception): pass +class NoAuthInfo(Exception): + pass class WebAuthInfoRetriever(Component): @@ -70,6 +69,7 @@ """ pass + WebAuthInfoRetreiver = class_renamed( 'WebAuthInfoRetreiver', WebAuthInfoRetriever, '[3.17] WebAuthInfoRetreiver had been renamed into WebAuthInfoRetriever ' @@ -95,6 +95,7 @@ def revalidate_login(self, req): return req.get_authorization()[0] + LoginPasswordRetreiver = class_renamed( 'LoginPasswordRetreiver', LoginPasswordRetriever, '[3.17] LoginPasswordRetreiver had been renamed into LoginPasswordRetriever ' @@ -190,7 +191,7 @@ session = self._authenticate(login, authinfo) except AuthenticationError: retriever.cleanup_authentication_information(req) - continue # the next one may succeed + continue # the next one may succeed for retriever_ in self.authinforetrievers: retriever_.authenticated(retriever, req, session, login, authinfo) return session, login diff -r d19f7ec36d33 -r 9056a41d91ba flake8-ok-files.txt --- a/flake8-ok-files.txt Fri Mar 10 18:18:51 2017 +0100 +++ b/flake8-ok-files.txt Fri Mar 10 18:21:22 2017 +0100 @@ -20,6 +20,7 @@ cubicweb/devtools/test/unittest_webtest.py cubicweb/devtools/webtest.py cubicweb/entities/adapters.py +cubicweb/entities/authobjs.py cubicweb/entities/test/unittest_base.py cubicweb/etwist/__init__.py cubicweb/etwist/request.py @@ -30,6 +31,7 @@ cubicweb/hooks/test/unittest_security.py cubicweb/hooks/test/unittest_syncsession.py cubicweb/pylintext.py +cubicweb/repoapi.py cubicweb/rset.py cubicweb/rtags.py cubicweb/server/__init__.py @@ -54,6 +56,7 @@ cubicweb/server/test/unittest_session.py cubicweb/server/test/unittest_rqlannotation.py cubicweb/server/test/unittest_utils.py +cubicweb/sobjects/notification.py cubicweb/sobjects/test/unittest_notification.py cubicweb/sobjects/test/unittest_register_user.py cubicweb/sobjects/textparsers.py @@ -92,6 +95,7 @@ cubicweb/web/test/unittest_views_basetemplates.py cubicweb/web/test/unittest_views_cwsources.py cubicweb/web/test/unittest_views_json.py +cubicweb/web/views/authentication.py cubicweb/web/views/editcontroller.py cubicweb/web/views/json.py cubicweb/web/views/searchrestriction.py