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

@ -20,7 +20,7 @@ def genapi():
subs = set()
for f in files:
if not '.' in f:
if '.' not in f:
continue
f, ext = f.rsplit('.', 1)

View file

@ -33,7 +33,7 @@ __all__ = ['AudioAddictModule']
#
# WARNING
#
# AudioAddict playlists do not seem to be appreciated by mplayer
# AudioAddict playlists do not seem to be appreciated by mplayer
# VLC plays them successfully, therefore I advice to set the media_player
# option to another player in the ~/.config/weboob/radioob config file:
# [ROOT]
@ -160,7 +160,7 @@ class AudioAddictModule(Module, CapRadio, CapCollection):
streamName = self._get_stream_name(selectedNetwork, quality)
if not self.RADIOS:
self.RADIOS = {}
if not selectedNetwork in self.RADIOS:
if selectedNetwork not in self.RADIOS:
document = self.browser.location('http://listen.%s/%s' %
(self.NETWORKS[selectedNetwork]['domain'],
streamName))
@ -199,7 +199,7 @@ class AudioAddictModule(Module, CapRadio, CapCollection):
def get_current(self, network, radio):
channel = {}
if not network in self.HISTORY:
if network not in self.HISTORY:
self._get_tracks_history(network)
channel = self.HISTORY[network].get(str(self.RADIOS[network][radio]['id']))
else:
@ -229,7 +229,7 @@ class AudioAddictModule(Module, CapRadio, CapCollection):
self._fetch_radio_list(network)
if not radioName in self.RADIOS[network]:
if radioName not in self.RADIOS[network]:
return None
radio_dict = self.RADIOS[network][radioName]

View file

