Commit aa9bb3ca authored by Julien Cristau's avatar Julien Cristau
Browse files

[repo] pylint cleanup, mainly of imports, with a bit of style

parent ad66d7b3fd48
# 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.
......
......@@ -193,7 +193,7 @@ def check_entities(schema, session, eids, fix=1):
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 '
......
# -*- 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()
......
# 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 itertools import chain
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
......
......@@ -55,13 +55,9 @@ from cubicweb.schema import (ETYPE_NAME_MAP, META_RTYPES, VIRTUAL_RTYPES,
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):
......
......@@ -33,26 +33,22 @@ import threading
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 @@ class Repository(object):
# 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):
......
......@@ -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 logilab.common.shellutils import ProgressBar
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
......
# 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
......
# 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 os.path import join, exists
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
......
# 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.deprecation import deprecated
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 @@ class _session_hooks_control(_hooks_control): # XXX repoapi: remove me when
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 @@ class _session_security_enabled(_security_enabled):
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__
......
......@@ -275,9 +275,9 @@ You can set multiple groups by separating them by a comma.',
# 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.
......
......@@ -35,7 +35,7 @@ from threading import Lock
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 import schema2sql as y2sql
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 @@ class DatabaseIndependentBackupRestore(object):
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 @@ class DatabaseIndependentBackupRestore(object):
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):
......
......@@ -58,8 +58,8 @@ from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY
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
......
# 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.
......
......@@ -108,7 +108,7 @@ def manager_userpasswd(user=None, msg=DEFAULT_MSG, confirm=False,
return user, passwd
_MARKER=object()
_MARKER = object()
def func_name(func):
name = getattr(func, '__name__', _MARKER)
if name is _MARKER:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment