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 StandardCustomSelector:
self.selector.set_text_column(1)
else:
self.selector = gtk.ComboBoxEntry(self.store, 1)
if self.active_key != None:
if self.active_key is not None:
self.selector.set_active(self.active_index)
# make autocompletion work
@ -222,7 +222,7 @@ class StandardCustomSelector:
key, text = val
if key in self.mapping.keys() and key != self.custom_key:
self.store.foreach(self.set_int_value, key)
elif self.custom_key != None:
elif self.custom_key is not None:
self.selector.child.set_text(text)
else:
print "StandardCustomSelector.set(): Option not available:", val

View File

@ -347,17 +347,17 @@ class FontStyle:
in the range of 0-255 represeting the red, green, and blue
components of a color.
"""
if face != None:
if face is not None:
self.set_type_face(face)
if size != None:
if size is not None:
self.set_size(size)
if italic != None:
if italic is not None:
self.set_italic(italic)
if bold != None:
if bold is not None:
self.set_bold(bold)
if underline != None:
if underline is not None:
self.set_underline(underline)
if color != None:
if color is not None:
self.set_color(color)
def set_italic(self, val):
@ -671,31 +671,31 @@ class ParagraphStyle:
@param bgcolor: background color of the paragraph as an RGB tuple.
@param font: FontStyle instance that defines the font
"""
if font != None:
if font is not None:
self.font = FontStyle(font)
if pad != None:
if pad is not None:
self.set_padding(pad)
if tborder != None:
if tborder is not None:
self.set_top_border(tborder)
if bborder != None:
if bborder is not None:
self.set_bottom_border(bborder)
if rborder != None:
if rborder is not None:
self.set_right_border(rborder)
if lborder != None:
if lborder is not None:
self.set_left_border(lborder)
if bgcolor != None:
if bgcolor is not None:
self.set_background_color(bgcolor)
if align != None:
if align is not None:
self.set_alignment(align)
if rmargin != None:
if rmargin is not None:
self.set_right_margin(rmargin)
if lmargin != None:
if lmargin is not None:
self.set_left_margin(lmargin)
if first_indent != None:
if first_indent is not None:
self.set_first_indent(first_indent)
if tmargin != None:
if tmargin is not None:
self.set_top_margin(tmargin)
if bmargin != None:
if bmargin is not None:
self.set_bottom_margin(bmargin)
def set_header_level(self, level):
@ -1028,7 +1028,7 @@ class StyleSheet:
self.table_styles = {}
self.cell_styles = {}
self.name = ""
if obj != None:
if obj is not None:
for style_name in obj.para_styles.keys():
style = obj.para_styles[style_name]
self.para_styles[style_name] = ParagraphStyle(style)

View File

@ -166,7 +166,7 @@ class NameDisplay:
for (num, name,fmt_str,act) in formats:
func = self._format_fn(fmt_str)
func_raw = raw_func_dict.get(num)
if func_raw == None:
if func_raw is None:
func_raw = self._format_raw_fn(fmt_str)
self.name_formats[num] = (name,fmt_str,act,func,func_raw)
@ -427,7 +427,7 @@ def fn(%s):
method call and we need all the speed we can squeeze out of this.
"""
func = self.__class__.raw_format_funcs.get(format_str)
if func == None:
if func is None:
func = self._gen_raw_func(format_str)
self.__class__.raw_format_funcs[format_str] = func
@ -455,7 +455,7 @@ def fn(%s):
All the other characters in the fmt_str are unaffected.
"""
func = self.__class__.format_funcs.get(format_str)
if func == None:
if func is None:
func = self._gen_cooked_func(format_str)
self.__class__.format_funcs[format_str] = func
try:
@ -555,7 +555,7 @@ def fn(%s):
@returns: Returns the L{Name} string representation
@rtype: str
"""
if name == None:
if name is None:
return ""
num = self._is_format_valid(name.display_as)

View File

@ -101,20 +101,20 @@ def get(key):
val = get_string(token)
except:
val = default_value[key]
if val == None:
if val is None:
val = default_value[key]
return val
def get_bool(key):
val = client.get(key)
if val == None:
if val is None:
return None
val = client.get_bool(key)
if val in (True, False):
return val
else:
val = client.get_default_from_schema(key)
if val == None:
if val is None:
raise Errors.GConfSchemaError("No default value for key "+key)
return val.get_bool()
@ -124,14 +124,14 @@ def set_bool(key, val):
def get_int(key, correct_tuple=None):
val = client.get(key)
if val == None:
if val is None:
return None
val = client.get_int(key)
if not correct_tuple or val in correct_tuple:
return val
else:
val = client.get_default_from_schema(key)
if val == None:
if val is None:
raise Errors.GConfSchemaError("No default value for key "+key)
return val.get_int()
@ -141,14 +141,14 @@ def set_int(key, val, correct_tuple=None):
def get_string(key, test_func=None):
val = client.get(key)
if val == None:
if val is None:
return None
val = client.get_string(key)
if not test_func or test_func(val):
return val
else:
val = client.get_default_from_schema(key)
if val == None:
if val is None:
raise Errors.GConfSchemaError("No default value for key "+key)
return val.get_string()
@ -162,7 +162,7 @@ def sync():
def get_default(key, sample=''):
token = "/apps/gramps/%s/%s" % (key[0], key[1])
value = client.get_default_from_schema(token)
if value == None:
if value is None:
raise Errors.GConfSchemaError("No default value for key "+key[1])
if isinstance(sample, basestring):
return value.get_string()

View File

@ -209,7 +209,7 @@ def get(key):
val = get_int(key)
else:
val = get_string(key)
if val == None or val == "":
if val is None or val == "":
val = default_value[key]
return val

View File

@ -136,7 +136,7 @@ def make_requested_gramplet(viewpage, name, opts, dbstate, uistate):
msg = None
if gui.pui:
msg = gui.pui.tooltip
if msg == None:
if msg is None:
msg = _("Drag Properties Button to move and click it for setup")
if msg:
gui.tooltips = gtk.Tooltips()
@ -415,7 +415,7 @@ class Gramplet(object):
if iter.has_tag(tag):
if link_type == 'Person':
person = self.dbstate.db.get_person_from_handle(handle)
if person != None:
if person is not None:
if event.button == 1: # left mouse
if event.type == gtk.gdk._2BUTTON_PRESS: # double
try:
@ -726,7 +726,7 @@ class MyScrolledWindow(gtk.ScrolledWindow):
# Hack to get around show_all that shows hidden items
# do once, the first time showing
if self.viewpage:
gramplets = [g for g in self.viewpage.gramplet_map.values() if g != None]
gramplets = [g for g in self.viewpage.gramplet_map.values() if g is not None]
self.viewpage = None
for gramplet in gramplets:
gramplet.gvoptions.hide()
@ -820,7 +820,7 @@ class GrampletView(PageView.PersonNavView):
"""
Detach all of the mainframe gramplets from the columns.
"""
gramplets = [g for g in self.gramplet_map.values() if g != None]
gramplets = [g for g in self.gramplet_map.values() if g is not None]
for gramplet in gramplets:
if (gramplet.state == "windowed" or gramplet.state == "closed"):
continue
@ -832,7 +832,7 @@ class GrampletView(PageView.PersonNavView):
"""
Place the gramplet mainframes in the columns.
"""
gramplets = [g for g in self.gramplet_map.values() if g != None]
gramplets = [g for g in self.gramplet_map.values() if g is not None]
# put the gramplets where they go:
# sort by row
gramplets.sort(lambda a, b: cmp(a.row, b.row))
@ -913,7 +913,7 @@ class GrampletView(PageView.PersonNavView):
for gframe in self.columns[col]:
gramplet = self.frame_map[str(gframe)]
opts = get_gramplet_options_by_name(gramplet.name)
if opts != None:
if opts is not None:
base_opts = opts.copy()
for key in base_opts:
if key in gramplet.__dict__:
@ -940,7 +940,7 @@ class GrampletView(PageView.PersonNavView):
row += 1
for gramplet in self.detached_gramplets:
opts = get_gramplet_options_by_name(gramplet.name)
if opts != None:
if opts is not None:
base_opts = opts.copy()
for key in base_opts:
if key in gramplet.__dict__:
@ -1093,7 +1093,7 @@ class GrampletView(PageView.PersonNavView):
if gramplet.title == name:
#gramplet.state = "maximized"
self.closed_gramplets.remove(gramplet)
if self._popup_xy != None:
if self._popup_xy is not None:
self.drop_widget(self.widget, gramplet,
self._popup_xy[0], self._popup_xy[1], 0)
else:
@ -1122,7 +1122,7 @@ class GrampletView(PageView.PersonNavView):
# set height on gramplet.scrolledwindow here:
gramplet.scrolledwindow.set_size_request(-1, gramplet.height)
## now drop it in right place
if self._popup_xy != None:
if self._popup_xy is not None:
self.drop_widget(self.widget, gramplet,
self._popup_xy[0], self._popup_xy[1], 0)
else:
@ -1132,7 +1132,7 @@ class GrampletView(PageView.PersonNavView):
tname = obj.get_child().get_label()
all_opts = get_gramplet_options_by_tname(tname)
name = all_opts["name"]
if all_opts == None:
if all_opts is None:
print "Unknown gramplet type: '%s'; bad gramplets.ini file?" % name
return
if "title" not in all_opts:
@ -1159,7 +1159,7 @@ class GrampletView(PageView.PersonNavView):
# set height on gramplet.scrolledwindow here:
gramplet.scrolledwindow.set_size_request(-1, gramplet.height)
## now drop it in right place
if self._popup_xy != None:
if self._popup_xy is not None:
self.drop_widget(self.widget, gramplet,
self._popup_xy[0], self._popup_xy[1], 0)
else:
@ -1223,7 +1223,7 @@ class GrampletView(PageView.PersonNavView):
ag_menu = self.uistate.uimanager.get_widget('/Popup/AddGramplet')
if ag_menu:
qr_menu = ag_menu.get_submenu()
if qr_menu == None:
if qr_menu is None:
qr_menu = gtk.Menu()
names = [AVAILABLE_GRAMPLETS[key]["tname"] for key
in AVAILABLE_GRAMPLETS.keys()]
@ -1235,7 +1235,7 @@ class GrampletView(PageView.PersonNavView):
rg_menu = self.uistate.uimanager.get_widget('/Popup/RestoreGramplet')
if rg_menu:
qr_menu = rg_menu.get_submenu()
if qr_menu != None:
if qr_menu is not None:
rg_menu.remove_submenu()
names = []
for gramplet in self.closed_gramplets:
@ -1255,7 +1255,7 @@ class GrampletView(PageView.PersonNavView):
return False
def on_delete(self):
gramplets = [g for g in self.gramplet_map.values() if g != None]
gramplets = [g for g in self.gramplet_map.values() if g is not None]
for gramplet in gramplets:
# this is the only place where the gui runs user code directly
if gramplet.pui:

View File

@ -1255,7 +1255,7 @@ class PedigreeView(PageView.PersonNavView):
def find_tree(self,person,index,depth,lst,val=0):
"""Recursively build a list of ancestors"""
if depth > 5 or person == None:
if depth > 5 or person is None:
return
try:
@ -1276,7 +1276,7 @@ class PedigreeView(PageView.PersonNavView):
mrel = True
frel = True
family = self.dbstate.db.get_family_from_handle(family_handle)
if family != None:
if family is not None:
for child_ref in family.get_child_ref_list():
if child_ref.ref == person.handle:
mrel = child_ref.mrel == gen.lib.ChildRefType.BIRTH
@ -1284,11 +1284,11 @@ class PedigreeView(PageView.PersonNavView):
lst[index] = (person,val,family,alive)
father_handle = family.get_father_handle()
if father_handle != None:
if father_handle is not None:
father = self.dbstate.db.get_person_from_handle(father_handle)
self.find_tree(father,(2*index)+1,depth+1,lst,frel)
mother_handle = family.get_mother_handle()
if mother_handle != None:
if mother_handle is not None:
mother = self.dbstate.db.get_person_from_handle(mother_handle)
self.find_tree(mother,(2*index)+2,depth+1,lst,mrel)

View File

@ -527,7 +527,7 @@ class PersonView(PageView.PersonNavView):
active = self.dbstate.active
self.tree.set_model(self.model)
if const.USE_TIPS and self.model.tooltip_column != None:
if const.USE_TIPS and self.model.tooltip_column is not None:
self.tooltips = TreeTips.TreeTips(self.tree,
self.model.tooltip_column,
True)
@ -984,7 +984,7 @@ class PersonView(PageView.PersonNavView):
node = self.model.on_get_iter(path)
# Node might be null if the surname is not known so test against None
while node != None:
while node is not None:
real_iter = self.model.get_iter(path)
for subindex in range(0, self.model.iter_n_children(real_iter)):
subpath = ((path[0], subindex))

View File

@ -662,7 +662,7 @@ class RelationshipView(PageView.PersonNavView):
hbox = gtk.HBox()
label = widgets.MarkupLabel(msg, x_align=1)
# Draw the collapse/expand button:
if family != None:
if family is not None:
if self.check_collapsed(person.handle, family.handle):
arrow = widgets.ExpandCollapseArrow(True,
self.expand_collapse_press,
@ -1189,7 +1189,7 @@ class RelationshipView(PageView.PersonNavView):
def write_family(self, family_handle, person = None):
family = self.dbstate.db.get_family_from_handle(family_handle)
if family == None:
if family is None:
from QuestionDialog import WarningDialog
WarningDialog(
_('Broken family detected'),

View File

@ -112,7 +112,7 @@ class DateDisplay:
]
self.verify_format(format)
if format == None:
if format is None:
self.format = 0
else:
self.format = format
@ -177,7 +177,7 @@ class DateDisplay:
# YYYY-MM-DD (ISO)
year = self._slash_year(date_val[2], date_val[3])
# This produces 1789, 1789-00-11 and 1789-11-00 for incomplete dates.
if date_val[0] == 0 and date_val[1] == 0:
if date_val[0] == date_val[1] == 0:
# No month and no day -> year
value = year
else:
@ -203,7 +203,7 @@ class DateDisplay:
if date_val[3]:
return self.display_iso(date_val)
else:
if date_val[0] == 0 and date_val[1] == 0:
if date_val[0] == date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m', str(date_val[1]))

View File

@ -288,7 +288,7 @@ class DateParser:
Convert the string to an integer if the value is not None. If the
value is None, a zero is returned
"""
if val == None:
if val is None:
return 0
else:
return int(val)
@ -317,18 +317,18 @@ class DateParser:
match = regex1.match(text.lower())
if match:
groups = match.groups()
if groups[0] == None:
if groups[0] is None:
m = 0
else:
m = mmap[groups[0].lower()]
if groups[2] == None:
if groups[2] is None:
y = self._get_int(groups[1])
d = 0
s = False
else:
d = self._get_int(groups[1])
if groups[4] != None: # slash year "/80"
if groups[4] is not None: # slash year "/80"
y = int(groups[3]) + 1 # fullyear + 1
s = True
else: # regular, non-slash date
@ -342,18 +342,18 @@ class DateParser:
match = regex2.match(text.lower())
if match:
groups = match.groups()
if groups[1] == None:
if groups[1] is None:
m = 0
else:
m = mmap[groups[1].lower()]
d = self._get_int(groups[0])
if groups[2] == None:
if groups[2] is None:
y = None
s = False
else:
if groups[4] != None: # slash year digit
if groups[4] is not None: # slash year digit
y = int(groups[3]) + 1 # fullyear + 1
s = True
else:
@ -370,7 +370,7 @@ class DateParser:
"""
Convert only the date portion of a date.
"""
if subparser == None:
if subparser is None:
subparser = self._parse_greg_julian
if subparser == self._parse_greg_julian:
@ -411,7 +411,7 @@ class DateParser:
groups = match.groups()
if self.ymd:
# '1789' and ymd: incomplete date
if groups[1] == None:
if groups[1] is None:
y = self._get_int(groups[4])
m = 0
d = 0

View File

@ -156,7 +156,7 @@ class DateDisplayDE(DateDisplay):
if date_val[3]:
return self.display_iso(date_val)
else:
if date_val[0] == 0 and date_val[1] == 0:
if date_val[0] == date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m', str(date_val[1]))

View File

@ -151,7 +151,7 @@ class DateDisplayFI(DateDisplay):
text = u"%s - %s" % (d1, d2)
elif mod == Date.MOD_RANGE:
stop = date.get_stop_date()
if start[0] == 0 and start[1] == 0 and stop[0] == 0 and stop[1] == 0:
if start[0] == start[1] == 0 and stop[0] == 0 and stop[1] == 0:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](stop)
text = u"vuosien %s ja %s välillä" % (d1, d2)

View File

@ -216,7 +216,7 @@ class DateDisplayFR(DateDisplay):
if date_val[2] < 0 or date_val[3]:
return self.display_iso(date_val)
else:
if date_val[0] == 0 and date_val[1] == 0:
if date_val[0] == date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m', str(date_val[1]))

View File

@ -159,7 +159,7 @@ class DateDisplayNL(DateDisplay):
return self.display_iso(date_val)
else:
# Numeric
if date_val[0] == 0 and date_val[1] == 0:
if date_val[0] == date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m', str(date_val[1]))

View File

@ -175,7 +175,7 @@ class DateDisplayPL(DateDisplay):
if date_val[3]:
return self.display_iso(date_val)
else:
if date_val[0] == 0 and date_val[1] == 0:
if date_val[0] == date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m',str(date_val[0]))

View File

@ -245,7 +245,7 @@ class CLIDbManager:
os.mkdir(new_path)
path_name = os.path.join(new_path, NAME_FILE)
if title == None:
if title is None:
name_list = [ name[0] for name in self.current_names ]
title = find_next_db_name(name_list)

View File

@ -271,7 +271,7 @@ class BaseModel(gtk.GenericTreeModel):
self.node_map.set_path_map([ x[1] for x in self.sort_data ])
index = self.node_map.get_path(handle)
if index != None:
if index is not None:
node = self.get_iter(index)
self.row_inserted(index, node)
@ -332,23 +332,23 @@ class BaseModel(gtk.GenericTreeModel):
def on_iter_children(self, node):
"""Return the first child of the node"""
if node == None and len(self.node_map):
if node is None and len(self.node_map):
return self.node_map.get_first_handle()
return None
def on_iter_has_child(self, node):
"""returns true if this node has children"""
if node == None:
if node is None:
return len(self.node_map) > 0
return False
def on_iter_n_children(self, node):
if node == None:
if node is None:
return len(self.node_map)
return 0
def on_iter_nth_child(self, node, n):
if node == None:
if node is None:
return self.node_map.get_handle(n)
return None

View File

@ -159,20 +159,20 @@ class NodeTreeMap:
return self.path2iter.get((surname, val+1))
def first_child(self, node):
if node == None:
if node is None:
return self.top_path2iter[0]
else:
return self.path2iter.get((node, 0))
def has_child(self, node):
if node == None:
if node is None:
return len(self.sname_sub)
if self.sname_sub.has_key(node) and len(self.sname_sub[node]) > 0:
return True
return False
def number_of_children(self, node):
if node == None:
if node is None:
return len(self.sname_sub)
try:
return len(self.sname_sub[node])
@ -181,7 +181,7 @@ class NodeTreeMap:
def get_nth_child(self, node, n):
try:
if node == None:
if node is None:
return self.top_path2iter[n]
try:
return self.path2iter[(node, n)]

