Skip to content
Snippets Groups Projects
Commit 48ab42f0 authored by Jean-Christophe Fillion-Robin's avatar Jean-Christophe Fillion-Robin
Browse files

STYLE: src/Admin: Update python scripts to use "is None" instead of "== None"

Rational copied from https://www.python.org/dev/peps/pep-0290/#testing-for-none

// -----------------
Since there is only one None object, equality can be tested with identity. Identity
tests are slightly faster than equality tests. Also, some object types may overload
comparison, so equality testing may be much slower.

Pattern:

if v == None  -->  if v is None:
if v != None  -->  if v is not None:
// -----------------
parent 697b15ab
No related branches found
No related tags found
No related merge requests found
...@@ -88,7 +88,7 @@ def getPage(url): ...@@ -88,7 +88,7 @@ def getPage(url):
for i in f.readlines(): for i in f.readlines():
page += i page += i
date = f.info().getdate('Last-Modified') date = f.info().getdate('Last-Modified')
if date == None: if date is None:
date = (0, 0, 0) date = (0, 0, 0)
else: else:
date = date[:3] date = date[:3]
...@@ -112,7 +112,7 @@ def getRobotParser(startUrl): ...@@ -112,7 +112,7 @@ def getRobotParser(startUrl):
robotUrl = urlparse.urljoin(startUrl, "/robots.txt") robotUrl = urlparse.urljoin(startUrl, "/robots.txt")
page, date, url = getPage(robotUrl) page, date, url = getPage(robotUrl)
if page == None: if page is None:
print "Could not read ROBOTS.TXT at:", robotUrl print "Could not read ROBOTS.TXT at:", robotUrl
return None return None
# end if # end if
...@@ -205,11 +205,11 @@ def parsePages(startUrl, maxUrls, blockExtensions): ...@@ -205,11 +205,11 @@ def parsePages(startUrl, maxUrls, blockExtensions):
while True: while True:
url = getUrlToProcess(pageMap) url = getUrlToProcess(pageMap)
if url == None: if url is None:
break break
print " ", url print " ", url
page, date, newUrl = getPage(url) page, date, newUrl = getPage(url)
if page == None: if page is None:
del pageMap[url] del pageMap[url]
elif url != newUrl: elif url != newUrl:
print "Redirect -> " + newUrl print "Redirect -> " + newUrl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment