SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
PEP 8 – Comparison to 'None' Part 3
Gormogon8b77cd230d4b
diff --git a/ext/pyPdf/xmp.py b/ext/pyPdf/xmp.pyindex b070df90..d22837d3 100644--- a/ext/pyPdf/xmp.py+++ b/ext/pyPdf/xmp.py@@ -66,7 +66,7 @@ class XmpInformation(PdfObject):for desc in self.rdfRoot.getElementsByTagNameNS(RDF_NAMESPACE, "Description"):if desc.getAttributeNS(RDF_NAMESPACE, "about") == aboutUri:attr = desc.getAttributeNodeNS(namespace, name)- if attr != None:+ if attr is not None:yield attrfor element in desc.getElementsByTagNameNS(namespace, name):yield element@@ -187,7 +187,7 @@ class XmpInformation(PdfObject):else:value = self._getText(element)break- if value != None:+ if value is not None:value = converter(value)ns_cache = self.cache.setdefault(namespace, {})ns_cache[name] = valuediff --git a/ext/socks.py b/ext/socks.pyindex d68b2ad1..b91be10f 100644--- a/ext/socks.py+++ b/ext/socks.py@@ -114,7 +114,7 @@ def wrapmodule(module):This will only work on modules that import socket directly into the namespace;most of the Python Standard Library falls into this category."""- if _defaultproxy != None:+ if _defaultproxy is not None:module.socket.socket = socksocketelse:raise GeneralProxyError((4, "no proxy specified"))@@ -128,7 +128,7 @@ class socksocket(socket.socket):def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):_orgsocket.__init__(self, family, type, proto, _sock)- if _defaultproxy != None:+ if _defaultproxy is not None:self.__proxy = _defaultproxyelse:self.__proxy = (None, None, None, None, None, None)@@ -171,7 +171,7 @@ class socksocket(socket.socket):Negotiates a connection through a SOCKS5 server."""# First we'll send the authentication packages we support.- if (self.__proxy[4]!=None) and (self.__proxy[5]!=None):+ if (self.__proxy[4] is not None) and (self.__proxy[5] is not None):# The username/password details were supplied to the# setproxy method so we support the USERNAME/PASSWORD# authentication (in addition to the standard none).@@ -253,7 +253,7 @@ class socksocket(socket.socket):raise GeneralProxyError((1,_generalerrors[1]))boundport = struct.unpack(">H", self.__recvall(2))[0]self.__proxysockname = (boundaddr, boundport)- if ipaddr != None:+ if ipaddr is not None:self.__proxypeername = (socket.inet_ntoa(ipaddr), destport)else:self.__proxypeername = (destaddr, destport)@@ -295,7 +295,7 @@ class socksocket(socket.socket):# Construct the request packetreq = struct.pack(">BBH", 0x04, 0x01, destport) + ipaddr# The username parameter is considered userid for SOCKS4- if self.__proxy[4] != None:+ if self.__proxy[4] is not None:req = req + self.__proxy[4]req += chr(0x00).encode()# DNS name if remote resolving is required@@ -320,7 +320,7 @@ class socksocket(socket.socket):raise Socks4Error((94, _socks4errors[4]))# Get the bound address/portself.__proxysockname = (socket.inet_ntoa(resp[4:]), struct.unpack(">H", resp[2:4])[0])- if rmtrslv != None:+ if rmtrslv is not None:self.__proxypeername = (socket.inet_ntoa(ipaddr), destport)else:self.__proxypeername = (destaddr, destport)@@ -367,27 +367,27 @@ class socksocket(socket.socket):if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int):raise GeneralProxyError((5, _generalerrors[5]))if self.__proxy[0] == PROXY_TYPE_SOCKS5:- if self.__proxy[2] != None:+ if self.__proxy[2] is not None:portnum = self.__proxy[2]else:portnum = 1080_orgsocket.connect(self, (self.__proxy[1], portnum))self.__negotiatesocks5(destpair[0], destpair[1])elif self.__proxy[0] == PROXY_TYPE_SOCKS4:- if self.__proxy[2] != None:+ if self.__proxy[2] is not None:portnum = self.__proxy[2]else:portnum = 1080_orgsocket.connect(self,(self.__proxy[1], portnum))self.__negotiatesocks4(destpair[0], destpair[1])elif self.__proxy[0] == PROXY_TYPE_HTTP:- if self.__proxy[2] != None:+ if self.__proxy[2] is not None:portnum = self.__proxy[2]else:portnum = 8080_orgsocket.connect(self,(self.__proxy[1], portnum))self.__negotiatehttp(destpair[0], destpair[1])- elif self.__proxy[0] == None:+ elif self.__proxy[0] is None:_orgsocket.connect(self, (destpair[0], destpair[1]))else:raise GeneralProxyError((4, _generalerrors[4]))diff --git a/modules/sfp_virustotal.py b/modules/sfp_virustotal.pyindex f29b3668..f8e843a0 100644--- a/modules/sfp_virustotal.py+++ b/modules/sfp_virustotal.py@@ -85,7 +85,7 @@ class sfp_virustotal(SpiderFootPlugin):if self.opts['publicapi']:time.sleep(15)- if res['content'] == None:+ if res['content'] is None:self.sf.info("No VirusTotal info found for " + qry)return None@@ -149,7 +149,7 @@ class sfp_virustotal(SpiderFootPlugin):return Noneinfo = self.query(addr)- if info == None:+ if info is None:continueif info.has_key('detected_urls'):self.sf.info("Found VirusTotal URL data for " + addr)diff --git a/modules/sfp_websvr.py b/modules/sfp_websvr.pyindex dca5ea3a..cfcb5c20 100644--- a/modules/sfp_websvr.py+++ b/modules/sfp_websvr.py@@ -87,13 +87,13 @@ class sfp_websvr(SpiderFootPlugin):if eventData.has_key('x-aspnet-version'):tech = "ASP.NET"- if tech != None and '.jsp' in eventSource:+ if tech is not None and '.jsp' in eventSource:tech = "Java/JSP"- if tech != None and '.php' in eventSource:+ if tech is not None and '.php' in eventSource:tech = "PHP"- if tech != None:+ if tech is not None:evt = SpiderFootEvent("WEBSERVER_TECHNOLOGY", tech, self.__name__, parentEvent)self.notifyListeners(evt)diff --git a/modules/sfp_whois.py b/modules/sfp_whois.pyindex 4d1ef848..94a2f559 100644--- a/modules/sfp_whois.py+++ b/modules/sfp_whois.py@@ -75,7 +75,7 @@ class sfp_whois(SpiderFootPlugin):self.notifyListeners(evt)info = pythonwhois.parse.parse_raw_whois(data, True)- if eventName == "DOMAIN_NAME" and info['registrar'] != None:+ if eventName == "DOMAIN_NAME" and info['registrar'] is not None:evt = SpiderFootEvent("DOMAIN_REGISTRAR", info['registrar'][0],self.__name__, event)self.notifyListeners(evt)diff --git a/modules/sfp_yahoosearch.py b/modules/sfp_yahoosearch.pyindex cea45690..df97fa19 100644--- a/modules/sfp_yahoosearch.py+++ b/modules/sfp_yahoosearch.py@@ -67,7 +67,7 @@ class sfp_yahoosearch(SpiderFootPlugin):# Sites hosted on the domainpages = self.sf.yahooIterate("site:" + eventData, dict(limit=self.opts['pages'],useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))- if pages == None:+ if pages is None:self.sf.info("No results returned from Yahoo.")return Nonediff --git a/sfscan.py b/sfscan.pyindex bbe3d8c2..1a2e9865 100644--- a/sfscan.py+++ b/sfscan.py@@ -52,7 +52,7 @@ class SpiderFootScanner(threading.Thread):# Set the status of the currently running scan (if any)def setStatus(self, status, started=None, ended=None):- if self.ts == None:+ if self.ts is None:print "Internal Error: Status set attempted before " + \"SpiderFootScanner was ready."exit(-1)@@ -154,7 +154,7 @@ class SpiderFootScanner(threading.Thread):tlddata = self.ts.sf.cacheGet("internet_tlds",self.ts.config['_internettlds_cache'])# If it wasn't loadable from cache, load it from scratch- if tlddata == None:+ if tlddata is None:self.ts.config['_internettlds'] = self.ts.sf.optValueToData(self.ts.config['_internettlds'])self.ts.sf.cachePut("internet_tlds", self.ts.config['_internettlds'])@@ -184,7 +184,7 @@ class SpiderFootScanner(threading.Thread):# Give modules a chance to 'enrich' the original target with# aliases of that target.newTarget = mod.enrichTarget(target)- if newTarget != None:+ if newTarget is not None:target = newTargetself.ts.moduleInstances[modName] = mod@@ -207,7 +207,7 @@ class SpiderFootScanner(threading.Thread):# Note the absence of a check for whether a module can register# to itself. That is intentional because some modules will# act on their own notifications (e.g. sfp_dns)!- if listenerModule.watchedEvents() != None:+ if listenerModule.watchedEvents() is not None:module.registerListener(listenerModule)# Now we are ready to roll..@@ -219,7 +219,7 @@ class SpiderFootScanner(threading.Thread):psMod.setTarget(target)psMod.clearListeners()for mod in self.ts.moduleInstances.values():- if mod.watchedEvents() != None:+ if mod.watchedEvents() is not None:psMod.registerListener(mod)# Create the "ROOT" event which un-triggered modules will link events todiff --git a/sfwebui.py b/sfwebui.pyindex fc2f9eb1..b00d5500 100644--- a/sfwebui.py+++ b/sfwebui.py@@ -192,7 +192,7 @@ class SpiderFootWebUi:def scaninfo(self, id):dbh = SpiderFootDb(self.config)res = dbh.scanInstanceGet(id)- if res == None:+ if res is None:return self.error("Scan ID not found.")templ = Template(filename='dyn/scaninfo.tmpl', lookup=self.lookup)@@ -216,10 +216,10 @@ class SpiderFootWebUi:def scandelete(self, id, confirm=None):dbh = SpiderFootDb(self.config)res = dbh.scanInstanceGet(id)- if res == None:+ if res is None:return self.error("Scan ID not found.")- if confirm != None:+ if confirm is not None:dbh.scanInstanceDelete(id)raise cherrypy.HTTPRedirect("/")else:@@ -316,7 +316,7 @@ class SpiderFootWebUi:targetType = regexToType[rx]break- if targetType == None:+ if targetType is None:return self.error("Invalid target type. Could not recognize it as " + \"an IP address, IP subnet, domain name or host name.")@@ -327,7 +327,7 @@ class SpiderFootWebUi:t.start()# Wait until the scan has initialized- while globalScanStatus.getStatus(scanId) == None:+ while globalScanStatus.getStatus(scanId) is None:print "[info] Waiting for the scan to initialize..."time.sleep(1)@@ -341,7 +341,7 @@ class SpiderFootWebUi:def stopscan(self, id):global globalScanStatus- if globalScanStatus.getStatus(id) == None:+ if globalScanStatus.getStatus(id) is None:return self.error("That scan is not actually running. A data consistency " + \"error for this scan probably exists. <a href='/scandelete?id=" + \id + "&confirm=1'>Click here to delete it.</a>")