Commit 8a316636 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Fix some flake8 errors

--HG--
branch : 3.25
parent 4ba8fd2cd41a
......@@ -19,10 +19,6 @@
from cubicweb import _
from socket import gethostname
from logilab.common.decorators import clear_cache
from cubicweb import validation_error
from cubicweb.predicates import is_instance
from cubicweb.server import SOURCE_TYPES, hook
......@@ -39,12 +35,11 @@ class SourceHook(hook.Hook):
{}, source_entity.eid)
# repo sources synchronization #################################################
class SourceAddedHook(SourceHook):
__regid__ = 'cw.sources.added'
__select__ = SourceHook.__select__ & is_instance('CWSource')
events = ('after_add_entity',)
def __call__(self):
if self.entity.type not in SOURCE_TYPES:
msg = _('Unknown source type')
......@@ -59,6 +54,7 @@ class SourceRemovedHook(SourceHook):
__regid__ = 'cw.sources.removed'
__select__ = SourceHook.__select__ & is_instance('CWSource')
events = ('before_delete_entity',)
def __call__(self):
if self.entity.name == 'system':
msg = _("You cannot remove the system source")
......@@ -69,6 +65,7 @@ class SourceUpdatedHook(SourceHook):
__regid__ = 'cw.sources.configupdate'
__select__ = SourceHook.__select__ & is_instance('CWSource')
events = ('before_update_entity',)
def __call__(self):
if 'name' in self.entity.cw_edited:
oldname, newname = self.entity.cw_edited.oldnewvalue('name')
......
......@@ -85,7 +85,7 @@ class AbstractSource(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 __init__(self, repo, source_config, eid=None):
self.repo = repo
......@@ -213,12 +213,13 @@ class AbstractSource(object):
self.urls = []
PUBLIC_KEYS = ('type', 'uri', 'use-cwuri-as-url')
def remove_sensitive_information(self, sourcedef):
"""remove sensitive information such as login / password from source
definition
"""
for key in list(sourcedef):
if not key in self.PUBLIC_KEYS:
if key not in self.PUBLIC_KEYS:
sourcedef.pop(key)
# connections handling #####################################################
......@@ -282,7 +283,7 @@ class AbstractSource(object):
"""add a relation to the source"""
raise NotImplementedError(self)
def add_relations(self, cnx, rtype, subj_obj_list):
def add_relations(self, cnx, rtype, subj_obj_list):
"""add a relations to the source"""
# override in derived classes if you feel you can
# optimize
......
......@@ -229,7 +229,7 @@ class DefaultEidGenerator(object):
return self._create_eid(count)
else:
raise
except Exception: # WTF?
except Exception: # WTF?
cnx.rollback()
self.cnx = None
source.exception('create eid failed in an unforeseen way on SQL statement %s', sql)
......@@ -704,7 +704,7 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
raise UniqueTogetherError(cnx, cstrname=mo.group(0))
# old sqlite
mo = re.search('columns? (.*) (?:is|are) not unique', arg)
if mo is not None: # sqlite in use
if mo is not None: # sqlite in use
# we left chop the 'cw_' prefix of attribute names
rtypes = [c.strip()[3:]
for c in mo.group(1).split(',')]
......@@ -1649,12 +1649,12 @@ class DatabaseIndependentBackupRestore(object):
self.logger.critical('Restore warning: versions do not match')
new_cubes = db_versions - archive_versions
if new_cubes:
self.logger.critical('In the db:\n%s', '\n'.join('%s: %s' % (cube, ver)
for cube, ver in sorted(new_cubes)))
self.logger.critical('In the db:\n%s', '\n'.join(
'%s: %s' % (cube, ver) for cube, ver in sorted(new_cubes)))
old_cubes = archive_versions - db_versions
if old_cubes:
self.logger.critical('In the archive:\n%s', '\n'.join('%s: %s' % (cube, ver)
for cube, ver in sorted(old_cubes)))
self.logger.critical('In the archive:\n%s', '\n'.join(
'%s: %s' % (cube, ver) for cube, ver in sorted(old_cubes)))
if not ASK.confirm('Versions mismatch: continue anyway ?', False):
raise ValueError('Unable to restore: versions do not match')
table_chunks = {}
......
......@@ -178,6 +178,7 @@ class DataFeedConfigTC(CubicWebTC):
self.assertEqual({'type': u'datafeed', 'uri': u'myfeed', 'use-cwuri-as-url': False},
dfsource.public_config)
if __name__ == '__main__':
from logilab.common.testlib import unittest_main
unittest_main()
......@@ -26,6 +26,7 @@ cubicweb/etwist/__init__.py
cubicweb/etwist/request.py
cubicweb/etwist/service.py
cubicweb/ext/__init__.py
cubicweb/hooks/syncsources.py
cubicweb/hooks/test/data/hooks.py
cubicweb/hooks/test/unittest_notificationhooks.py
cubicweb/hooks/test/unittest_security.py
......@@ -53,6 +54,7 @@ cubicweb/server/test/data-migractions/cubes/__init__.py
cubicweb/server/test/data-migractions/migratedapp/__init__.py
cubicweb/server/test/data-schema2sql/__init__.py
cubicweb/server/test/unittest_checkintegrity.py
cubicweb/server/test/unittest_datafeed.py
cubicweb/server/test/unittest_ldapsource.py
cubicweb/server/test/unittest_serverctl.py
cubicweb/server/test/unittest_session.py
......@@ -63,6 +65,8 @@ cubicweb/sobjects/services.py
cubicweb/sobjects/test/unittest_notification.py
cubicweb/sobjects/test/unittest_register_user.py
cubicweb/sobjects/textparsers.py
cubicweb/sources/__init__.py
cubicweb/sources/native.py
cubicweb/test/data/libpython/cubicweb_comment/__init__.py
cubicweb/test/data/libpython/cubicweb_comment/__pkginfo__.py
cubicweb/test/data/libpython/cubicweb_email/entities.py
......
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