Code optimizations wrt handling of None - bug 2212

svn: r10811
This commit is contained in:
Gerald Britton
2008-06-16 15:01:46 +00:00
parent 47095b4e98
commit 4982292774
124 changed files with 379 additions and 377 deletions

View File

@@ -141,7 +141,7 @@ class ChildEmbedList(EmbeddedList):
def _find_row(self, x, y):
row = self.tree.get_path_at_pos(x, y)
if row == None:
if row is None:
return len(self.family.get_child_ref_list())
else:
return row[0][0]
@@ -415,8 +415,8 @@ class EditFamily(EditPrimary):
# look for the scenerio of a child and no parents on a new
# family
if self.added and self.obj.get_father_handle() == None and \
self.obj.get_mother_handle() == None and \
if self.added and self.obj.get_father_handle() is None and \
self.obj.get_mother_handle() is None and \
len(self.obj.get_child_ref_list()) == 1:
self.add_parent = True
if not Config.get(Config.FAMILY_WARN):
@@ -450,7 +450,7 @@ class EditFamily(EditPrimary):
# Add a signal pick up changes to events, bug #1329
self._add_db_signal('event-update', self.event_updated)
self.added = self.obj.handle == None
self.added = self.obj.handle is None
if self.added:
self.obj.handle = Utils.create_id()
@@ -802,7 +802,7 @@ class EditFamily(EditPrimary):
def load_parent(self, handle, box, birth_obj, birth_label, death_obj,
death_label, btn_obj, btn2_obj, add_msg, del_msg):
is_used = handle != None
is_used = handle is not None
for i in box.get_children():
box.remove(i)
@@ -872,8 +872,8 @@ class EditFamily(EditPrimary):
self.db.commit_person(person, trans)
def object_is_empty(self):
return self.obj.get_father_handle() == None and \
self.obj.get_mother_handle() == None and \
return self.obj.get_father_handle() is None and \
self.obj.get_mother_handle() is None and \
len(self.obj.get_child_ref_list()) == 0
def save(self, *obj):

View File

@@ -124,13 +124,13 @@ class EditMediaRef(EditReference):
coord = self.source_ref.get_rectangle()
#upgrade path: set invalid (from eg old db) to none
if coord is not None and ((coord[0] == None and coord[1] == None
and coord[2] == None and coord[3] == None) or (
coord[0] == 0 and coord[1] == 0
and coord[2] == 100 and coord[3] == 100) or (
coord[0] == coord[2] and coord[1] == coord[3]
)):
if coord is not None and (
(coord[0] is coord[1] is coord[2] is coord[3] is None) or \
(coord[0] == coord[1] == 0 and coord[2] == coord[3] == 100) or \
(coord[0] == coord[2] and coord[1] == coord[3])
):
coord = None
self.rectangle = coord
self.subpixmap = self.top.get_widget("subpixmap")
@@ -474,13 +474,13 @@ class EditMediaRef(EditReference):
self.top.get_widget("corner2_y").get_value_as_int(),
)
#do not set unset or invalid coord
if (coord[0] == None and coord[1] == None
and coord[2] == None and coord[3] == None) or (
coord[0] == 0 and coord[1] == 0
and coord[2] == 100 and coord[3] == 100) or (
coord[0] == coord[2] and coord[1] == coord[3]
):
if coord is not None and (
(coord[0] is coord[1] is coord[2] is coord[3] is None) or \
(coord[0] == coord[1] == 0 and coord[2] == coord[3] == 100) or \
(coord[0] == coord[2] and coord[1] == coord[3])
):
coord = None
self.source_ref.set_rectangle(coord)
#call callback if given

View File

@@ -571,7 +571,7 @@ class EditPerson(EditPrimary):
"""
self.load_obj = path
self.load_rect = rectangle
if path == None:
if path is None:
self.obj_photo.hide()
else:
try:
@@ -579,7 +579,7 @@ class EditPerson(EditPrimary):
width = i.get_width()
height = i.get_height()
if rectangle != None:
if rectangle is not None:
upper_x = min(rectangle[0], rectangle[2])/100.
lower_x = max(rectangle[0], rectangle[2])/100.
upper_y = min(rectangle[1], rectangle[3])/100.
@@ -633,7 +633,7 @@ class EditPerson(EditPrimary):
for tmp_handle in self.obj.get_family_handle_list():
temp_family = self.db.get_family_from_handle(tmp_handle)
if self.obj == temp_family.get_mother_handle():
if temp_family.get_father_handle() != None:
if temp_family.get_father_handle() is not None:
error = True
else:
temp_family.set_mother_handle(None)
@@ -642,7 +642,7 @@ class EditPerson(EditPrimary):
for tmp_handle in self.obj.get_family_handle_list():
temp_family = self.db.get_family_from_handle(tmp_handle)
if self.obj == temp_family.get_father_handle():
if temp_family.get_mother_handle() != None:
if temp_family.get_mother_handle() is not None:
error = True
else:
temp_family.set_father_handle(None)
@@ -651,13 +651,13 @@ class EditPerson(EditPrimary):
for tmp_handle in self.obj.get_family_handle_list():
temp_family = self.db.get_family_from_handle(tmp_handle)
if self.obj == temp_family.get_father_handle():
if temp_family.get_mother_handle() != None:
if temp_family.get_mother_handle() is not None:
error = True
else:
temp_family.set_father_handle(None)
temp_family.set_mother_handle(self.obj)
if self.obj == temp_family.get_mother_handle():
if temp_family.get_father_handle() != None:
if temp_family.get_father_handle() is not None:
error = True
else:
temp_family.set_mother_handle(None)