[repo] pylint cleanup, mainly of imports, with a bit of style
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 23 Jan 2014 12:32:16 +0100
changeset 9468 39b7a91a3f4c
parent 9467 ad66d7b3fd48
child 9469 032825bbacab
[repo] pylint cleanup, mainly of imports, with a bit of style
devtools/repotest.py
server/checkintegrity.py
server/cwzmq.py
server/hook.py
server/migractions.py
server/repository.py
server/schemaserial.py
server/server.py
server/serverconfig.py
server/session.py
server/sources/ldapfeed.py
server/sources/native.py
server/sources/rql2sql.py
server/sources/storages.py
server/utils.py
--- a/devtools/repotest.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/devtools/repotest.py	Thu Jan 23 12:32:16 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
--- a/server/checkintegrity.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/checkintegrity.py	Thu Jan 23 12:32:16 2014 +0100
@@ -193,7 +193,7 @@
             notify_fixed(fix)
     # source in entities, but no relation cw_source
     applcwversion = session.repo.get_versions().get('cubicweb')
-    if applcwversion >= (3,13,1): # entities.asource appeared in 3.13.1
+    if applcwversion >= (3, 13, 1): # entities.asource appeared in 3.13.1
         cursor = session.system_sql('SELECT e.eid FROM entities as e, cw_CWSource as s '
                                     'WHERE s.cw_name=e.asource AND '
                                     'NOT EXISTS(SELECT 1 FROM cw_source_relation as cs '
--- a/server/cwzmq.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/cwzmq.py	Thu Jan 23 12:32:16 2014 +0100
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# copyright 2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2012-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -17,17 +17,17 @@
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 
-from threading import Thread
 import cPickle
 import traceback
+from threading import Thread
+from logging import getLogger
 
 import zmq
 from zmq.eventloop import ioloop
 import zmq.eventloop.zmqstream
 
-from logging import getLogger
 from cubicweb import set_log_methods
-from cubicweb.server.server import QuitEvent
+from cubicweb.server.server import QuitEvent, Finished
 
 ctx = zmq.Context()
 
--- a/server/hook.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/hook.py	Thu Jan 23 12:32:16 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -257,8 +257,8 @@
 from logilab.common.decorators import classproperty, cached
 from logilab.common.deprecation import deprecated, class_renamed
 from logilab.common.logging_ext import set_log_methods
-from logilab.common.registry import (Predicate, NotPredicate, OrPredicate,
-                                     objectify_predicate, yes)
+from logilab.common.registry import (NotPredicate, OrPredicate,
+                                     objectify_predicate)
 
 from cubicweb import RegistryNotFound, server
 from cubicweb.cwvreg import CWRegistry, CWRegistryStore
--- a/server/migractions.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/migractions.py	Thu Jan 23 12:32:16 2014 +0100
@@ -55,13 +55,9 @@
 from cubicweb.cwvreg import CW_EVENT_MANAGER
 from cubicweb.dbapi import get_repository, _repo_connect
 from cubicweb.migration import MigrationHelper, yes
-from cubicweb.server import hook
-try:
-    from cubicweb.server import SOURCE_TYPES, schemaserial as ss
-    from cubicweb.server.utils import manager_userpasswd
-    from cubicweb.server.sqlutils import sqlexec, SQL_PREFIX
-except ImportError: # LAX
-    pass
+from cubicweb.server import hook, schemaserial as ss
+from cubicweb.server.utils import manager_userpasswd
+from cubicweb.server.sqlutils import sqlexec, SQL_PREFIX
 
 
 def mock_object(**params):
--- a/server/repository.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/repository.py	Thu Jan 23 12:32:16 2014 +0100
@@ -33,26 +33,22 @@
 import Queue
 from warnings import warn
 from itertools import chain
-from os.path import join
-from datetime import datetime
 from time import time, localtime, strftime
 from contextlib import contextmanager
 from warnings import warn
 
 from logilab.common.decorators import cached, clear_cache
 from logilab.common.deprecation import deprecated
-from logilab.common.compat import any
-from logilab.common import flatten
 
 from yams import BadSchemaDefinition
 from yams.schema import role_name
 from rql import RQLSyntaxError
 from rql.utils import rqlvar_maker
 
-from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, QueryError,
+from cubicweb import (CW_MIGRATION_MAP, QueryError,
                       UnknownEid, AuthenticationError, ExecutionError,
                       BadConnectionId, Unauthorized, ValidationError,
-                      RepositoryError, UniqueTogetherError, onevent)
+                      UniqueTogetherError, onevent)
 from cubicweb import cwvreg, schema, server
 from cubicweb.server import ShuttingDown, utils, hook, querier, sources
 from cubicweb.server.session import Session, InternalSession, InternalManager