@ -196,7 +196,7 @@ class AuMModule(Module, CapMessages, CapMessagesPost, CapDating, CapChat, CapCon
flags |= Message.IS_UNREAD
if get_profiles:
if not mail['from'] in contacts:
if mail['from'] not in contacts:
try:
with self.browser:
contacts[mail['from']] = self.get_contact(mail['from'])
@ -329,7 +329,7 @@ class AuMModule(Module, CapMessages, CapMessagesPost, CapDating, CapChat, CapCon
def _get_slut(self, id):
id = int(id)
sluts = self.storage.get('sluts')
if not sluts or not id in sluts:
if not sluts or id not in sluts:
slut = {'lastmsg': datetime.datetime(1970,1,1),
'status': None}
else:

View file

@ -128,7 +128,7 @@ class AccountsPage(BasePage):
continue
self.logger.debug('Args: %r' % args)
if not 'paramNumCompte' in args:
if 'paramNumCompte' not in args:
try:
label = unicode(table.xpath('./caption')[0].text.strip())
except Exception:

View file

@ -171,7 +171,7 @@ class AccountsPage(LoggedPage, HTMLPage):
continue
if len(left.xpath('./span[@class="precision"]')) == 0 or \
(left.text is None or not 'total' in left.text.lower()):
(left.text is None or 'total' not in left.text.lower()):
continue
balance -= CleanDecimal('.', replace_dots=False)(right)

View file

@ -266,13 +266,13 @@ class AccountsPage(BasePage):
currency = Account.get_currency(m.group(1))
for tr in div.getnext().xpath('.//tbody/tr'):
if not 'id' in tr.attrib:
if 'id' not in tr.attrib:
continue
args = dict(parse_qsl(tr.attrib['id']))
tds = tr.findall('td')
if len(tds) < 4 or not 'identifiant' in args:
if len(tds) < 4 or 'identifiant' not in args:
self.logger.warning('Unable to parse an account')
continue

View file

@ -104,7 +104,7 @@ class AccountsPage(Page):
text = script.text
if text is None:
continue
if not 'remotePerso' in text:
if 'remotePerso' not in text:
continue
account = None

View file

@ -153,7 +153,7 @@ class AccountsPage(BredBasePage):
if a is None:
for a in cols[0].xpath('.//li/a'):
args = self.js2args(a.attrib['href'])
if not 'numero_compte' in args or not 'numero_poste' in args:
if 'numero_compte' not in args or 'numero_poste' not in args:
self.logger.warning('Card link with strange args: %s' % args)
continue
@ -168,7 +168,7 @@ class AccountsPage(BredBasePage):
args = self.js2args(a.attrib['href'])
if not 'numero_compte' in args or not 'numero_poste' in args:
if 'numero_compte' not in args or 'numero_poste' not in args:
self.logger.warning('Account link for %r with strange args: %s' % (a.attrib.get('alt', a.text), args))
continue

View file

@ -117,6 +117,6 @@ class VideoPage(Page):
def get_video(self, video):
_id = self.group_dict['id']
for vid in self.document.getchildren():
if not _id in vid.find('ID').text:
if _id not in vid.find('ID').text:
continue
return self.parse_video(vid, video)

View file

@ -51,7 +51,7 @@ class CanalTP(Browser):
result = result
departure = ''
for line in result.split('&'):
if not '=' in line:
if '=' not in line:
raise BrokenPageError('Unable to parse result: %s' % line)
key, value = line.split('=', 1)
if key == 'nomgare':

View file

@ -93,7 +93,7 @@ class AccountsPage(Page):
url = urlparse(link)
p = parse_qs(url.query)
if not 'rib' in p:
if 'rib' not in p:
continue
for i in (2,1):

View file

@ -208,11 +208,11 @@ class CragrMobile(Browser):
target_accounts = self.page.get_transfer_target_accounts()
# check that the given source account can be used
if not account in source_accounts.values():
if account not in source_accounts.values():
raise TransferError('You cannot use account %s as a source account.' % account)
# check that the given source account can be used
if not to in target_accounts.values():
if to not in target_accounts.values():
raise TransferError('You cannot use account %s as a target account.' % to)
# separate euros from cents

View file

@ -109,7 +109,7 @@ class AccountsList(CragrBasePage):
elif self.look_like_account_name(token):
required_tokens['account_name'] = token
elif self.look_like_account_owner(token):
if 'account_owner' in optional_tokens and not 'account_name' in required_tokens:
if 'account_owner' in optional_tokens and 'account_name' not in required_tokens:
required_tokens['account_name'] = optional_tokens['account_owner']
optional_tokens['account_owner'] = token
# Step 3: create account objects

View file

@ -296,7 +296,7 @@ class ProTransactionsPage(TransactionsPage):
for i, key, value in re.findall('listeopecv\[(\d+)\]\[\'(\w+)\'\]="(.*)";', txt):
i = int(i)
if not i in transactions:
if i not in transactions:
transactions[i] = {}
transactions[i][key] = value

View file

@ -177,7 +177,7 @@ class CreditMutuelBrowser(LoginBrowser):
# look for the known "everything went well" message
content = page.response.text
transfer_ok_message = u'Votre virement a été exécuté ce jour'
if not transfer_ok_message in content:
if transfer_ok_message not in content:
raise TransferError('The expected message "%s" was not found.' % transfer_ok_message)
# We now have to return a Transfer object

View file

@ -124,7 +124,7 @@ class AccountsPage(LoggedPage, HTMLPage):
url = urlparse(link)
p = parse_qs(url.query)
if not 'rib' in p:
if 'rib' not in p:
raise SkipItem()
balance = CleanDecimal('./td[2] | ./td[3]', replace_dots=True)(self)

View file

@ -119,7 +119,7 @@ class DLFPModule(Module, CapMessages, CapMessagesPost, CapContent):
thread = Thread(content.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
@ -148,7 +148,7 @@ class DLFPModule(Module, CapMessages, CapMessagesPost, CapContent):
Insert 'com' comment and its children in the parent message.
"""
flags = Message.IS_HTML
if not com.id in self.storage.get('seen', parent.thread.id, 'comments', default=[]):
if com.id not in self.storage.get('seen', parent.thread.id, 'comments', default=[]):
flags |= Message.IS_UNREAD
if getseen or flags & Message.IS_UNREAD:

View file

@ -76,7 +76,7 @@ class FeedlyModule(Module, CapMessages, CapCollection):
if entry is None:
return None
if not thread.id in self.storage.get('seen', default=[]):
if thread.id not in self.storage.get('seen', default=[]):
entry.flags = Message.IS_UNREAD
entry.thread = thread

View file

@ -18,8 +18,6 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.messages import CapMessages, Message, Thread
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import Value
@ -51,7 +49,7 @@ class FourChanModule(Module, CapMessages):
thread = id
id = thread.id
if not '.' in id:
if '.' not in id:
self.logger.warning('Malformated ID (%s)' % id)
return
@ -61,7 +59,7 @@ class FourChanModule(Module, CapMessages):
_thread = self.browser.get_thread(board, thread_id)
flags = 0
if not _thread.id in self.storage.get('boards', board, default={}):
if _thread.id not in self.storage.get('boards', board, default={}):
flags |= Message.IS_UNREAD
if not thread:
@ -81,7 +79,7 @@ class FourChanModule(Module, CapMessages):
for comment in _thread.comments:
flags = 0
if not comment.id in self.storage.get('boards', board, _thread.id, default=[]):
if comment.id not in self.storage.get('boards', board, _thread.id, default=[]):
flags |= Message.IS_UNREAD
m = Message(thread=thread,

View file

@ -60,7 +60,7 @@ class GazelleBrowser(Browser):
return self.page.iter_torrents()
def get_torrent(self, fullid):
if not '.' in fullid:
if '.' not in fullid:
return None
id, torrentid = fullid.split('.', 1)
self.location(self.buildurl('/torrents.php', id=id, torrentid=torrentid))

Some files were not shown because too many files have changed in this diff Show more