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

@ -205,7 +205,7 @@ class HaveDate(Boobmsg):
if backend_name == '*':
backend_name = None
elif backend_name is not None and not backend_name in [b.name for b in self.enabled_backends]:
elif backend_name is not None and backend_name not in [b.name for b in self.enabled_backends]:
print('Error: No such backend "%s"' % backend_name, file=self.stderr)
return 1
@ -223,13 +223,13 @@ class HaveDate(Boobmsg):
optims = {}
backends = set()
for (name, optim) in self.do('iter_optimizations', backends=backend_name):
if optims_names is not None and not name in optims_names:
if optims_names is not None and name not in optims_names:
continue
if optim.is_running():
status = 'RUNNING'
else:
status = '-------'
if not name in optims:
if name not in optims:
optims[name] = {optim.backend: status}
else:
optims[name][optim.backend] = status

View file

@ -49,7 +49,7 @@ class HousingListWidgetItem(QListWidgetItem):
text += u'<br /><font color="#008800">%s</font>' % storage.get('notes', self.housing.fullid, default='').strip().replace('\n', '<br />')
self.setText(text)
if not self.housing.fullid in storage.get('read'):
if self.housing.fullid not in storage.get('read'):
self.setBackground(QBrush(QColor(200, 200, 255)))
self.read = False
elif self.housing.fullid in storage.get('bookmarks'):

View file

@ -80,7 +80,7 @@ class MainWindow(QtMainWindow):
def tabChanged(self, i):
widget = self.ui.tabWidget.currentWidget()
if hasattr(widget, 'load') and not i in self.loaded_tabs:
if hasattr(widget, 'load') and i not in self.loaded_tabs:
widget.load()
self.loaded_tabs[i] = True

View file

@ -103,9 +103,9 @@ class Translaboob(ReplApplication):
lan_from, lan_to, text = self.parse_command_args(line, 3, 2)
try:
if not lan_from in self.LANGUAGE.keys():
if lan_from not in self.LANGUAGE.keys():
raise LanguageNotSupported()
if not lan_to in self.LANGUAGE.keys():
if lan_to not in self.LANGUAGE.keys():
raise LanguageNotSupported()
if not text or text == '-':

View file

@ -366,7 +366,7 @@ class Browser(object):
It only redirect to the refresh URL if the sleep time is inferior to
REFRESH_MAX.
"""
if not 'Refresh' in response.headers:
if 'Refresh' not in response.headers:
return response
m = self.REFRESH_RE.match(response.headers['Refresh'])

View file

@ -392,7 +392,7 @@ class BaseObject(object):
try:
attr = (self._fields or {})[name]
except KeyError:
if not name in dir(self) and not name.startswith('_'):
if name not in dir(self) and not name.startswith('_'):
warnings.warn('Creating a non-field attribute %s. Please prefix it with _' % name,
AttributeCreationWarning, stacklevel=2)
object.__setattr__(self, name, value)

View file

@ -101,7 +101,7 @@ class Contact(BaseObject):
:type name: str
:param kwargs: See :class:`ContactPhoto` to know what other parameters you can use
"""
if not name in self.photos:
if name not in self.photos:
self.photos[name] = ContactPhoto(name)
photo = self.photos[name]

View file

@ -483,7 +483,7 @@ class Repositories(object):
modules = {}
for repos in reversed(self.repositories):
for name, info in repos.modules.iteritems():
if not name in modules and (not caps or info.has_caps(caps)):
if name not in modules and (not caps or info.has_caps(caps)):
modules[name] = self._extend_module_info(repos, info)
return modules

View file

@ -265,7 +265,7 @@ class StandardBrowser(mechanize.Browser):
"""
Download URL data specifying what to do on failure (nothing by default).
"""
if not 'if_fail' in kwargs:
if 'if_fail' not in kwargs:
kwargs['if_fail'] = None
result = self.openurl(url, *args, **kwargs)

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):