@@ -1486,7 +1482,7 @@
 
     # these are overridden by set_log_methods below
     # only defining here to prevent pylint from complaining
-    info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
+    info = warning = error = critical = exception = debug = lambda msg, *a, **kw: None
 
 
 def pyro_unregister(config):
--- a/server/schemaserial.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/schemaserial.py	Thu Jan 23 12:32:16 2014 +0100
@@ -20,7 +20,6 @@
 __docformat__ = "restructuredtext en"
 
 import os
-from itertools import chain
 import json
 
 from logilab.common.shellutils import ProgressBar
@@ -28,9 +27,9 @@
 from yams import (BadSchemaDefinition, schema as schemamod, buildobjs as ybo,
                   schema2sql as y2sql)
 
-from cubicweb import CW_SOFTWARE_ROOT, Binary, typed_eid
+from cubicweb import Binary
 from cubicweb.schema import (KNOWN_RPROPERTIES, CONSTRAINTS, ETYPE_NAME_MAP,
-                             VIRTUAL_RTYPES, PURE_VIRTUAL_RTYPES)
+                             VIRTUAL_RTYPES)
 from cubicweb.server import sqlutils
 
 
--- a/server/server.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/server.py	Thu Jan 23 12:32:16 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -19,13 +19,9 @@
 
 __docformat__ = "restructuredtext en"
 
-import os
-import sys
 import select
-import warnings
 from time import localtime, mktime
 
-from cubicweb.cwconfig import CubicWebConfiguration
 from cubicweb.server.utils import TasksManager
 from cubicweb.server.repository import Repository
 
--- a/server/serverconfig.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/serverconfig.py	Thu Jan 23 12:32:16 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -24,7 +24,7 @@
 from StringIO import StringIO
 
 import logilab.common.configuration as lgconfig
-from logilab.common.decorators import wproperty, cached
+from logilab.common.decorators import cached
 
 from cubicweb.toolsutils import read_config, restrict_perms_to_user
 from cubicweb.cwconfig import CONFIGURATIONS, CubicWebConfiguration
--- a/server/session.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/session.py	Thu Jan 23 12:32:16 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -31,7 +31,7 @@
 from logilab.common.textutils import unormalize
 from logilab.common.registry import objectify_predicate
 
-from cubicweb import UnknownEid, QueryError, schema, server, ProgrammingError
+from cubicweb import QueryError, schema, server, ProgrammingError
 from cubicweb.req import RequestSessionBase
 from cubicweb.utils import make_uid
 from cubicweb.rqlrewrite import RQLRewriter
@@ -160,7 +160,7 @@
     def __init__(self, session, mode, *categories):
         self.session = session
         super_init = super(_session_hooks_control, self).__init__
-        return super_init(session._cnx, mode, *categories)
+        super_init(session._cnx, mode, *categories)
 
     def __exit__(self, exctype, exc, traceback):
         super_exit = super(_session_hooks_control, self).__exit__