View File

@ -368,7 +368,7 @@ class DisplayState(gen.utils.Callback):
self.relationship.connect_db_signals(dbstate)
default_person = dbstate.db.get_default_person()
active = dbstate.get_active_person()
if default_person == None or active == None:
if default_person is None or active is None:
return u''
if default_person.handle == self.disprel_defpers and \
active.handle == self.disprel_active :
@ -428,7 +428,7 @@ class DisplayState(gen.utils.Callback):
def modify_statusbar(self, dbstate, active=None):
self.status.pop(self.status_id)
if dbstate.active == None:
if dbstate.active is None:
self.status.push(self.status_id, "")
else:
person = dbstate.get_active_person()

View File

@ -274,7 +274,7 @@ class ButtonTab(GrampsTab):
# explicitly, dirty_selection must make sure they do not interact
if self.dirty_selection:
return
if self.get_selected() != None:
if self.get_selected() is not None:
self.edit_btn.set_sensitive(True)
if self.jump_btn:
self.jump_btn.set_sensitive(True)

View File

@ -241,7 +241,7 @@ class EmbeddedList(ButtonTab):
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.get_data())
else:
return row[0][0]

View File

@ -203,7 +203,7 @@ class GalleryTab(ButtonTab):
def _update_internal_list(self, *obj):
newlist = []
node = self.iconmodel.get_iter_first()
while node != None:
while node is not None:
newlist.append(self.iconmodel.get_value(node, 2))
node = self.iconmodel.iter_next(node)
for i in xrange(len(self.media_list)):

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)

View File

@ -307,7 +307,7 @@ class MyID(gtk.HBox):
selector = selector_factory(obj_class)
inst = selector(self.dbstate, self.uistate, self.track)
val = inst.run()
if val == None:
if val is None:
self.set_text('')
else:
self.set_text(val.get_gramps_id())

View File

@ -58,6 +58,6 @@ class MatchesRegexpOf(Rule):
def apply(self, db, note):
""" Apply the filter """
text = unicode(note.get())
if self.match.match(text) != None:
if self.match.match(text) is not None:
return True
return False

View File

@ -77,14 +77,14 @@ class RelationshipPathBetween(Rule):
def apply_filter(self,rank, handle,plist,pmap):
person = self.db.get_person_from_handle(handle)
if person == None:
if person is None:
return
plist.append(handle)
pmap[person.get_handle()] = rank
fam_id = person.get_main_parents_family_handle()
family = self.db.get_family_from_handle(fam_id)
if family != None:
if family is not None:
self.apply_filter(rank+1,family.get_father_handle(),plist,pmap)
self.apply_filter(rank+1,family.get_mother_handle(),plist,pmap)

View File

@ -78,7 +78,7 @@ class RelationshipPathBetweenBookmarks(Rule):
person = self.db.get_person_from_handle(handle)
except:
return None
if person == None:
if person is None:
return None
try:
name = person.get_primary_name().get_name()
@ -96,11 +96,11 @@ class RelationshipPathBetweenBookmarks(Rule):
for handle in generation:
try:
person = self.db.get_person_from_handle(handle)
if person == None:
if person is None:
continue
fam_id = person.get_main_parents_family_handle()
family = self.db.get_family_from_handle(fam_id)
if family == None:
if family is None:
continue
fhandle = family.get_father_handle()
mhandle = family.get_mother_handle()

View File

@ -59,7 +59,7 @@ class InLatLonNeighborhood(Rule):
self.halfheight = float(self.list[2])/2.
except ValueError :
self.halfheight = None
if self.halfheight != None and self.halfheight<= 0. :
if self.halfheight is not None and self.halfheight<= 0. :
self.halfheight = None
else :
self.halfheight = -1
@ -71,7 +71,7 @@ class InLatLonNeighborhood(Rule):
self.halfwidth = float(self.list[3])/2.
except ValueError :
self.halfwidth = None
if self.halfwidth!=None and self.halfwidth<= 0. :
if self.halfwidth is not None and self.halfwidth<= 0. :
self.halfwidth = None
else :
self.halfwidth = -1
@ -80,7 +80,7 @@ class InLatLonNeighborhood(Rule):
#we allow a band instead of a triangle
self.lat, self.lon = PlaceUtils.conv_lat_lon(self.list[0],self.list[1],"D.D8")
if self.lat != None and self.lon != None :
if self.lat is not None and self.lon is not None :
self.lat = float(self.lat)
self.lon = float(self.lon)
else :
@ -88,13 +88,13 @@ class InLatLonNeighborhood(Rule):
#we define the two squares we must look in
# can be 0, so check on None
if self.lat!=None and self.halfheight!=None and self.halfheight != -1 :
if self.lat is not None and self.halfheight is not None and self.halfheight != -1 :
self.S = self.lat + self.halfheight
if self.S > 90. : self.S = 90.
self.N = self.lat - self.halfheight
if self.N < -90. : self.N = -90.
self.doublesquares = False
if self.lon!=None and self.halfwidth!=None and self.halfwidth != -1 :
if self.lon is not None and self.halfwidth is not None and self.halfwidth != -1 :
if self.halfwidth >= 180. :
#the entire longitude is allowed, reset values
self.lon = 0.
@ -122,11 +122,11 @@ class InLatLonNeighborhood(Rule):
return False
# when given, must be valid
if self.lat == None or self.lon == None :
if self.lat is None or self.lon is None :
return False
# if height/width given, they must be valid
if self.halfheight == None or self.halfwidth == None :
if self.halfheight is None or self.halfwidth is None :
return False
#now we know at least one is given in the filter and is valid

View File

@ -60,6 +60,6 @@ class HasNoteRegexBase(Rule):
for notehandle in notelist:
note = db.get_note_from_handle(notehandle)
n = unicode(note.get(False))
if self.match.match(n) != None:
if self.match.match(n) is not None:
return True
return False

View File

@ -60,4 +60,4 @@ class RegExpIdBase(Rule):
self.match = re.compile('')
def apply(self, db, obj):
return self.match.match(obj.gramps_id) != None
return self.match.match(obj.gramps_id) is not None

View File

@ -53,7 +53,7 @@ class Rule:
pass
def set_list(self, arg):
assert isinstance(arg, list) or arg == None, "Argument is not a list"
assert isinstance(arg, list) or arg is None, "Argument is not a list"
assert len(arg) == len(self.labels), \
"Number of arguments does not match number of labels.\n"\
"list: %s\nlabels: %s" % (arg,self.labels)

View File

@ -106,7 +106,7 @@ class FilterParser(handler.ContentHandler):
self.a.append(attrs['value'])
def endElement(self, tag):
if tag == "rule" and self.r != None:
if tag == "rule" and self.r is not None:
if len(self.r.labels) < len(self.a):
print "WARNING: Invalid number of arguments in filter '%s'!" %\
self.f.get_name()

View File

@ -115,7 +115,7 @@ class GenericFilter:
def check_func(self, db, id_list, task):
final_list = []
if id_list == None:
if id_list is None:
cursor = self.get_cursor(db)
data = cursor.first()
while data:
@ -135,7 +135,7 @@ class GenericFilter:
def check_and(self, db, id_list):
final_list = []
flist = self.flist
if id_list == None:
if id_list is None:
cursor = self.get_cursor(db)
data = cursor.first()
while data:

View File

@ -383,7 +383,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
"""
model = self.fmt_obox.get_model()
iter = model.get_iter_first()
while iter != None:
while iter is not None:
othernum = model.get_value(iter, COL_NUM)
oldnum = model.get_value(oldnode, COL_NUM)
if othernum == oldnum:
@ -531,7 +531,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
"""
model, self.iter = tree_selection.get_selected()
if self.iter == None:
if self.iter is None:
tree_selection.select_path(0)
model, self.iter = tree_selection.get_selected()
self.selected_fmt = model.get(self.iter, 0, 1, 2)

View File

@ -990,9 +990,9 @@ class GedcomParser(UpdateCallback):
# if we haven't we need to get a new GRAMPS ID
intid = self.place_names.get(title)
if intid == None:
if intid is None:
intid = self.lid2id.get(title)
if intid == None:
if intid is None:
new_id = self.dbase.find_next_place_gramps_id()
else:
new_id = None
@ -2382,7 +2382,7 @@ class GedcomParser(UpdateCallback):
self.__parse_level(state, self.family_func, self.__family_even)
# handle addresses attached to families
if state.addr != None:
if state.addr is not None:
father_handle = family.get_father_handle()
father = self.dbase.get_person_from_handle(father_handle)
if father:
@ -4286,7 +4286,7 @@ class GedcomParser(UpdateCallback):
self.__warn(_("Could not import %s") % filename)
path = filename.replace('\\', os.path.sep)
photo_handle = self.media_map.get(path)
if photo_handle == None:
if photo_handle is None:
photo = gen.lib.MediaObject()
photo.set_path(path)
photo.set_description(title)

View File

