diff --git a/data/tools/scoutDefault.py b/data/tools/scoutDefault.py
index f655a1e1551..fb87597b192 100755
--- a/data/tools/scoutDefault.py
+++ b/data/tools/scoutDefault.py
@@ -36,7 +36,7 @@ AI_SCOUTS_TEXT = "\n\t[ai]%s\n\t[/ai]" % SCOUTS_TEXT.replace('\n','\n\t')
def applySearch(text, RE, groupId):
data = RE.search(text, 0)
- if data != None:
+ if data is not None:
return data.group(groupId)
else:
return ""
@@ -65,7 +65,7 @@ class wikiAi:
self.updated_description = ""
def addAiData(self, aiContent):
- if aiContent != None:
+ if aiContent is not None:
self.start = applySearch(aiContent, AI_START, 'text')
self.scouts = applySearch(aiContent, AI_SCOUTS, 'text')
self.full_description = aiContent
@@ -89,9 +89,9 @@ class wikiSide:
self.scouts_setting = False
def addAiData(self, sideContent):
- if sideContent != None:
+ if sideContent is not None:
aiDetail = ai_block.search(sideContent, 0)
- while aiDetail != None:
+ while aiDetail is not None:
if applySearch(aiDetail.group(), AI_TIME, 'text') == "" and applySearch(aiDetail.group(), AI_TURNS, 'text') == "":
self.ai.append(wikiAi())
self.ai[self.getCurrentAiNumber()].addAiData(aiDetail.group())
@@ -145,7 +145,7 @@ class wikiScenario:
def parseScenario (self, scenarioContent):
self.addScenarioData(scenarioContent)
sideDetail = side_block.search(scenarioContent, 0)
- while sideDetail != None:
+ while sideDetail is not None:
self.addSideData(sideDetail.group())
self.addAiData(sideDetail.group())
searchStart = sideDetail.end()
diff --git a/data/tools/unit_tree/animations.py b/data/tools/unit_tree/animations.py
index 1fcb5c7d104..64ceb7dcdfb 100644
--- a/data/tools/unit_tree/animations.py
+++ b/data/tools/unit_tree/animations.py
@@ -64,7 +64,7 @@ def write_table_row(out, unit, color, name = None):
if abil.get_all(tag = "teleport"):
needed["teleport"] = True
- if name == None: name = unit.id
+ if name is None: name = unit.id
out.write("
%s | " % (color and "c1" or "c2", name))
diff --git a/data/tools/wesnoth/campaignserver_client.py b/data/tools/wesnoth/campaignserver_client.py
index bd444dd6164..219855a4b05 100755
--- a/data/tools/wesnoth/campaignserver_client.py
+++ b/data/tools/wesnoth/campaignserver_client.py
@@ -57,7 +57,7 @@ class CampaignClient:
self.verbose = False
self.quiet = quiet
- if address != None:
+ if address is not None:
self.canceled = False
self.error = False
s = address.split(":")
diff --git a/data/tools/wesnoth/libgithub.py b/data/tools/wesnoth/libgithub.py
index 4942721b958..b7394796127 100644
--- a/data/tools/wesnoth/libgithub.py
+++ b/data/tools/wesnoth/libgithub.py
@@ -519,7 +519,7 @@ class GitHub(object):
return json_parsed
def _github_have_authorization(self):
- return self.authorization != None
+ return self.authorization is not None
def _github_authorization(self):
if self.authorization:
return self.authorization
@@ -541,7 +541,7 @@ class GitHub(object):
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, cwd=cwd)
out = ""
err = ""
- while(p.poll() == None):
+ while(p.poll() is None):
out += p.stdout.read()
err += p.stderr.read()
@@ -615,6 +615,6 @@ def get_build_system(possible_dirs=[]):
Returns: The Addon object of the build-system
"""
global _g
- if _g == None:
+ if _g is None:
_g = _gen(possible_dirs)
return next(_g)
diff --git a/data/tools/wesnoth/wescamp.py b/data/tools/wesnoth/wescamp.py
index 5eb999db4bd..37481473d24 100755
--- a/data/tools/wesnoth/wescamp.py
+++ b/data/tools/wesnoth/wescamp.py
@@ -449,13 +449,13 @@ if __name__ == "__main__":
logging.getLogger().addHandler(handler)
server = "localhost"
- if(args.server != None):
+ if(args.server is not None):
server = args.server
- if args.port != None:
+ if args.port is not None:
server += ":" + args.port
campaignd_configured = True
- elif args.branch != None:
+ elif args.branch is not None:
for port, version in libwml.CampaignClient.portmap:
if version.startswith(args.branch):
server += ":" + port
@@ -464,7 +464,7 @@ if __name__ == "__main__":
target = None
tmp = tempdir()
- if(args.temp_dir != None):
+ if(args.temp_dir is not None):
if(args.upload_all):
logging.error("TEMP-DIR not allowed for UPLOAD-ALL.")
sys.exit(2)
@@ -520,10 +520,10 @@ if __name__ == "__main__":
print(k)
# Upload an addon to wescamp.
- elif(args.upload != None):
+ elif(args.upload is not None):
assert_campaignd(campaignd_configured)
assert_wescamp(wescamp_configured)
- if(wescamp == None):
+ if(wescamp is None):
logging.error("No wescamp checkout specified")
sys.exit(2)
@@ -546,7 +546,7 @@ if __name__ == "__main__":
elif(args.upload_all):
assert_campaignd(campaignd_configured)
assert_wescamp(wescamp_configured)
- if(wescamp == None):
+ if(wescamp is None):
logging.error("No wescamp checkout specified.")
sys.exit(2)
@@ -581,7 +581,7 @@ if __name__ == "__main__":
elif(args.checkout or args.checkout_readonly):
assert_wescamp(wescamp_configured)
- if(wescamp == None):
+ if(wescamp is None):
logging.error("No wescamp checkout specified.")
sys.exit(2)
diff --git a/data/tools/wesnoth/wmldata.py b/data/tools/wesnoth/wmldata.py
index af42deaf83f..b42f26cbdf6 100755
--- a/data/tools/wesnoth/wmldata.py
+++ b/data/tools/wesnoth/wmldata.py
@@ -275,7 +275,7 @@ class DataSub(Data):
bytes = ""
for r in result:
- if r != None:
+ if r is not None:
# For networking, we need actual bytestream here, not unicode.
if type(r) is unicode: r = r.encode("utf8")
bytes += str(r)
@@ -577,11 +577,11 @@ class DataSub(Data):
"""For the even lazier, looks for a value inside a difficulty ifdef.
"""
v = self.get_text_val(tag)
- if v != None: return v
+ if v is not None: return v
for ifdef in self.get_ifdefs(["EASY", "NORMAL", "HARD"][difficulty]):
v = ifdef.get_text_val(tag)
- if v != None: return v
+ if v is not None: return v
return default
diff --git a/data/tools/wesnoth/wmlparser.py b/data/tools/wesnoth/wmlparser.py
index c9684dccda5..a6554e4f48e 100755
--- a/data/tools/wesnoth/wmlparser.py
+++ b/data/tools/wesnoth/wmlparser.py
@@ -378,12 +378,12 @@ class Parser:
elif macro[0] == ".":
dirpath = self.current_path + macro[1:]
# Otherwise, try to interpret the macro as a filename in the data dir.
- elif self.data_dir != None:
+ elif self.data_dir is not None:
dirpath = self.data_dir + "/" + macro
else:
dirpath = None
- if dirpath != None and os.path.exists(dirpath):
+ if dirpath is not None and os.path.exists(dirpath):
dirpath = os.path.normpath(dirpath)
if self.only_expand_pathes:
if not [x for x in self.only_expand_pathes if os.path.commonprefix([dirpath, x]) == x]:
@@ -675,7 +675,7 @@ class Parser:
self.read_while(" ")
text = self.read_lines_until("#enddef")
- if text == None:
+ if text is None:
raise Error(self, "#define without #enddef")
self.macros[params[0]] = self.Macro(
diff --git a/data/tools/wesnoth/wmlparser3.py b/data/tools/wesnoth/wmlparser3.py
index bdcab903514..752e4787d43 100755
--- a/data/tools/wesnoth/wmlparser3.py
+++ b/data/tools/wesnoth/wmlparser3.py
@@ -309,7 +309,7 @@ class Parser:
if data_dir: self.data_dir = os.path.abspath(data_dir)
self.keep_temp_dir = None
self.temp_dir = None
- self.no_preprocess = (wesnoth_exe == None)
+ self.no_preprocess = (wesnoth_exe is None)
self.preprocessed = None
self.verbose = False
diff --git a/utils/gdb/register_wesnoth_pretty_printers.py b/utils/gdb/register_wesnoth_pretty_printers.py
index 9b970b195d1..d3e39ee7081 100644
--- a/utils/gdb/register_wesnoth_pretty_printers.py
+++ b/utils/gdb/register_wesnoth_pretty_printers.py
@@ -43,7 +43,7 @@ def create_wesnoth_lookup_function(pretty_printers_dict):
# Get the type name.
typename = type.tag
- if typename == None:
+ if typename is None:
return None
# Iterate over local dictionary of types to determine
diff --git a/utils/simulate_lobby_traffic.py b/utils/simulate_lobby_traffic.py
index d5cecd477ac..782c952322f 100644
--- a/utils/simulate_lobby_traffic.py
+++ b/utils/simulate_lobby_traffic.py
@@ -50,7 +50,7 @@ while len(clients) > 0 and time.monotonic() < waiting_start_time + EXIT_WAIT_TIM
time.sleep(1.0)
clients_copy = list(clients)
for c in clients_copy:
- if c.poll() != None:
+ if c.poll() is not None:
# The process has terminated, remove it from the set.
clients.remove(c)
diff --git a/utils/wiki_grabber.py b/utils/wiki_grabber.py
index 39d3afb40a1..9a64e4dabc0 100755
--- a/utils/wiki_grabber.py
+++ b/utils/wiki_grabber.py
@@ -121,7 +121,7 @@ if __name__ == "__main__":
res = re.compile("^" + key + " *= *(.*)$", re.M).search(data)
- if res != None:
+ if res is not None:
res = res.group(1)
return res
@@ -131,7 +131,7 @@ if __name__ == "__main__":
page = get_value(data, "@page")
order = get_value(data, "@order")
- if order == None:
+ if order is None:
order = 10000
return [page, order]