Commit e0542c2e authored by Laurent Bachelier's avatar Laurent Bachelier 🐧

Fix comparisons to None

Diff checked manually.

autopep8 -a -ir -j2 --select=E711 .

This required the "agressive" option because it can change code
behavior.
parent 7094931c
......@@ -123,7 +123,7 @@ class Downloadboob:
def id_regexp_matched(self, video_id, id_regexp):
if id_regexp:
return re.search(id_regexp, video_id) != None
return re.search(id_regexp, video_id) is not None
return True
def get_filename(self, video, relative=False):
......
......@@ -60,7 +60,7 @@ class AccountsList(BasePage):
elif td.attrib.get('class', '') == 'account-total':
span = td.find('span')
if span == None:
if span is None:
balance = td.text
else:
balance = span.text
......
......@@ -153,7 +153,7 @@ class CICBrowser(BaseBrowser):
self['IDB'] = [account[-1]]
self['ICR'] = [to[-1]]
self['MTTVIR'] = '%s' % str(amount).replace('.', ',')
if reason != None:
if reason is not None:
self['LIBDBT'] = reason
self['LIBCRT'] = reason
self.submit()
......
......@@ -228,7 +228,7 @@ class Cragr(BaseBrowser):
self['numCompteBeneficiaire'] = ['%s' % self.dict_find_value(target_accounts, to)]
self['montantPartieEntiere'] = '%s' % amount_euros
self['montantPartieDecimale'] = '%02d' % amount_cents
if reason != None:
if reason is not None:
self['libelle'] = reason
self.submit()
......
......@@ -153,7 +153,7 @@ class CreditMutuelBrowser(BaseBrowser):
self['IDB'] = [account[-1]]
self['ICR'] = [to[-1]]
self['MTTVIR'] = '%s' % str(amount).replace('.', ',')
if reason != None:
if reason is not None:
self['LIBDBT'] = reason
self['LIBCRT'] = reason
self.submit()
......
......@@ -74,7 +74,7 @@ class ImdbBackend(BaseBackend, ICapCinema):
or 'death_date' in fields or 'nationality' in fields\
or 'short_biography' in fields or 'roles' in fields\
or 'birth_date' in fields or 'thumbnail_url' in fields\
or 'gender' in fields or fields == None:
or 'gender' in fields or fields is None:
per = self.get_person(person.id)
person.real_name = per.real_name
person.birth_date = per.birth_date
......
......@@ -89,7 +89,7 @@ class ImdbBrowser(BaseBrowser):
def get_movie(self, id):
res = self.readurl('http://imdbapi.org/?id=%s&type=json&plot=simple&episode=1&lang=en-US&aka=full&release=simple&business=0&tech=0' % id )
if res != None:
if res is not None:
jres = json.loads(res)
else:
return None
......
......@@ -37,7 +37,7 @@ class ReleasePage(BasePage):
for a in links:
href = a.attrib.get('href','')
if href.strip('/').split('/')[0] == 'calendar' and\
(country_filter == None or href.split('region=')[-1].lower() == country_filter):
(country_filter is None or href.split('region=')[-1].lower() == country_filter):
country = a.text
td_date = self.parser.select(a.getparent().getparent().getparent(),'td')[1]
date_links = self.parser.select(td_date,'a')
......@@ -73,7 +73,7 @@ class MovieCrewPage(BasePage):
''' Page listing all the persons related to a movie
'''
def iter_persons(self, role_filter=None):
if (role_filter == None or (role_filter != None and role_filter == 'actor')):
if (role_filter is None or (role_filter is not None and role_filter == 'actor')):
tables = self.parser.select(self.document.getroot(),'table.cast')
if len(tables) > 0:
table = tables[0]
......@@ -97,7 +97,7 @@ class MovieCrewPage(BasePage):
for gloss_link in self.parser.select(self.document.getroot(),'table[cellspacing=1] h5 a'):
role = gloss_link.attrib.get('name','').rstrip('s')
if (role_filter == None or (role_filter != None and role == role_filter)):
if (role_filter is None or (role_filter is not None and role == role_filter)):
tbody = gloss_link.getparent().getparent().getparent().getparent()
for line in self.parser.select(tbody,'tr')[1:]:
for a in self.parser.select(line,'a'):
......@@ -217,7 +217,7 @@ class FilmographyPage(BasePage):
def iter_movies(self, role_filter=None):
for role_div in self.parser.select(self.document.getroot(),'div.filmo'):
role = self.parser.select(role_div,'h5 a',1).text.replace(':','')
if (role_filter == None or (role_filter != None and role.lower().strip() == role_filter))\
if (role_filter is None or (role_filter is not None and role.lower().strip() == role_filter))\
and role != 'In Development':
for a in self.parser.select(role_div,'ol > li > a'):
id = a.attrib.get('href','').strip('/').split('/')[-1]
......
......@@ -59,9 +59,9 @@ class ImdbTest(BackendTest):
def test_get_person_biography(self):
bio = self.backend.get_person_biography('nm0223033')
assert bio != ''
assert bio != None
assert bio is not None
def test_get_movie_releases(self):
rel = self.backend.get_movie_releases('tt0079980')
assert rel != ''
assert rel != None
assert rel is not None
......@@ -53,9 +53,9 @@ class TorrentsPage(BasePage):
size = float(size[:-3])
sseed = tr.getchildren()[4].text
sleech = tr.getchildren()[5].text
if sseed != None and sseed != "":
if sseed is not None and sseed != "":
seed = int(sseed)
if sleech != None and sleech != "":
if sleech is not None and sleech != "":
leech = int(sleech)
url = u'https://isohunt.com/download/%s/mon_joli_torrent.torrent' % idt
torrent = Torrent(idt, title)
......@@ -101,7 +101,7 @@ class TorrentPage(BasePage):
if p.attrib.get('style', '') == 'line-height:1.2em;margin-top:1.8em':
count_p_found += 1
if count_p_found == 1:
if p.getchildren()[1].tail != None:
if p.getchildren()[1].tail is not None:
description = unicode(p.getchildren()[1].tail)
if count_p_found == 2:
if p.getchildren()[0].text == 'Directory:':
......
......@@ -40,7 +40,7 @@ class ArtistResultsPage(BasePage):
class ArtistSongsPage(BasePage):
def iter_lyrics(self,artist=None):
if artist == None:
if artist is None:
artist = self.parser.select(self.document.getroot(),'head > title',1).text.replace('Paroles ','')
for link in self.parser.select(self.document.getroot(),'div#albums a'):
href = link.attrib.get('href','')
......
......@@ -66,7 +66,7 @@ class AccountsList(BasePage):
elif td.attrib.get('headers', '') == 'Solde':
balance = td.find('div').text if td.find('div') is not None else None
if balance != None:
if balance is not None:
account.currency = account.get_currency(balance)
balance = FrenchTransaction.clean_amount(balance)
account.balance = Decimal(balance)
......
......@@ -109,7 +109,7 @@ class MainWindow(QtMainWindow):
f=codecs.open(history_path,'r','utf-8')
conf_hist = f.read()
f.close()
if conf_hist != None and conf_hist.strip() != '':
if conf_hist is not None and conf_hist.strip() != '':
result = conf_hist.strip().split('\n')
return result
......@@ -140,7 +140,7 @@ class MainWindow(QtMainWindow):
and save it in the action history
'''
self.ui.currentActionLabel.setText(description)
if self.action_history['last_action'] != None:
if self.action_history['last_action'] is not None:
self.action_history['action_list'].append(self.action_history['last_action'])
self.ui.backButton.setToolTip(self.action_history['last_action']['description'])
self.ui.backButton.show()
......@@ -246,7 +246,7 @@ class MainWindow(QtMainWindow):
def displayMovie(self, movie, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget != None:
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
......@@ -289,7 +289,7 @@ class MainWindow(QtMainWindow):
def displayPerson(self, person, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget != None:
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
......@@ -332,7 +332,7 @@ class MainWindow(QtMainWindow):
def displayTorrent(self, torrent, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget != None:
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
......@@ -375,7 +375,7 @@ class MainWindow(QtMainWindow):
def displaySubtitle(self, subtitle, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget != None:
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
......
......@@ -115,7 +115,7 @@ class GenericNewsPage(BasePage):
self.element_title_selector,
1).text_content().strip()
except AttributeError:
if self.main_div == None:
if self.main_div is None:
#TODO: Mettre un warning
return self.__article.title
else:
......@@ -132,7 +132,7 @@ class GenericNewsPage(BasePage):
except BrokenPageError:
raise NoBodyElement("no body on %s" % (self.browser))
except AttributeError:
if self.main_div == None:
if self.main_div is None:
raise NoneMainDiv("main_div is none on %s" % (self.browser))
else:
raise
......@@ -143,7 +143,7 @@ class GenericNewsPage(BasePage):
except BrokenPageError:
raise NoAuthorElement()
except AttributeError:
if self.main_div == None:
if self.main_div is None:
raise NoneMainDiv("main_div is none on %s" % (self.browser))
else:
raise
......
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