@ -233,49 +233,49 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
"""
returns True if the handle exists in the current Person database.
"""
return self.person_map.get(str(handle), txn=self.txn) != None
return self.person_map.get(str(handle), txn=self.txn) is not None
def has_family_handle(self, handle):
"""
returns True if the handle exists in the current Family database.
"""
return self.family_map.get(str(handle), txn=self.txn) != None
return self.family_map.get(str(handle), txn=self.txn) is not None
def has_object_handle(self, handle):
"""
returns True if the handle exists in the current MediaObjectdatabase.
"""
return self.media_map.get(str(handle), txn=self.txn) != None
return self.media_map.get(str(handle), txn=self.txn) is not None
def has_repository_handle(self, handle):
"""
returns True if the handle exists in the current Repository database.
"""
return self.repository_map.get(str(handle), txn=self.txn) != None
return self.repository_map.get(str(handle), txn=self.txn) is not None
def has_note_handle(self, handle):
"""
returns True if the handle exists in the current Note database.
"""
return self.note_map.get(str(handle), txn=self.txn) != None
return self.note_map.get(str(handle), txn=self.txn) is not None
def has_event_handle(self, handle):
"""
returns True if the handle exists in the current Repository database.
"""
return self.event_map.get(str(handle), txn=self.txn) != None
return self.event_map.get(str(handle), txn=self.txn) is not None
def has_place_handle(self, handle):
"""
returns True if the handle exists in the current Repository database.
"""
return self.place_map.get(str(handle), txn=self.txn) != None
return self.place_map.get(str(handle), txn=self.txn) is not None
def has_source_handle(self, handle):
"""
returns True if the handle exists in the current Repository database.
"""
return self.source_map.get(str(handle), txn=self.txn) != None
return self.source_map.get(str(handle), txn=self.txn) is not None
def get_raw_person_data(self, handle):
"""
@ -474,7 +474,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
else:
the_txn = None
if gstats == None:
if gstats is None:
# New database. Set up the current version.
self.metadata.put('version', _DBVERSION, txn=the_txn)
elif not self.metadata.has_key('version'):
@ -820,7 +820,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
data = self.reference_map.get(data)
else:
data = pickle.loads(data)
if include_classes == None or \
if include_classes is None or \
KEY_TO_CLASS_MAP[data[0][0]] in include_classes:
yield (KEY_TO_CLASS_MAP[data[0][0]], data[0][1])
@ -1599,13 +1599,13 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
return status
def undo_reference(self, data, handle):
if data == None:
if data is None:
self.reference_map.delete(handle, txn=self.txn)
else:
self.reference_map.put(handle, data, txn=self.txn)
def undo_data(self, data, handle, db_map, signal_root):
if data == None:
if data is None:
self.emit(signal_root + '-delete', ([handle], ))
db_map.delete(handle, txn=self.txn)
else:

View File

@ -834,7 +834,7 @@ class GrampsDbXmlWriter(UpdateCallback):
%(sp,self.fix(date.get_text())))
def write_force_line(self,label,value,indent=1):
if value != None:
if value is not None:
self.g.write('%s<%s>%s</%s>\n' % (' '*indent,label,self.fix(value),label))
def dump_name(self, name,alternative=False,index=1):
@ -962,15 +962,13 @@ class GrampsDbXmlWriter(UpdateCallback):
corner1_y = rect[1]
corner2_x = rect[2]
corner2_y = rect[3]
if corner1_x==None : corner1_x = 0
if corner1_y==None : corner1_y = 0
if corner2_x==None : corner2_x = 100
if corner2_y==None : corner2_y = 100
if corner1_x is None : corner1_x = 0
if corner1_y is None : corner1_y = 0
if corner2_x is None : corner2_x = 100
if corner2_y is None : corner2_y = 100
#don't output not set rectangle
if (corner1_x == 0 and corner1_y == 0
and corner2_x == 0 and corner2_y == 0
) or (corner1_x == 0 and corner1_y == 0
and corner2_x == 100 and corner2_y == 100
if (corner1_x == corner1_y == corner2_x == corner2_y == 0) or \
(corner1_x == corner1_y == 0 and corner2_x == corner2_y == 100
):
rect = None
if (len(proplist) + len(nreflist) + len(refslist)) == 0 \
@ -1137,4 +1135,4 @@ def conf_priv(obj):
#
#-------------------------------------------------------------------------
# Don't export a writer for plugins, that is the task of _WriteXML.py
# Don't export a writer for plugins, that is the task of _WriteXML.py

View File

@ -756,7 +756,7 @@ class GrampsParser(UpdateCallback):
name_displayer.set_name_format(self.db.name_formats)
self.db.set_researcher(self.owner)
if self.home != None:
if self.home is not None:
person = self.db.get_person_from_handle(self.home)
self.db.set_default_person_handle(person.handle)
@ -971,11 +971,11 @@ class GrampsParser(UpdateCallback):
event.personal = True
if (event.type == gen.lib.EventType.BIRTH) \
and (self.eventref.role == gen.lib.EventRoleType.PRIMARY) \
and (self.person.get_birth_ref() == None):
and (self.person.get_birth_ref() is None):
self.person.set_birth_ref(self.eventref)
elif (event.type == gen.lib.EventType.DEATH) \
and (self.eventref.role == gen.lib.EventRoleType.PRIMARY) \
and (self.person.get_death_ref() == None):
and (self.person.get_death_ref() is None):
self.person.set_death_ref(self.eventref)
else:
self.person.add_event_ref(self.eventref)
@ -1881,7 +1881,7 @@ class GrampsParser(UpdateCallback):
else:
text = None
if text != None:
if text is not None:
note = gen.lib.Note()
note.handle = Utils.create_id()
note.set(_("Witness comment: %s") % text)
@ -1963,10 +1963,10 @@ class GrampsParser(UpdateCallback):
ref.private = self.event.private
ref.role.set(gen.lib.EventRoleType.PRIMARY)
if (self.event.type == gen.lib.EventType.BIRTH) \
and (self.person.get_birth_ref() == None):
and (self.person.get_birth_ref() is None):
self.person.set_birth_ref(ref)
elif (self.event.type == gen.lib.EventType.DEATH) \
and (self.person.get_death_ref() == None):
and (self.person.get_death_ref() is None):
self.person.set_death_ref(ref)
else:
self.person.add_event_ref(ref)
@ -2037,7 +2037,7 @@ class GrampsParser(UpdateCallback):
"""
##place = None
##handle = None
##if self.place_ref == None: #todo, add place_ref in start and init
##if self.place_ref is None: #todo, add place_ref in start and init
## #legacy cody? I see no reason for this, but it was present
## if self.place_map.has_key(tag):
## place = self.place_map[tag]

View File

@ -1111,7 +1111,7 @@ class GedcomWriter(BasicUtils.UpdateCallback):
+2 MEDI <SOURCE_MEDIA_TYPE> {0:1}
"""
if reporef.ref == None:
if reporef.ref is None:
return
repo = self.dbase.get_repository_from_handle(reporef.ref)
@ -1339,7 +1339,7 @@ class GedcomWriter(BasicUtils.UpdateCallback):
"""
src_handle = ref.get_reference_handle()
if src_handle == None:
if src_handle is None:
return
src = self.dbase.get_source_from_handle(src_handle)

View File

@ -49,7 +49,7 @@ def cli_callback(val):
def exportData(database, filename, person=None, callback=None, cl=False):
if callback == None:
if callback is None:
callback = cli_callback
filename = os.path.normpath(filename)

View File

@ -66,14 +66,14 @@ class LdsTemples:
returns True if the code is a valid LDS temple code according
to the lds.xml file
"""
return self.__temple_to_abrev.get(code) != None
return self.__temple_to_abrev.get(code) is not None
def is_valid_name(self, name):
"""
returns True if the name matches a temple name (not code) in
the lds.xml file
"""
return self.__temple_codes.get(name) != None
return self.__temple_codes.get(name) is not None
def code(self, name):
"""
@ -110,7 +110,7 @@ class LdsTemples:
text = ''.join(self.__tlist)
if tag == "code":
if self.__temple_codes.get(self.__current_temple) == None:
if self.__temple_codes.get(self.__current_temple) is None:
self.__temple_codes[self.__current_temple] = text
self.__temple_to_abrev[text] = self.__current_temple

View File

