python: avoid equality check for None

PEP8 says that:
"Comparisons to singletons like None should always be done with is or
is not, never the equality operators."

glib uses a mix of "== None" and "is None". This patch changes all
cases to the latter.
This commit is contained in:
Thomas Hindoe Paaboel Andersen 2018-07-12 23:40:50 +02:00
parent c557c6de81
commit a8b416f9fe
7 changed files with 21 additions and 21 deletions

View File

@ -1068,7 +1068,7 @@ class CodeGenerator:
'\n')
def generate_annotations(self, prefix, annotations):
if annotations == None:
if annotations is None:
return
n = 0

View File

@ -63,38 +63,38 @@ def apply_annotation(iface_list, iface, method, signal, prop, arg, key, value):
iface_obj = i
break
if iface_obj == None:
if iface_obj is None:
print_error('No interface "{}"'.format(iface))
target_obj = None
if method:
method_obj = find_method(iface_obj, method)
if method_obj == None:
if method_obj is None:
print_error('No method "{}" on interface "{}"'.format(method, iface))
if arg:
arg_obj = find_arg(method_obj.in_args, arg)
if (arg_obj == None):
if (arg_obj is None):
arg_obj = find_arg(method_obj.out_args, arg)
if (arg_obj == None):
if (arg_obj is None):
print_error('No arg "{}" on method "{}" on interface "{}"'.format(arg, method, iface))
target_obj = arg_obj
else:
target_obj = method_obj
elif signal:
signal_obj = find_signal(iface_obj, signal)
if signal_obj == None:
if signal_obj is None:
print_error('No signal "{}" on interface "{}"'.format(signal, iface))
if arg:
arg_obj = find_arg(signal_obj.args, arg)
if (arg_obj == None):
if (arg_obj is None):
print_error('No arg "{}" on signal "{}" on interface "{}"'.format(arg, signal, iface))
target_obj = arg_obj
else:
target_obj = signal_obj
elif prop:
prop_obj = find_prop(iface_obj, prop)
if prop_obj == None:
if prop_obj is None:
print_error('No property "{}" on interface "{}"'.format(prop, iface))
target_obj = prop_obj
else:

View File

@ -61,7 +61,7 @@ class Arg:
if len(self.since) == 0:
self.since = utils.lookup_since(self.annotations)
if self.name == None:
if self.name is None:
self.name = 'unnamed_arg%d'%arg_number
# default to GVariant
self.ctype_in_g = 'GVariant *'

View File

@ -116,21 +116,21 @@ def lookup_annotation(annotations, key):
def lookup_docs(annotations):
s = lookup_annotation(annotations, 'org.gtk.GDBus.DocString')
if s == None:
if s is None:
return ''
else:
return s
def lookup_since(annotations):
s = lookup_annotation(annotations, 'org.gtk.GDBus.Since')
if s == None:
if s is None:
return ''
else:
return s
def lookup_brief_docs(annotations):
s = lookup_annotation(annotations, 'org.gtk.GDBus.DocString.Short')
if s == None:
if s is None:
return ''
else:
return s

View File

@ -9,7 +9,7 @@ def read_global_var (symname):
return gdb.selected_frame().read_var(symname)
def g_quark_to_string (quark):
if quark == None:
if quark is None:
return None
quark = long(quark)
if quark == 0:
@ -171,7 +171,7 @@ def pretty_printer_lookup (val):
return None
def register (obj):
if obj == None:
if obj is None:
obj = gdb
obj.pretty_printers.append(pretty_printer_lookup)

View File

@ -104,7 +104,7 @@ class Mapping:
return [self]
def serialise(self, serialiser):
if self.serialised == None:
if self.serialised is None:
self.serialised = serialiser.add_mapping(self.mapping)
return self.serialised
@ -193,7 +193,7 @@ class Chain:
return [self]
def serialise(self, serialiser):
if self.serialised == None:
if self.serialised is None:
# Before we serialise, see if we can optimise a bit
self.chain = sum((item.get_flattened() for item in self.chain), [])

View File

@ -26,7 +26,7 @@ def g_type_to_typenode (gtype):
if typenode == 0:
return None
val = read_global_var ("static_fundamental_type_nodes")
if val == None:
if val is None:
return None
return val[typenode >> 2].address
@ -132,7 +132,7 @@ def pretty_printer_lookup (val):
return None
def get_signal_name (id):
if id == None:
if id is None:
return None
id = long(id)
if id == 0:
@ -163,7 +163,7 @@ class SignalFrame(FrameDecorator):
def read_var (self, frame, name, array = None):
try:
v = frame_var (frame, name)
if v == None or v.is_optimized_out:
if v is None or v.is_optimized_out:
return None
if array != None:
array.append (v)
@ -174,7 +174,7 @@ class SignalFrame(FrameDecorator):
def read_object (self, frame, name, array = None):
try:
v = frame_var (frame, name)
if v == None or v.is_optimized_out:
if v is None or v.is_optimized_out:
return None
v = v.cast (gdb.lookup_type("GObject").pointer())
# Ensure this is a somewhat correct object pointer
@ -323,7 +323,7 @@ class GFrameFilter(object):
return GFrameDecorator(iterator)
def register (obj):
if obj == None:
if obj is None:
obj = gdb
if HAVE_GDB_FRAMEDECORATOR: