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

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

View file

@ -57,7 +57,7 @@ class GDCVaultVideo(BaseVideo):
# # file will not be accessible (not free and not logged in)
# return None
if not 'vault_media_id' in data:
if 'vault_media_id' not in data:
return None
media_id = int(data['vault_media_id'])
video = GDCVaultVideo(media_id)

View file

@ -49,10 +49,10 @@ class GoogleTranslateModule(Module, CapTranslate):
}
def translate(self, lan_from, lan_to, text):
if not lan_from in self.GOOGLELANGUAGE.keys():
if lan_from not in self.GOOGLELANGUAGE.keys():
raise LanguageNotSupported()
if not lan_to in self.GOOGLELANGUAGE.keys():
if lan_to not in self.GOOGLELANGUAGE.keys():
raise LanguageNotSupported()
translation = Translation(0)

View file

@ -72,7 +72,7 @@ class OperationsFuturesPage(LoggedPage, HTMLPage):
klass = Transaction
def condition(self):
return not u'Aucune opération en attente' in CleanText(TableCell('date'))(self)
return u'Aucune opération en attente' not in CleanText(TableCell('date'))(self)
obj_date = Date(CleanText(TableCell('date')), LinearDateGuesser())
obj_type = Transaction.TYPE_UNKNOWN
@ -94,7 +94,7 @@ class OperationsTraiteesPage(LoggedPage, HTMLPage):
klass = Transaction
def condition(self):
return not u'Aucune opération' in CleanText(TableCell('date'))(self)
return u'Aucune opération' not in CleanText(TableCell('date'))(self)
obj_date = Date(CleanText(TableCell('date')), LinearDateGuesser())
obj_type = Transaction.TYPE_UNKNOWN

View file

@ -68,7 +68,7 @@ class HDSModule(Module, CapMessages):
thread = Thread(story.id)
flags = 0
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 = story.title

View file

@ -131,7 +131,7 @@ class RoadmapPage(Page):
continue
for td in self.parser.select(tr, 'td'):
if not 'class' in td.attrib:
if 'class' not in td.attrib:
continue
if 'iti-inner' in td.attrib['class']:

View file

@ -32,7 +32,7 @@ class TorrentsPage(Page):
if tr.attrib.get('class', '') == 'odd' or tr.attrib.get('class', '') == ' even':
magnet = NotAvailable
url = NotAvailable
if not 'id' in tr.attrib:
if 'id' not in tr.attrib:
continue
title = self.parser.tocleanstring(tr.find('.//a[@class="cellMainLink"]'))
# WTF is that?

View file

@ -54,7 +54,7 @@ class NewsfeedModule(Module, CapMessages):
return None
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
if len(entry.content) > 0:
content = u"<p>Link %s</p> %s" % (entry.link, entry.content[0])

View file

@ -128,6 +128,6 @@ class NolifeTVModule(Module, CapVideo, CapCollection):
'quality=%s&a=UEM%%7CSEM%%7CMEM%%7CCH%%7CSWQ&skey=%s&id%%5Fnlshow=%s&timestamp=%s' % (quality, skey, id, timestamp))
values = dict([urllib.splitvalue(s) for s in data.split('&')])
if not 'url' in values:
if 'url' not in values:
return None
return unicode(values['url'])

View file

@ -92,7 +92,7 @@ class FamilyPage(Page):
subs = list()
for el in self.document.xpath('//ul/li[@data-role="list-divider"]'):
if not el.text in subs:
if el.text not in subs:
yield Collection([el.text], unicode(el.text))
subs.append(el.text)

View file

@ -63,7 +63,7 @@ class NovaModule(Module, CapRadio, CapCollection):
if not isinstance(radio, Radio):
radio = Radio(radio)
if not radio.id in self._RADIOS:
if radio.id not in self._RADIOS:
return None
title, description, url = self._RADIOS[radio.id]

View file