@ -231,7 +231,7 @@ class ListModel:
Return the row at the specified (x,y) coordinates
"""
path = self.tree.get_path_at_pos(xpos, ypos)
if path == None:
if path is None:
return self.count -1
else:
return path[0][0]-1

View File

@ -97,7 +97,7 @@ class LRU:
Iterate over the LRU
"""
cur = self.first
while cur != None:
while cur is not None:
cur2 = cur.next
yield cur.value[1]
cur = cur2
@ -108,7 +108,7 @@ class LRU:
Return items in the LRU using a generator
"""
cur = self.first
while cur != None:
while cur is not None:
cur2 = cur.next
yield cur.value
cur = cur2

View File

@ -394,7 +394,7 @@ class ManagedWindow:
return id(obj)
def define_glade(self, top_module, glade_file=None):
if glade_file == None:
if glade_file is None:
glade_file = const.GLADE_FILE
self._gladeobj = glade.XML(glade_file, top_module, "gramps")
return self._gladeobj

View File

@ -705,7 +705,7 @@ class MergePeople:
## fam.set_father_handle(self.p1)
## if self.p2 == fam.get_mother_handle():
## fam.set_mother_handle(self.p1)
## if fam.get_father_handle() == None and fam.get_mother_handle() == None:
## if fam.get_father_handle() is None and fam.get_mother_handle() is None:
## self.delete_empty_family(fam, trans)
## data = cursor.next()

View File

@ -840,7 +840,7 @@ class ListView(BookMarkView):
self.list.set_model(self.model)
self.build_columns()
if const.USE_TIPS and self.model.tooltip_column != None:
if const.USE_TIPS and self.model.tooltip_column is not None:
self.tooltips = TreeTips.TreeTips(
self.list, self.model.tooltip_column, True)
self.dirty = False

View File

@ -237,18 +237,18 @@ def conv_lat_lon(latitude, longitude, format="D.D4"):
else:
error = True
# degs should have a value now
if degs == None:
if degs is None:
error = True
if error:
return None
if v != None:
if v is not None:
return v
#we have a degree notation, convert to float
v = float(degs)
if secs != None:
if secs is not None:
v += secs / 3600.
if mins != None:
if mins is not None:
v += float(mins) / 60.
if sign =="-":
v = v * -1.
@ -277,7 +277,7 @@ def conv_lat_lon(latitude, longitude, format="D.D4"):
lon_float = convert_float_val(longitude, 'lon')
# give output (localized if needed)
if lat_float == None or lon_float == None:
if lat_float is None or lon_float is None:
if format == "ISO-D" or format == "ISO-DM" or format == "ISO-DMS":
return None
else:

View File

@ -1252,7 +1252,7 @@ class GuiMenuOptions:
widget, label = make_gui_option(option, self.__tooltips,
dialog.dbstate, dialog.uistate, dialog.track)
if widget == None:
if widget is None:
print "UNKNOWN OPTION: ", option
else:
if label:

View File

@ -143,7 +143,6 @@ class PluginManager(gen.utils.Callback):
self.__success_list.append((filename, _module))
except:
self.__failmsg_list.append((filename, sys.exc_info()))
return len(self.__failmsg_list) != 0 # return True if there are errors
def reload_plugins(self):

View File

@ -407,7 +407,7 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
self.frame_names.append(frame_name)
def set_current_frame(self, name):
if name == None:
if name is None:
self.notebook.set_current_page(0)
else:
for frame_name in self.frame_names:

View File

@ -888,7 +888,7 @@ class RelationshipCalculator:
will be looked up anyway an stored if common. At end the doubles
are filtered out
"""
if person == None or not person.handle :
if person is None or not person.handle :
return
if depth > self.__max_depth:
@ -1189,7 +1189,7 @@ class RelationshipCalculator:
(relation_string, distance_common_orig, distance_common_other)
"""
stop = False
if orig_person == None:
if orig_person is None:
rel_str = _("undefined")
stop = True
@ -1233,7 +1233,7 @@ class RelationshipCalculator:
dist_other= len(rel[4])
if len(databest) == 1:
birth = self.only_birth(rel[2]) and self.only_birth(rel[4])
if dist_orig == 1 and dist_other == 1:
if dist_orig == dist_other == 1:
rel_str = self.get_sibling_relationship_string(
self.get_sibling_type(
db, orig_person, other_person),
@ -1287,7 +1287,7 @@ class RelationshipCalculator:
dist_orig = len(rel[2])
dist_other= len(rel[4])
birth = self.only_birth(rel[2]) and self.only_birth(rel[4])
if dist_orig == 1 and dist_other == 1:
if dist_orig == dist_other == 1:
rel_str = self.get_sibling_relationship_string(
self.get_sibling_type(
db, orig_person, other_person),
@ -1314,7 +1314,7 @@ class RelationshipCalculator:
"""
relstrings = []
commons = {}
if orig_person == None:
if orig_person is None:
return ([], [])
if orig_person.get_handle() == other_person.get_handle():
@ -1342,7 +1342,7 @@ class RelationshipCalculator:
rel4 = rel4 + self.REL_FAM_BIRTH
rel1 = None
birth = self.only_birth(rel2) and self.only_birth(rel4)
if dist_orig == 1 and dist_other == 1:
if dist_orig == dist_other == 1:
rel_str = self.get_sibling_relationship_string(
self.get_sibling_type(
db, orig_person, other_person),

View File

@ -187,11 +187,11 @@ class Bibliography:
return True
if ( self.mode & self.MODE_DATE ) == self.MODE_DATE:
date = source_ref.get_date_object()
if date != None and not date.is_empty():
if date is not None and not date.is_empty():
return True
if ( self.mode & self.MODE_CONF ) == self.MODE_CONF:
confidence = source_ref.get_confidence_level()
if confidence != None and confidence != SourceRef.CONF_NORMAL:
if confidence is not None and confidence != SourceRef.CONF_NORMAL:
return True
if ( self.mode & self.MODE_NOTE ) == self.MODE_NOTE:
if len(source_ref.get_note_list()) != 0:

View File

@ -165,7 +165,7 @@ class DocReportDialog(ReportDialog):
self.row += 1
ext = self.format_menu.get_ext()
if ext == None:
if ext is None:
ext = ""
else:
spath = self.get_default_directory()

View File

@ -76,7 +76,7 @@ def cite_source(bibliography, obj):
first = 0
(cindex, key) = bibliography.add_reference(ref)
txt += "%d" % (cindex + 1)
if key != None:
if key is not None:
txt += key
return txt

View File

@ -931,7 +931,7 @@ class GraphvizReportDialog(ReportDialog):
self.row += 1
ext = self.format_menu.get_ext()
if ext == None:
if ext is None:
ext = ""
else:
spath = self.get_default_directory()

View File

@ -1436,7 +1436,7 @@ def estimate_age(db, person, end_handle=None, start_handle=None, today=_TODAY):
if dhandle:
ddata = db.get_event_from_handle(dhandle).get_date_object()
else:
if today != None:
if today is not None:
ddata = today
else:
return (-1, -1)
@ -1461,7 +1461,7 @@ def estimate_age(db, person, end_handle=None, start_handle=None, today=_TODAY):
else:
return high[2] - low[2]
if bstop == Date.EMPTY and dstop == Date.EMPTY:
if bstop == dstop == Date.EMPTY:
lower = _calc_diff(bstart, dstart)
age = (lower, lower)
elif bstop == Date.EMPTY:
@ -1504,7 +1504,7 @@ def estimate_age_on_date(db, person, ddata=_TODAY):
return high[2] - low[2] - 1
else:
return high[2] - low[2]
if bstop == Date.EMPTY and dstop == Date.EMPTY:
if bstop == dstop == Date.EMPTY:
lower = _calc_diff(bstart, dstart)
age = [lower, lower]
elif bstop == Date.EMPTY:
@ -1655,7 +1655,7 @@ def born_died_str(database, person, endnotes=None, name_object=None, person_name
if not name_object:
name_object = person.get_primary_name()
if person_name == None:
if person_name is None:
person_name = _nd.display_name(name_object)
elif person_name == 0:
if person.get_gender() == Person.MALE:
@ -2140,7 +2140,7 @@ def born_str(database, person, person_name=None, verbose=True,
"""
name_index = 1
if person_name == None:
if person_name is None:
person_name = _nd.display(person)
elif person_name == 0:
name_index = 0
@ -2238,7 +2238,7 @@ def died_str(database, person, person_name=None, verbose=True,
"""
name_index = 1
if person_name == None:
if person_name is None:
person_name = _nd.display(person)
elif person_name == 0:
name_index = 0
@ -2321,7 +2321,7 @@ def buried_str(database, person, person_name=None, empty_date="", empty_place=""
"""
name_index = 0
if person_name == None:
if person_name is None:
person_name = _nd.display(person)
elif person_name == 0:
name_index = 1
@ -2606,7 +2606,7 @@ def get_person_mark(db, person):
deathEvt = db.get_event_from_handle(death_ref.ref)
death = DateHandler.get_date(deathEvt)
if birth == " " and death == " ":
if birth == death == " ":
key = name
else:
key = "%s (%s - %s)" % (name, birth, death)

View File

@ -1060,7 +1060,7 @@ class ScratchPadListView:
self._widget.unset_rows_drag_source()
if node != None:
if node is not None:
o = model.get_value(node,1)
targets = [ScratchPadListView.LOCAL_DRAG_TARGET] + \

View File

@ -612,7 +612,7 @@ class SimpleAccess:
@rtype: list
"""
assert(isinstance(obj, (gen.lib.Person, gen.lib.Family, NoneType)))
assert(isinstance(restrict, list) or restrict == None)
assert(isinstance(restrict, list) or restrict is None)
if obj:
event_handles = [ ref.ref for ref in obj.get_event_ref_list() ]

View File

@ -187,7 +187,7 @@ class SimpleTable:
elif isinstance(item, gen.lib.Person):
name = self.access.name(item)
retval.append(name)
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Person', item.handle)
elif isinstance(item, gen.lib.Family):
father = self.access.father(item)
@ -203,32 +203,32 @@ class SimpleTable:
else:
text += " " + _("Unknown mother")
retval.append(text)
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Family', item.handle)
elif isinstance(item, gen.lib.Source):
retval.append(_('Source'))
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Souce', item.handle)
elif isinstance(item, gen.lib.Event):
name = self.access.event_type(item)
retval.append(name)
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Event', item.handle)
elif isinstance(item, gen.lib.MediaObject):
retval.append(_('Media'))
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Media', item.handle)
elif isinstance(item, gen.lib.Place):
retval.append(_('Place'))
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Place', item.handle)
elif isinstance(item, gen.lib.Repository):
retval.append(_('Repository'))
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Repository', item.handle)
elif isinstance(item, gen.lib.Note):
retval.append(_('Note'))
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Note', item.handle)
elif isinstance(item, gen.lib.Date):
text = DateHandler.displayer.display(item)
@ -242,7 +242,7 @@ class SimpleTable:
invalid_date_format = Config.get(Config.INVALID_DATE_FORMAT)
self.set_cell_markup(col, row,
invalid_date_format % text)
if (self.__link_col == col or link == None):
if (self.__link_col == col or link is None):
link = ('Date', item)
elif isinstance(item, gen.lib.Span):
text = str(item)
@ -363,14 +363,14 @@ class SimpleTable:
has formatting), or just the plain data.
"""
if x in self.__cell_markup:
if y == None:
if y is None:
return True # markup for this column
elif y in self.__cell_markup[x]:
return self.__cell_markup[x][y]
else:
return cgi.escape(data)
else:
if y == None:
if y is None:
return False # no markup for this column
else:
return data

View File

@ -121,7 +121,7 @@ def __build_thumb_path(path, rectangle=None):
@returns: full path name to the corresponding thumbnail file.
"""
extra = ""
if rectangle != None:
if rectangle is not None:
extra = "?" + str(rectangle)
md5_hash = md5.md5(path+extra)
return os.path.join(const.THUMB_DIR, md5_hash.hexdigest()+'.png')
@ -158,7 +158,7 @@ def __create_thumbnail_image(src_file, mtype=None, rectangle=None):
width = pixbuf.get_width()
height = pixbuf.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.

View File

@ -185,7 +185,7 @@ class TreeTips(gtk.Widget):
return False
pathReturn = tree.get_path_at_pos(xEvent, yEvent)
model = tree.get_model()
if pathReturn == None:
if pathReturn is None:
self.path = None
elif self.path != pathReturn[0]:
self.path = pathReturn[0]

View File

@ -138,7 +138,7 @@ def fix_encoding(value):
def xml_lang():
loc = locale.getlocale()
if loc[0] == None:
if loc[0] is None:
return ""
else:
return loc[0].replace('_', '-')
@ -578,7 +578,7 @@ def probably_alive(person, db, current_date=None, limit=0):
(defaults to today)
limit - number of years to check beyond death_date
"""
if current_date == None:
if current_date is None:
current_date = gen.lib.Date()
# yr, mon, day:
current_date.set_yr_mon_day(*time.localtime(time.time())[0:3])

View File

@ -969,12 +969,12 @@ class ViewManager:
Initialize the navigation scheme
"""
old_nav = self._navigation_type[self.prev_nav]
if old_nav[0] != None:
if old_nav[0] is not None:
old_nav[0].disable()
page_type = self.active_page.navigation_type()
nav_type = self._navigation_type[page_type]
if nav_type[0] != None:
if nav_type[0] is not None:
nav_type[0].enable()
def change_page(self, obj, page, num=-1):

View File

@ -76,4 +76,7 @@
<author uid="zfoldvar" title="contributor">
Zsolt Foldvari &lt;<html:a href="mailto:zfoldvar@users.sourceforge.net">zfoldvar@users.sourceforge.net</html:a>&gt;
</author>
<author uid="gbritton" title="contributor">
Gerald Britton &lt;<html:a href="mailto:gerald.britton@gmail.com">gerald.britton@gmail.com</html:a>&gt;
</author>
</authors>

View File

@ -146,7 +146,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
top_add = 0
elif bottom_add == 0:
match = stop.search(line)
if match != None:
if match is not None:
bottom_add = 1
self.bottom.append(line)
else:
@ -172,7 +172,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
top_add = 0
elif bottom_add == 0:
match = stop.search(line)
if match != None:
if match is not None:
bottom_add = 1
self.bottom.append(line)
else:
@ -245,7 +245,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
self.fix_title("".join(self.top))
def fix_title(self,msg=None):
if msg == None:
if msg is None:
match = t_header_line_re.match(self.file_header)
else:
match = t_header_line_re.match(msg)
@ -428,7 +428,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
def start_paragraph(self,style_name,leader=None):
self.f.write('<p class="' + style_name + '">')
if leader != None:
if leader is not None:
self.f.write(leader)
self.f.write(' ')

View File

@ -326,15 +326,15 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
self.indent = ltxstyle.leftIndent
self.FLindent = ltxstyle.firstLineIndent
if self.indent != None and not self.in_table:
if self.indent is not None and not self.in_table:
myspace = '%scm' % str(self.indent)
self.f.write('\\grampsindent{%s}\n' % myspace)
self.fix_indent = 1
if leader != None and not self.in_list:
if leader is not None and not self.in_list:
self.f.write('\\begin{enumerate}\n')
self.in_list = 1
if leader != None:
if leader is not None:
# try obtaining integer
leader_1 = leader[:-1]
num = roman2arabic(leader_1)
@ -356,7 +356,7 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
self.f.write(' \\addtocounter{enumi}{-1}\n')
self.f.write(' \\item ')
if leader == None and not self.in_list and not self.in_table:
if leader is None and not self.in_list and not self.in_table:
self.f.write('\n')
self.f.write('%s ' % self.fbeg)

View File

@ -847,7 +847,7 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
self.cntnt.write('<text:h text:style-name="')
self.cntnt.write(name)
self.cntnt.write('" text:outline-level="' + str(self.level) + '">')
if leader != None:
if leader is not None:
self.cntnt.write(leader)
self.cntnt.write('<text:tab/>')
self.new_cell = 0

View File

@ -58,9 +58,9 @@ try:
except:
pass
if print_label == None:
if print_label is None:
# Second, try to print directly
if get_print_dialog_app() != None:
if get_print_dialog_app() is not None:
print_label = _("Print a copy")
#-------------------------------------------------------------------------

View File

@ -1717,7 +1717,7 @@ class GrampsDbBase(Callback):
if self.undoindex >= _UNDO_SIZE or self.readonly:
return False
if self.translist[self.undoindex+1] == None:
if self.translist[self.undoindex+1] is None:
return False
return True
@ -1811,7 +1811,7 @@ class GrampsDbBase(Callback):
pass
def undo_data(self, data, handle, db_map, signal_root):
if data == None:
if data is None:
self.emit(signal_root + '-delete', ([handle], ))
del db_map[handle]
else:
@ -1924,7 +1924,7 @@ class GrampsDbBase(Callback):
def set_default_person_handle(self, handle):
"""Set the default Person to the passed instance."""
if (self.metadata != None) and (not self.readonly):
if (self.metadata is not None) and (not self.readonly):
self.metadata['default'] = str(handle)
def get_default_person(self):
@ -1932,13 +1932,13 @@ class GrampsDbBase(Callback):
person = self.get_person_from_handle(self.get_default_handle())
if person:
return person
elif (self.metadata != None) and (not self.readonly):
elif (self.metadata is not None) and (not self.readonly):
self.metadata['default'] = None
return None
def get_default_handle(self):
"""Return the default Person of the database."""
if self.metadata != None:
if self.metadata is not None:
return self.metadata.get('default')
return None
@ -2252,17 +2252,17 @@ class GrampsDbBase(Callback):
def set_mediapath(self, path):
"""Set the default media path for database, path should be utf-8."""
if (self.metadata != None) and (not self.readonly):
if (self.metadata is not None) and (not self.readonly):
self.metadata['mediapath'] = path
def get_mediapath(self):
"""Return the default media path of the database."""
if self.metadata != None:
if self.metadata is not None:
return self.metadata.get('mediapath', None)
return None
def set_column_order(self, col_list, name):
if (self.metadata != None) and (not self.readonly):
if (self.metadata is not None) and (not self.readonly):
self.metadata[name] = col_list
def set_person_column_order(self, col_list):
@ -2321,7 +2321,7 @@ class GrampsDbBase(Callback):
self.set_column_order(col_list, NOTE_COL_KEY)
def __get_column_order(self, name, default):
if self.metadata == None:
if self.metadata is None:
return default
else:
cols = self.metadata.get(name, default)
@ -2496,7 +2496,7 @@ class GrampsDbBase(Callback):
# Find which tables to iterate over
if (include_classes == None):
if (include_classes is None):
the_tables = primary_tables.keys()
else:
the_tables = include_classes
@ -2627,7 +2627,7 @@ class Transaction:
"""
self.last = self.db.append(
cPickle.dumps((obj_type, handle, old_data, new_data), 1))
if self.first == None:
if self.first is None:
self.first = self.last
def get_recnos(self):

View File

@ -262,7 +262,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
def __has_handle(self, table, handle):
try:
return table.get(str(handle), txn=self.txn) != None
return table.get(str(handle), txn=self.txn) is not None
except DBERRS, msg:
self.__log_error()
raise Errors.DbError(msg)
@ -537,7 +537,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
# Start transaction
the_txn = self.env.txn_begin()
if gstats == None:
if gstats is None:
# New database. Set up the current version.
self.metadata.put('version', _DBVERSION, txn=the_txn)
elif not self.metadata.has_key('version'):
@ -876,7 +876,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
data = self.reference_map.get(data)
else:
data = pickle.loads(data)
if include_classes == None or \
if include_classes is None or \
KEY_TO_CLASS_MAP[data[0][0]] in include_classes:
yield (KEY_TO_CLASS_MAP[data[0][0]], data[0][1])
@ -1664,7 +1664,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
def undo_reference(self, data, handle):
try:
if data == None:
if data is None:
self.reference_map.delete(handle, txn=self.txn)
else:
self.reference_map.put(handle, data, txn=self.txn)
@ -1674,7 +1674,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
def undo_data(self, data, handle, db_map, signal_root):
try:
if data == None:
if data is None:
self.emit(signal_root + '-delete', ([handle],))
db_map.delete(handle, txn=self.txn)
else:

View File

@ -97,7 +97,7 @@ class Span:
) # number of months, for sorting
def __eq__(self, other):
if other == None:
if other is None:
return False
return self.diff_tuple == other.diff_tuple
@ -204,15 +204,15 @@ class Date:
raise AttributeError, "invalid args to Date: %s" % source
#### ok, process either date or tuple
if isinstance(source, tuple):
if calendar == None:
if calendar is None:
self.calendar = Date.CAL_GREGORIAN
else:
self.calendar = self.lookup_calendar(calendar)
if modifier == None:
if modifier is None:
self.modifier = Date.MOD_NONE
else:
self.modifier = self.lookup_modifier(modifier)
if quality == None:
if quality is None:
self.quality = Date.QUAL_NONE
else:
self.quality = self.lookup_quality(quality)
@ -222,9 +222,9 @@ class Date:
self.newyear = 0
self.set_yr_mon_day(*source)
elif isinstance(source, str) and source != "":
if (calendar != None or
modifier != None or
quality != None):
if (calendar is not None or
modifier is not None or
quality is not None):
raise AttributeError("can't set calendar, modifier, or "
"quality with string date")
import DateHandler
@ -972,7 +972,7 @@ class Date:
year = max(value[Date._POS_YR], 1)
month = max(value[Date._POS_MON], 1)
day = max(value[Date._POS_DAY], 1)
if year == 0 and month == 0 and day == 0:
if year == month == 0 and day == 0:
self.sortval = 0
else:
func = Date._calendar_convert[calendar]
@ -995,7 +995,7 @@ class Date:
year = max(self.dateval[Date._POS_YR], 1)
month = max(self.dateval[Date._POS_MON], 1)
day = max(self.dateval[Date._POS_DAY], 1)
if year == 0 and month == 0 and day == 0:
if year == month == 0 and day == 0:
self.sortval = 0
else:
func = Date._calendar_convert[self.calendar]

View File

@ -57,7 +57,7 @@ class DateBase:
"""
Convert the object to a serialized tuple of data.
"""
if self.date == None or (self.date.is_empty() and not self.date.text):
if self.date is None or (self.date.is_empty() and not self.date.text):
date = None
else:
date = self.date.serialize(no_text_date)

View File

@ -255,7 +255,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
@returns: True if the Events are equal
@rtype: bool
"""
if other == None:
if other is None:
other = Event (None)
if self.__type != other.__type or \
@ -314,3 +314,4 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
"""
return self.__description
description = property(get_description, set_description, None, 'Returns or sets description of the event')

View File

@ -204,3 +204,4 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
"""
self.__role.set(role)
role = property(get_role, set_role, None, 'Returns or sets role property')

View File

@ -56,6 +56,6 @@ class FamilyRelType(GrampsType):
]
def __init__(self, value=None):
if value == None:
if value is None:
value = self.UNKNOWN
GrampsType.__init__(self, value)

View File

@ -44,7 +44,7 @@ class GenderStats:
indicating the gender of the person.
"""
def __init__ (self, stats={}):
if stats == None:
if stats is None:
self.stats = {}
else:
self.stats = stats

View File

@ -95,7 +95,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
@rtype: tuple
"""
if self.main_loc == None or self.main_loc.serialize() == _EMPTY_LOC:
if self.main_loc is None or self.main_loc.serialize() == _EMPTY_LOC:
main_loc = None
else:
main_loc = self.main_loc.serialize()

View File

@ -226,7 +226,7 @@ class Tester(unittest.TestCase):
"""
Tests two GRAMPS dates to see if they match.
"""
if expected2 == None:
if expected2 is None:
expected2 = expected1
date1 = _dp.parse(d1)
date2 = _dp.parse(d2)

View File

@ -76,7 +76,7 @@ class LivingProxyDb(ProxyDbBase):
"""
ProxyDbBase.__init__(self, dbase)
self.mode = mode
if current_year != None:
if current_year is not None:
self.current_date = Date()
self.current_date.set_year(current_year)
else:

View File

@ -343,7 +343,7 @@ class Callback(object):
self._current_signals.append(signal_name)
# check that args is a tuple. This is a common programming error.
if not (isinstance(args, tuple) or args == None):
if not (isinstance(args, tuple) or args is None):
self._warn("Signal emitted with argument that is not a tuple.\n"
" emit() takes two arguments, the signal name and a \n"
" tuple that contains the arguments that are to be \n"
@ -359,7 +359,7 @@ class Callback(object):
# type check arguments
arg_types = self.__signal_map[signal_name]
if arg_types == None and len(args) > 0:
if arg_types is None and len(args) > 0:
self._warn("Signal emitted with "
"wrong number of args: %s\n"
" from: file: %s\n"
@ -378,7 +378,7 @@ class Callback(object):
% ((str(signal_name), ) + inspect.stack()[1][1:4]))
return
if arg_types != None:
if arg_types is not None:
for i in range(0, len(arg_types)):
if not isinstance(args[i], arg_types[i]):
self._warn("Signal emitted with "

View File

@ -73,7 +73,7 @@ def delete_person_from_database(db, person, trans):
def remove_family_relationships(db, family_handle, trans=None):
family = db.get_family_from_handle(family_handle)
if trans == None:
if trans is None:
need_commit = True
trans = db.transaction_begin()
else:
@ -105,7 +105,7 @@ def remove_parent_from_family(db, person_handle, family_handle, trans=None):
person = db.get_person_from_handle(person_handle)
family = db.get_family_from_handle(family_handle)
if trans == None:
if trans is None:
need_commit = True
trans = db.transaction_begin()
else:
@ -144,7 +144,7 @@ def remove_child_from_family(db, person_handle, family_handle, trans=None):
person.remove_parent_family_handle(family_handle)
family.remove_child_handle(person_handle)
if trans == None:
if trans is None:
need_commit = True
trans = db.transaction_begin()
else:
@ -186,7 +186,7 @@ def add_child_to_family(db, family, child,
family.add_child_ref(cref)
child.add_parent_family_handle(family.handle)
if trans == None:
if trans is None:
need_commit = True
trans = db.transaction_begin()
else:

View File

@ -83,14 +83,14 @@ class ProgressMonitor(object):
self._title = title
self._popup_time = popup_time
if self._popup_time == None:
if self._popup_time is None:
self._popup_time = self.__class__.__default_popup_time
self._status_stack = [] # list of current status objects
self._dlg = None
def _get_dlg(self):
if self._dlg == None:
if self._dlg is None:
self._dlg = self._dialog_class(self._dialog_class_params,
self._title)
@ -134,7 +134,7 @@ class ProgressMonitor(object):
if facade.active:
dlg = self._get_dlg()
if facade.pbar_idx == None:
if facade.pbar_idx is None:
facade.pbar_idx = dlg.add(facade.status_obj)
dlg.show()

View File

@ -62,10 +62,10 @@ def run(database, document, date):
if birth_date:
if (birth_date.get_valid() and birth_date < date and
birth_date.get_year() != 0 and
((death_date == None) or (death_date > date))):
((death_date is None) or (death_date > date))):
diff_tuple = (date - birth_date)
if ((death_date != None) or
(death_date == None and
if ((death_date is not None) or
(death_date is None and
diff_tuple[0] <= Config.get(Config.MAX_AGE_PROB_ALIVE))):
birth_str = str(diff_tuple)
birth_sort = int(diff_tuple)

View File

@ -159,8 +159,8 @@ class Calendar(Report):
married_name = n
break # use first
# Now, decide which to use:
if maiden_name != None:
if married_name != None:
if maiden_name is not None:
if married_name is not None:
name = gen.lib.Name(married_name)
else:
name = gen.lib.Name(primary_name)
@ -326,7 +326,7 @@ class Calendar(Report):
if birth_ref:
birth_event = self.database.get_event_from_handle(birth_ref.ref)
birth_date = birth_event.get_date_object()
if self.birthdays and birth_date != None:
if self.birthdays and birth_date is not None:
year = birth_date.get_year()
month = birth_date.get_month()
day = birth_date.get_day()
@ -347,7 +347,7 @@ class Calendar(Report):
if mother_handle == person_handle:
if father_handle:
father = self.database.get_person_from_handle(father_handle)
if father != None:
if father is not None:
father_lastname = father.get_primary_name().get_surname()
short_name = self.get_name(person, father_lastname)
if age >= 0:
@ -390,7 +390,7 @@ class Calendar(Report):
gen.lib.EventType.ANNULMENT,
gen.lib.EventType.DIV_FILING]:
are_married = None
if are_married != None:
if are_married is not None:
for event_ref in fam.get_event_ref_list():
event = self.database.get_event_from_handle(event_ref.ref)
event_obj = event.get_date_object()
@ -598,7 +598,7 @@ class CalendarOptions(MenuReportOptions):
g.set_paragraph_style(name)
if shadow:
g.set_shadow(*shadow)
if color != None:
if color is not None:
g.set_fill_color(color)
if not borders:
g.set_line_width(0)

View File

@ -96,7 +96,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
lSP = len(namesplitSP)
namesplitHY= name.split('-')
lHY = len(namesplitHY)
if lSP == 1 and lHY == 1:
if lSP == lHY == 1:
if name != name.capitalize():
# Single surname without hyphen(s)
self.name_list.append(name)
@ -156,7 +156,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
namesep = '-'
namesplitSP = name.replace(namesep,' ').split()
lSP= len(namesplitSP)
if lSP == 1 and lHY == 1:
if lSP == lHY == 1:
#if name != name.capitalize():
# Single surname without space(s) or hyphen(s), normal case
return name.capitalize()

View File

@ -151,7 +151,7 @@ class Check(Tool.BatchTool):
if self.fail:
return
cli = uistate == None
cli = uistate is None
if self.db.readonly:
# TODO: split plugin in a check and repair part to support

View File

@ -120,7 +120,7 @@ class CalendarGramplet(Gramplet):
if birth_ref:
birth_event = self.gui.dbstate.db.get_event_from_handle(birth_ref.ref)
birth_date = birth_event.get_date_object()
if self.birthdays and birth_date != None:
if self.birthdays and birth_date is not None:
year = birth_date.get_year()
month = birth_date.get_month()
day = birth_date.get_day()
@ -909,7 +909,7 @@ class PythonGramplet(Gramplet):
buffer.place_cursor(end)
return True
_retval = self.process_command(line)
if _retval != None:
if _retval is not None:
self.append_text("%s\n" % str(_retval))
self.append_text("%s " % self.prompt)
end = buffer.get_end_iter()

View File

@ -180,7 +180,7 @@ class DetAncestorReport(Report):
for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
mother_handle = family.get_mother_handle()
if mother_handle == None or \
if mother_handle is None or \
person.get_gender() == gen.lib.Person.FEMALE:
if self.listchildren:
self.write_children(family)

View File

@ -258,7 +258,7 @@ class CSVWriter:
self.include_marriages = self.option_box.include_marriages
self.include_children = self.option_box.include_children
if self.option_box.cfilter == None:
if self.option_box.cfilter is None:
for p in self.db.get_person_handles(sort_handles=False):
self.plist[p] = 1
else:

View File

@ -156,7 +156,7 @@ class CalendarWriter:
else:
self.option_box.parse_options()
if self.option_box.cfilter == None:
if self.option_box.cfilter is None:
for p in self.db.get_person_handles(sort_handles=False):
self.plist[p] = 1
else:

View File

@ -145,7 +145,7 @@ class CardWriter:
else:
self.option_box.parse_options()
if self.option_box.cfilter == None:
if self.option_box.cfilter is None:
for p in self.db.get_person_handles(sort_handles=False):
self.plist[p] = 1
else:

View File

@ -407,7 +407,7 @@ class FamilyGroup(Report):
spouse_count = spouse_count + 1
self.doc.start_row()
if spouse_count != 0 or self.missingInfo or death != None or birth != None:
if spouse_count != 0 or self.missingInfo or death is not None or birth is not None:
self.doc.start_cell('FGR-TextChild1')
else:
self.doc.start_cell('FGR-TextChild2')
@ -431,13 +431,13 @@ class FamilyGroup(Report):
self.doc.end_cell()
self.doc.end_row()
if self.missingInfo or birth != None:
if spouse_count != 0 or self.missingInfo or death != None:
if self.missingInfo or birth is not None:
if spouse_count != 0 or self.missingInfo or death is not None:
self.dump_child_event('FGR-TextChild1',_('Birth'),birth)
else:
self.dump_child_event('FGR-TextChild2',_('Birth'),birth)
if self.missingInfo or death != None:
if self.missingInfo or death is not None:
if spouse_count == 0 or not self.incChiMar:
self.dump_child_event('FGR-TextChild2',_('Death'),death)
else:

View File

@ -579,8 +579,8 @@ class FamilyLinesReport(Report):
'xmlcharrefreplace')
# see if the spouse has parents
if spouse_father_handle == None and \
spouse_mother_handle == None:
if spouse_father_handle is None and \
spouse_mother_handle is None:
for family_handle in \
spouse.get_parent_family_handle_list():
family = self._db.get_family_from_handle(
@ -616,12 +616,12 @@ class FamilyLinesReport(Report):
# if this person has parents, then we automatically keep
# this person
if father_handle != None or mother_handle != None:
if father_handle is not None or mother_handle is not None:
continue
# if the spouse has parents, then we automatically keep
# this person
if spouse_father_handle != None or spouse_mother_handle != None:
if spouse_father_handle is not None or spouse_mother_handle is not None:
continue
# if this is a person of interest, then we automatically keep

View File

@ -345,12 +345,12 @@ class CSVParser:
return data
def lookup(self, type, id):
if id == None: return None
if id is None: return None
if type == "family":
if id.startswith("[") and id.endswith("]"):
id = id[1:-1]
db_lookup = self.db.get_family_from_gramps_id(id)
if db_lookup == None:
if db_lookup is None:
return self.lookup(type, id)
else:
return db_lookup
@ -362,7 +362,7 @@ class CSVParser:
if id.startswith("[") and id.endswith("]"):
id = id[1:-1]
db_lookup = self.db.get_person_from_gramps_id(id)
if db_lookup == None:
if db_lookup is None:
return self.lookup(type, id)
else:
return db_lookup
@ -408,7 +408,7 @@ class CSVParser:
header = None # clear headers, ready for next "table"
continue
######################################
if header == None:
if header is None:
header = map(cleanup_column_name, row)
col = {}
count = 0
@ -430,7 +430,7 @@ class CSVParser:
note = rd(line_number, row, col, "note")
wife = self.lookup("person", wife)
husband = self.lookup("person", husband)
if husband == None and wife == None:
if husband is None and wife is None:
# might have children, so go ahead and add
print "Warning: no parents on line %d; adding family anyway" % line_number
family = self.get_or_create_family(marriage_ref, husband, wife)
@ -475,7 +475,7 @@ class CSVParser:
elif "family" in header:
# family, child
family_ref = rd(line_number, row, col, "family")
if family_ref == None:
if family_ref is None:
print "Error: no family reference found for family on line %d" % line_number
continue # required
child = rd(line_number, row, col, "child")
@ -484,10 +484,10 @@ class CSVParser:
gender = rd(line_number, row, col, "gender")
child = self.lookup("person", child)
family = self.lookup("family", family_ref)
if family == None:
if family is None:
print "Error: no matching family reference found for family on line %d" % line_number
continue
if child == None:
if child is None:
print "Error: no matching child reference found for family on line %d" % line_number
continue
# is this child already in this family? If so, don't add
@ -557,8 +557,8 @@ class CSVParser:
#########################################################
# if this person already exists, don't create them
person = self.lookup("person", person_ref)
if person == None:
if surname == None:
if person is None:
if surname is None:
print "Warning: empty surname for new person on line %d" % line_number
surname = ""
# new person
@ -571,31 +571,31 @@ class CSVParser:
else:
name = person.get_primary_name()
#########################################################
if person_ref != None:
if person_ref is not None:
self.storeup("person", person_ref, person)
# replace
if callname != None:
if callname is not None:
name.set_call_name(callname)
if title != None:
if title is not None:
name.set_title(title)
if prefix != None:
if prefix is not None:
name.prefix = prefix
name.group_as = '' # HELP? what should I do here?
if suffix != None:
if suffix is not None:
name.set_suffix(suffix)
if note != None:
if note is not None:
# append notes, if previous notes
previous_notes = person.get_note()
if previous_notes != "":
if note not in previous_notes:
note = previous_notes + "\n" + note
person.set_note(note)
if grampsid != None:
if grampsid is not None:
person.gramps_id = grampsid
elif person_ref != None:
elif person_ref is not None:
if person_ref.startswith("[") and person_ref.endswith("]"):
person.gramps_id = person_ref[1:-1]
if person.get_gender() == gen.lib.Person.UNKNOWN and gender != None:
if person.get_gender() == gen.lib.Person.UNKNOWN and gender is not None:
gender = gender.lower()
if gender == gender_map[gen.lib.Person.MALE]:
gender = gen.lib.Person.MALE
@ -606,25 +606,25 @@ class CSVParser:
person.set_gender(gender)
#########################################################
# add if new, replace if different
if birthdate != None:
if birthdate is not None:
birthdate = _dp.parse(birthdate)
if birthplace != None:
if birthplace is not None:
new, birthplace = self.get_or_create_place(birthplace)
if birthsource != None:
if birthsource is not None:
new, birthsource = self.get_or_create_source(birthsource)
if birthdate or birthplace or birthsource:
new, birth = self.get_or_create_event(person, gen.lib.EventType.BIRTH, birthdate, birthplace, birthsource)
birth_ref = person.get_birth_ref()
if birth_ref == None:
if birth_ref is None:
# new
birth_ref = gen.lib.EventRef()
birth_ref.set_reference_handle( birth.get_handle())
person.set_birth_ref( birth_ref)
if deathdate != None:
if deathdate is not None:
deathdate = _dp.parse(deathdate)
if deathplace != None:
if deathplace is not None:
new, deathplace = self.get_or_create_place(deathplace)
if deathsource != None:
if deathsource is not None:
new, deathsource = self.get_or_create_source(deathsource)
if deathdate or deathplace or deathsource or deathcause:
new, death = self.get_or_create_event(person, gen.lib.EventType.DEATH, deathdate, deathplace, deathsource)
@ -632,7 +632,7 @@ class CSVParser:
death.set_description(deathcause)
self.db.commit_event(death, self.trans)
death_ref = person.get_death_ref()
if death_ref == None:
if death_ref is None:
# new
death_ref = gen.lib.EventRef()
death_ref.set_reference_handle(death.get_handle())

View File

@ -143,7 +143,7 @@ class GeneWebParser:
try:
while 1:
line = self.get_next_line()
if line == None:
if line is None:
break
if line == "":
continue
@ -238,7 +238,7 @@ class GeneWebParser:
rel_person = self.db.get_person_from_handle(self.current_relationship_person_handle)
while 1:
line = self.get_next_line()
if line == None or line == "end":
if line is None or line == "end":
break
if line == "":
continue
@ -315,7 +315,7 @@ class GeneWebParser:
return None
while 1:
line = self.get_next_line()
if line == None:
if line is None:
break
if line == "":
continue
@ -384,7 +384,7 @@ class GeneWebParser:
note_txt = ""
while True:
line = self.get_next_line()
if line == None:
if line is None:
break
fields = line.split(" ")
@ -529,7 +529,7 @@ class GeneWebParser:
name.set_first_name(firstname)
name.set_surname(surname)
person.set_primary_name(name)
if person.get_gender() == gen.lib.Person.UNKNOWN and gender != None:
if person.get_gender() == gen.lib.Person.UNKNOWN and gender is not None:
person.set_gender(gender)
self.db.commit_person(person,self.trans)
personDataRe = re.compile("^[kmes0-9<>~#\[({!].*$")

View File

@ -107,7 +107,7 @@ class VCardParser:
try:
while 1:
line = self.get_next_line()
if line == None:
if line is None:
break
if line == "":
continue

View File

@ -83,7 +83,7 @@ class IndivCompleteReport(Report):
def write_fact(self,event_ref):
event = self.database.get_event_from_handle(event_ref.ref)
if event == None:
if event is None:
return
text = ""
if event_ref.get_role() == gen.lib.EventRoleType.PRIMARY or \

Some files were not shown because too many files have changed in this diff Show More