pep8: Use "X not in Y" instead of "not X in Y"

flake8 --select E713, semi-manual fixing
This commit is contained in:
Laurent Bachelier 2014-10-11 01:27:24 +02:00
commit 21e8f82fd7
57 changed files with 81 additions and 83 deletions

View file

@ -204,7 +204,7 @@ class Application(object):
if path is None:
path = os.path.join(self.CONFDIR, self.APPNAME + '.storage')
elif not os.path.sep in path:
elif os.path.sep not in path:
path = os.path.join(self.CONFDIR, path)
storage = klass(path)
@ -232,7 +232,7 @@ class Application(object):
if path is None:
path = os.path.join(self.CONFDIR, self.APPNAME)
elif not os.path.sep in path:
elif os.path.sep not in path:
path = os.path.join(self.CONFDIR, path)
self.config = klass(path)

View file

@ -201,7 +201,7 @@ class ConsoleApplication(Application):
sys.exit(1)
def do(self, function, *args, **kwargs):
if not 'backends' in kwargs:
if 'backends' not in kwargs:
kwargs['backends'] = self.enabled_backends
return self.weboob.do(function, *args, **kwargs)
@ -216,7 +216,7 @@ class ConsoleApplication(Application):
backend_name = backends[0][0]
else:
raise BackendNotGiven(_id, backends)
if backend_name is not None and not backend_name in dict(backends):
if backend_name is not None and backend_name not in dict(backends):
# Is the backend a short version of a real one?
found = False
for key in dict(backends):

View file

@ -149,7 +149,7 @@ class IFormatter(object):
if selected_fields: # can be an empty list (nothing to do), or None (return all fields)
obj = obj.copy()
for name, value in obj.iter_fields():
if not name in selected_fields:
if name not in selected_fields:
delattr(obj, name)
if self.MANDATORY_FIELDS:
@ -167,7 +167,7 @@ class IFormatter(object):
if selected_fields:
obj = obj.copy()
for name, value in obj.iteritems():
if not name in selected_fields:
if name not in selected_fields:
obj.pop(name)
if self.MANDATORY_FIELDS:

View file

@ -128,7 +128,7 @@ class BackendCfg(QDialog):
self.connect(self.ui.configButtonBox, SIGNAL('rejected()'), self.rejectBackend)
def get_icon_cache(self, path):
if not path in self.icon_cache:
if path not in self.icon_cache:
img = QImage(path)
self.icon_cache[path] = QIcon(QPixmap.fromImage(img))
return self.icon_cache[path]
@ -358,7 +358,7 @@ class BackendCfg(QDialog):
self.ui.moduleInfo.document().addResource(QTextDocument.ImageResource, QUrl('mydata://logo.png'),
QVariant(img))
if not module.name in [n for n, ign, ign2 in self.weboob.backends_config.iter_backends()]:
if module.name not in [n for n, ign, ign2 in self.weboob.backends_config.iter_backends()]:
self.ui.nameEdit.setText(module.name)
else:
self.ui.nameEdit.setText('')

View file

@ -207,7 +207,7 @@ class ReplApplication(Cmd, ConsoleApplication):
backend.DESCRIPTION))
i = self.ask('Select a backend to proceed with "%s"' % id)
if not i.isdigit():
if not i in dict(e.backends):
if i not in dict(e.backends):
print('Error: %s is not a valid backend' % i, file=self.stderr)
continue
backend_name = i

View file

@ -57,7 +57,7 @@ class GenericNewspaperModule(Module, CapMessages):
thread = Thread(id)
flags = Message.IS_HTML
if not thread.id in self.storage.get('seen', default={}):
if thread.id not in self.storage.get('seen', default={}):
flags |= Message.IS_UNREAD
thread.title = content.title
if not thread.date:

View file

@ -62,7 +62,7 @@ class StandardStorage(IStorage):
def load(self, what, name, default={}):
d = {}
if not what in self.config.values:
if what not in self.config.values:
self.config.values[what] = {}
else:
d = self.config.values[what].get(name, {})

View file

@ -90,7 +90,7 @@ class Value(object):
raise ValueError('Value can\'t be empty')
if self.regexp is not None and not re.match(self.regexp, unicode(v)):
raise ValueError('Value "%s" does not match regexp "%s"' % (v, self.regexp))
if self.choices is not None and not v in self.choices:
if self.choices is not None and v not in self.choices:
raise ValueError('Value "%s" is not in list: %s' % (
v, ', '.join(unicode(s) for s in self.choices)))
@ -254,8 +254,8 @@ class ValueBool(Value):
def check_valid(self, v):
if not isinstance(v, bool) and \
not unicode(v).lower() in ('y', 'yes', '1', 'true', 'on',
'n', 'no', '0', 'false', 'off'):
unicode(v).lower() not in ('y', 'yes', '1', 'true', 'on',
'n', 'no', '0', 'false', 'off'):
raise ValueError('Value "%s" is not a boolean (y/n)' % v)
def get(self):