@ -169,7 +169,7 @@ class OkCModule(Module, CapMessages, CapContact, CapMessagesPost, CapDating):
flags |= Message.IS_UNREAD
if get_profiles:
if not mail['id_from'] in contacts:
if mail['id_from'] not in contacts:
with self.browser:
contacts[mail['id_from']] = self.get_contact(mail['id_from'])
@ -219,7 +219,7 @@ class OkCModule(Module, CapMessages, CapContact, CapMessagesPost, CapDating):
def _get_slut(self, 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)}
else:
slut = self.storage.get('sluts', id)

View file

@ -163,7 +163,7 @@ class ProfilePage(Page):
if 'looking for' in label:
for i, li in enumerate(val.xpath('.//li')):
profile['data']['look_for'].value['look_for_%s' % i] = ProfileNode('look_for_%s' % i, '', li.text.strip())
elif 'summary' in label and not 'summary' in profile:
elif 'summary' in label and 'summary' not in profile:
profile['summary'] = txt
else:
key = label.replace(' ', '_')

View file

@ -79,7 +79,7 @@ class OuiFMModule(Module, CapRadio, CapCollection):
if not isinstance(radio, Radio):
radio = Radio(radio)
if not radio.id in self._RADIOS:
if radio.id not in self._RADIOS:
return None
title, description, url, bitrate = self._RADIOS[radio.id]

View file

@ -104,7 +104,7 @@ class QuviVideo(BaseVideo):
if _id.startswith('http'):
return _id
if not '.' in _id:
if '.' not in _id:
raise UserError('Please give an ID in form WEBSITE.ID (for example youtube.BaW_jenozKc). Supported websites are: %s' % ', '.join(cls.BACKENDS.keys()))
sub_backend, sub_id = _id.split('.', 1)

View file

@ -160,7 +160,7 @@ class IssuesPage(BaseIssuePage):
def get_values(key):
values = []
if not key in args:
if key not in args:
return values
for key, value in args[key]['values']:
if value.isdigit():
@ -394,7 +394,7 @@ class IssuePage(NewIssuePage):
# check issue 666 on symlink.me
i = 0
alist = author.findall('a')
if not 'title' in alist[i].attrib:
if 'title' not in alist[i].attrib:
params['author'] = (int(alist[i].attrib['href'].split('/')[-1]),
to_unicode(alist[i].text))
i += 1

View file

@ -64,7 +64,7 @@ class SeLogerModule(Module, CapHousing):
if categories['label'] != 'Villes':
continue
for city in categories['values']:
if not 'value' in city:
if 'value' not in city:
continue
c = City(city['value'])
c.name = unicode(city['label'])

View file

@ -52,7 +52,7 @@ class AccountsList(BasePage):
def get_list(self):
for tr in self.document.getiterator('tr'):
if not 'LGNTableRow' in tr.attrib.get('class', '').split():
if 'LGNTableRow' not in tr.attrib.get('class', '').split():
continue
account = Account()

View file

@ -45,7 +45,7 @@ class FacebookBrowser(DomainBrowser):
form['pass'] = password
form['persistent'] = 1
form.submit(allow_redirects=False)
if not 'Location' in self.response.headers:
if 'Location' not in self.response.headers:
raise BrowserIncorrectPassword()
self.location(self.response.headers['Location'])

View file

@ -90,7 +90,7 @@ class VoyagesSNCFModule(Module, CapTravel):
yield Station(_id, unicode(name))
# ...then ones whose name contains pattern.
for _id, name in enumerate(self.STATIONS):
if pattern in name.lower() and not _id in already:
if pattern in name.lower() and _id not in already:
yield Station(_id, unicode(name))
def iter_station_departures(self, station_id, arrival_id=None, date=None):

View file

@ -43,10 +43,10 @@ class WordReferenceModule(Module, CapTranslate):
}
def translate(self, lan_from, lan_to, text):
if not lan_from in self.WRLANGUAGE.keys():
if lan_from not in self.WRLANGUAGE.keys():
raise LanguageNotSupported()
if not lan_to in self.WRLANGUAGE.keys():
if lan_to not in self.WRLANGUAGE.keys():
raise LanguageNotSupported()
translation = Translation(0)