@@ -215,7 +215,7 @@
     def __init__(self, session, read=None, write=None):
         self.session = session
         super_init = super(_session_security_enabled, self).__init__
-        return super_init(session._cnx, read=read, write=write)
+        super_init(session._cnx, read=read, write=write)
 
     def __exit__(self, exctype, exc, traceback):
         super_exit = super(_session_security_enabled, self).__exit__
--- a/server/sources/ldapfeed.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/sources/ldapfeed.py	Thu Jan 23 12:32:16 2014 +0100
@@ -275,9 +275,9 @@
         # Deny auto-chasing of referrals to be safe, we handle them instead
         # Required for AD
         try:
-           conn.set_option(ldap.OPT_REFERRALS, 0)
+            conn.set_option(ldap.OPT_REFERRALS, 0)
         except ldap.LDAPError: # Cannot set referrals, so do nothing
-           pass
+            pass
         #conn.set_option(ldap.OPT_NETWORK_TIMEOUT, conn_timeout)
         #conn.timeout = op_timeout
         # Now bind with the credentials given. Let exceptions propagate out.
--- a/server/sources/native.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/sources/native.py	Thu Jan 23 12:32:16 2014 +0100
@@ -35,7 +35,7 @@
 from datetime import datetime
 from base64 import b64decode, b64encode
 from contextlib import contextmanager
-from os.path import abspath, basename
+from os.path import basename
 import re
 import itertools
 import zipfile
@@ -52,7 +52,7 @@
 from yams.schema import role_name
 
 from cubicweb import (UnknownEid, AuthenticationError, ValidationError, Binary,
-                      UniqueTogetherError, QueryError, UndoTransactionException)
+                      UniqueTogetherError, UndoTransactionException)
 from cubicweb import transaction as tx, server, neg_role
 from cubicweb.utils import QueryCache
 from cubicweb.schema import VIRTUAL_RTYPES
@@ -1554,7 +1554,7 @@
         self.cnx = self.get_connection()
         try:
             self.cursor = self.cnx.cursor()
-            self.cursor.arraysize=100
+            self.cursor.arraysize = 100
             self.logger.info('writing metadata')
             self.write_metadata(archive)
             for seq in self.get_sequences():
@@ -1597,8 +1597,8 @@
         archive.writestr('tables.txt', '\n'.join(self.get_tables()))
         archive.writestr('sequences.txt', '\n'.join(self.get_sequences()))
         versions = self._get_versions()
-        versions_str = '\n'.join('%s %s' % (k,v)
-                                 for k,v in versions)
+        versions_str = '\n'.join('%s %s' % (k, v)
+                                 for k, v in versions)
         archive.writestr('versions.txt', versions_str)
 
     def write_sequence(self, archive, seq):
--- a/server/sources/rql2sql.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/sources/rql2sql.py	Thu Jan 23 12:32:16 2014 +0100
@@ -58,8 +58,8 @@
 from rql import BadRQLQuery, CoercionError
 from rql.utils import common_parent
 from rql.stmts import Union, Select
-from rql.nodes import (SortTerm, VariableRef, Constant, Function, Variable, Or,
-                       Not, Comparison, ColumnAlias, Relation, SubQuery, Exists)
+from rql.nodes import (VariableRef, Constant, Function, Variable, Or,
+                       Not, Comparison, ColumnAlias, Relation, SubQuery)
 
 from cubicweb import QueryError
 from cubicweb.rqlrewrite import cleanup_solutions
--- a/server/sources/storages.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/sources/storages.py	Thu Jan 23 12:32:16 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
--- a/server/utils.py	Mon Jul 01 16:13:17 2013 +0200
+++ b/server/utils.py	Thu Jan 23 12:32:16 2014 +0100
@@ -108,7 +108,7 @@
     return user, passwd
 
 
-_MARKER=object()
+_MARKER = object()
 def func_name(func):
     name = getattr(func, '__name__', _MARKER)
     if name is _MARKER: