Fix comparisons to None

Diff checked manually.

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

This required the "agressive" option because it can change code
behavior.
This commit is contained in:
Laurent Bachelier 2013-03-15 20:20:35 +01:00
commit e0542c2e4a
14 changed files with 27 additions and 27 deletions

View file

@ -123,7 +123,7 @@ class Downloadboob:
def id_regexp_matched(self, video_id, id_regexp): def id_regexp_matched(self, video_id, id_regexp):
if 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 return True
def get_filename(self, video, relative=False): def get_filename(self, video, relative=False):

View file

@ -60,7 +60,7 @@ class AccountsList(BasePage):
elif td.attrib.get('class', '') == 'account-total': elif td.attrib.get('class', '') == 'account-total':
span = td.find('span') span = td.find('span')
if span == None: if span is None:
balance = td.text balance = td.text
else: else:
balance = span.text balance = span.text

View file

@ -153,7 +153,7 @@ class CICBrowser(BaseBrowser):
self['IDB'] = [account[-1]] self['IDB'] = [account[-1]]
self['ICR'] = [to[-1]] self['ICR'] = [to[-1]]
self['MTTVIR'] = '%s' % str(amount).replace('.', ',') self['MTTVIR'] = '%s' % str(amount).replace('.', ',')
if reason != None: if reason is not None:
self['LIBDBT'] = reason self['LIBDBT'] = reason
self['LIBCRT'] = reason self['LIBCRT'] = reason
self.submit() self.submit()

View file

@ -228,7 +228,7 @@ class Cragr(BaseBrowser):
self['numCompteBeneficiaire'] = ['%s' % self.dict_find_value(target_accounts, to)] self['numCompteBeneficiaire'] = ['%s' % self.dict_find_value(target_accounts, to)]
self['montantPartieEntiere'] = '%s' % amount_euros self['montantPartieEntiere'] = '%s' % amount_euros
self['montantPartieDecimale'] = '%02d' % amount_cents self['montantPartieDecimale'] = '%02d' % amount_cents
if reason != None: if reason is not None:
self['libelle'] = reason self['libelle'] = reason
self.submit() self.submit()

View file

@ -153,7 +153,7 @@ class CreditMutuelBrowser(BaseBrowser):
self['IDB'] = [account[-1]] self['IDB'] = [account[-1]]
self['ICR'] = [to[-1]] self['ICR'] = [to[-1]]
self['MTTVIR'] = '%s' % str(amount).replace('.', ',') self['MTTVIR'] = '%s' % str(amount).replace('.', ',')
if reason != None: if reason is not None:
self['LIBDBT'] = reason self['LIBDBT'] = reason
self['LIBCRT'] = reason self['LIBCRT'] = reason
self.submit() self.submit()

View file

@ -74,7 +74,7 @@ class ImdbBackend(BaseBackend, ICapCinema):
or 'death_date' in fields or 'nationality' in fields\ or 'death_date' in fields or 'nationality' in fields\
or 'short_biography' in fields or 'roles' in fields\ or 'short_biography' in fields or 'roles' in fields\
or 'birth_date' in fields or 'thumbnail_url' 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) per = self.get_person(person.id)
person.real_name = per.real_name person.real_name = per.real_name
person.birth_date = per.birth_date person.birth_date = per.birth_date

View file

@ -89,7 +89,7 @@ class ImdbBrowser(BaseBrowser):
def get_movie(self, id): 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 ) 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) jres = json.loads(res)
else: else:
return None return None

View file

@ -37,7 +37,7 @@ class ReleasePage(BasePage):
for a in links: for a in links:
href = a.attrib.get('href','') href = a.attrib.get('href','')
if href.strip('/').split('/')[0] == 'calendar' and\ 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 country = a.text
td_date = self.parser.select(a.getparent().getparent().getparent(),'td')[1] td_date = self.parser.select(a.getparent().getparent().getparent(),'td')[1]
date_links = self.parser.select(td_date,'a') date_links = self.parser.select(td_date,'a')
@ -73,7 +73,7 @@ class MovieCrewPage(BasePage):
''' Page listing all the persons related to a movie ''' Page listing all the persons related to a movie
''' '''
def iter_persons(self, role_filter=None): 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') tables = self.parser.select(self.document.getroot(),'table.cast')
if len(tables) > 0: if len(tables) > 0:
table = 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'): for gloss_link in self.parser.select(self.document.getroot(),'table[cellspacing=1] h5 a'):
role = gloss_link.attrib.get('name','').rstrip('s') 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() tbody = gloss_link.getparent().getparent().getparent().getparent()
for line in self.parser.select(tbody,'tr')[1:]: for line in self.parser.select(tbody,'tr')[1:]:
for a in self.parser.select(line,'a'): for a in self.parser.select(line,'a'):
@ -217,7 +217,7 @@ class FilmographyPage(BasePage):
def iter_movies(self, role_filter=None): def iter_movies(self, role_filter=None):
for role_div in self.parser.select(self.document.getroot(),'div.filmo'): for role_div in self.parser.select(self.document.getroot(),'div.filmo'):
role = self.parser.select(role_div,'h5 a',1).text.replace(':','') 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': and role != 'In Development':
for a in self.parser.select(role_div,'ol > li > a'): for a in self.parser.select(role_div,'ol > li > a'):
id = a.attrib.get('href','').strip('/').split('/')[-1] id = a.attrib.get('href','').strip('/').split('/')[-1]

View file

@ -59,9 +59,9 @@ class ImdbTest(BackendTest):
def test_get_person_biography(self): def test_get_person_biography(self):
bio = self.backend.get_person_biography('nm0223033') bio = self.backend.get_person_biography('nm0223033')
assert bio != '' assert bio != ''
assert bio != None assert bio is not None
def test_get_movie_releases(self): def test_get_movie_releases(self):
rel = self.backend.get_movie_releases('tt0079980') rel = self.backend.get_movie_releases('tt0079980')
assert rel != '' assert rel != ''
assert rel != None assert rel is not None

View file

@ -53,9 +53,9 @@ class TorrentsPage(BasePage):
size = float(size[:-3]) size = float(size[:-3])
sseed = tr.getchildren()[4].text sseed = tr.getchildren()[4].text
sleech = tr.getchildren()[5].text sleech = tr.getchildren()[5].text
if sseed != None and sseed != "": if sseed is not None and sseed != "":
seed = int(sseed) seed = int(sseed)
if sleech != None and sleech != "": if sleech is not None and sleech != "":
leech = int(sleech) leech = int(sleech)
url = u'https://isohunt.com/download/%s/mon_joli_torrent.torrent' % idt url = u'https://isohunt.com/download/%s/mon_joli_torrent.torrent' % idt
torrent = Torrent(idt, title) torrent = Torrent(idt, title)
@ -101,7 +101,7 @@ class TorrentPage(BasePage):
if p.attrib.get('style', '') == 'line-height:1.2em;margin-top:1.8em': if p.attrib.get('style', '') == 'line-height:1.2em;margin-top:1.8em':
count_p_found += 1 count_p_found += 1
if 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) description = unicode(p.getchildren()[1].tail)
if count_p_found == 2: if count_p_found == 2:
if p.getchildren()[0].text == 'Directory:': if p.getchildren()[0].text == 'Directory:':

View file

@ -40,7 +40,7 @@ class ArtistResultsPage(BasePage):
class ArtistSongsPage(BasePage): class ArtistSongsPage(BasePage):
def iter_lyrics(self,artist=None): 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 ','') 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'): for link in self.parser.select(self.document.getroot(),'div#albums a'):
href = link.attrib.get('href','') href = link.attrib.get('href','')

View file

@ -66,7 +66,7 @@ class AccountsList(BasePage):
elif td.attrib.get('headers', '') == 'Solde': elif td.attrib.get('headers', '') == 'Solde':
balance = td.find('div').text if td.find('div') is not None else None 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) account.currency = account.get_currency(balance)
balance = FrenchTransaction.clean_amount(balance) balance = FrenchTransaction.clean_amount(balance)
account.balance = Decimal(balance) account.balance = Decimal(balance)

View file

@ -109,7 +109,7 @@ class MainWindow(QtMainWindow):
f=codecs.open(history_path,'r','utf-8') f=codecs.open(history_path,'r','utf-8')
conf_hist = f.read() conf_hist = f.read()
f.close() 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') result = conf_hist.strip().split('\n')
return result return result
@ -140,7 +140,7 @@ class MainWindow(QtMainWindow):
and save it in the action history and save it in the action history
''' '''
self.ui.currentActionLabel.setText(description) 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.action_history['action_list'].append(self.action_history['last_action'])
self.ui.backButton.setToolTip(self.action_history['last_action']['description']) self.ui.backButton.setToolTip(self.action_history['last_action']['description'])
self.ui.backButton.show() self.ui.backButton.show()
@ -246,7 +246,7 @@ class MainWindow(QtMainWindow):
def displayMovie(self, movie, backend): def displayMovie(self, movie, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) 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.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide() self.current_info_widget.hide()
self.current_info_widget.deleteLater() self.current_info_widget.deleteLater()
@ -289,7 +289,7 @@ class MainWindow(QtMainWindow):
def displayPerson(self, person, backend): def displayPerson(self, person, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) 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.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide() self.current_info_widget.hide()
self.current_info_widget.deleteLater() self.current_info_widget.deleteLater()
@ -332,7 +332,7 @@ class MainWindow(QtMainWindow):
def displayTorrent(self, torrent, backend): def displayTorrent(self, torrent, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) 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.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide() self.current_info_widget.hide()
self.current_info_widget.deleteLater() self.current_info_widget.deleteLater()
@ -375,7 +375,7 @@ class MainWindow(QtMainWindow):
def displaySubtitle(self, subtitle, backend): def displaySubtitle(self, subtitle, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) 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.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide() self.current_info_widget.hide()
self.current_info_widget.deleteLater() self.current_info_widget.deleteLater()

View file

@ -115,7 +115,7 @@ class GenericNewsPage(BasePage):
self.element_title_selector, self.element_title_selector,
1).text_content().strip() 1).text_content().strip()
except AttributeError: except AttributeError:
if self.main_div == None: if self.main_div is None:
#TODO: Mettre un warning #TODO: Mettre un warning
return self.__article.title return self.__article.title
else: else:
@ -132,7 +132,7 @@ class GenericNewsPage(BasePage):
except BrokenPageError: except BrokenPageError:
raise NoBodyElement("no body on %s" % (self.browser)) raise NoBodyElement("no body on %s" % (self.browser))
except AttributeError: except AttributeError:
if self.main_div == None: if self.main_div is None:
raise NoneMainDiv("main_div is none on %s" % (self.browser)) raise NoneMainDiv("main_div is none on %s" % (self.browser))
else: else:
raise raise
@ -143,7 +143,7 @@ class GenericNewsPage(BasePage):
except BrokenPageError: except BrokenPageError:
raise NoAuthorElement() raise NoAuthorElement()
except AttributeError: except AttributeError:
if self.main_div == None: if self.main_div is None:
raise NoneMainDiv("main_div is none on %s" % (self.browser)) raise NoneMainDiv("main_div is none on %s" % (self.browser))
else: else:
raise raise