Replace dict.has_key(x) with x in dict for performance gain

svn: r10874
This commit is contained in:
Gerald Britton 2008-07-17 18:10:32 +00:00
parent a6a264d1ce
commit 882199f1c2
80 changed files with 188 additions and 188 deletions
src
BaseDoc.py
Config
DataViews
DateHandler
DbLoader.pyDbManager.py
DisplayModels
FilterEditor
Filters
GrampsDbUtils
GrampsLogger
ListModel.py
Merge
Mime
Models
PageView.py
PluginUtils
Relationship.py
ReportBase
TipOfDay.pyUtils.pyViewManager.pyansel_utf8.py
docgen
gen
gramps.py
plugins
test
widgets

@ -1199,7 +1199,7 @@ class SheetParser(handler.ContentHandler):
self.f.set_underline(int(attrs['underline']))
self.f.set_color(cnv2color(attrs['color']))
elif tag == "para":
if attrs.has_key('description'):
if 'description' in attrs:
self.p.set_description(attrs['description'])
self.p.set_right_margin(Utils.gfloat(attrs['rmargin']))
self.p.set_right_margin(Utils.gfloat(attrs['rmargin']))

@ -75,7 +75,7 @@ class IniKeyClient:
data = {}
for sec in cp.sections():
name = sec.lower()
if not data.has_key(name):
if name not in data:
data[name] = {}
for opt in cp.options(sec):
data[name][opt.lower()] = cp.get(sec, opt).strip()

@ -1089,7 +1089,7 @@ class RelationshipView(PageView.PersonNavView):
"""
if button_activated(event, _LEFT_BUTTON):
person, handle = pair
if self.collapsed_items.has_key(person.handle):
if person.handle in self.collapsed_items:
if handle in self.collapsed_items[person.handle]:
self.collapsed_items[person.handle].remove(handle)
else:

@ -45,7 +45,7 @@ import _Date_sv
# Initialize global parser
try:
if LANG_TO_PARSER.has_key(LANG):
if LANG in LANG_TO_PARSER:
parser = LANG_TO_PARSER[LANG]()
else:
parser = LANG_TO_PARSER[LANG_SHORT]()
@ -64,7 +64,7 @@ except:
val = 0
try:
if LANG_TO_DISPLAY.has_key(LANG):
if LANG in LANG_TO_DISPLAY:
displayer = LANG_TO_DISPLAY[LANG](val)
else:
displayer = LANG_TO_DISPLAY[LANG_SHORT](val)

@ -431,7 +431,7 @@ def format_maker(formats):
"""
format_list = [ ('auto', _('Automatically detected')) ]
for format in formats:
if _KNOWN_FORMATS.has_key(format):
if format in _KNOWN_FORMATS:
format_list.append( (format, _KNOWN_FORMATS[format][0]) )
type_selector = GrampsFormatWidget()

@ -45,7 +45,7 @@ LOG = logging.getLogger(".DbManager")
if os.sys.platform == "win32":
_RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
if _RCS_FOUND and not os.environ.has_key("TZ"):
if _RCS_FOUND and "TZ" not in os.environ:
# RCS requires the "TZ" variable be set.
os.environ["TZ"] = str(time.timezone)
else:

@ -133,7 +133,7 @@ class NodeTreeMap:
return (self.top_iter2path[surname], index)
def has_entry(self, handle):
return self.iter2path.has_key(handle)
return handle in self.iter2path
def get_iter(self, path):
try:
@ -146,7 +146,7 @@ class NodeTreeMap:
return None
def has_top_node(self, node):
return self.sname_sub.has_key(node)
return node in self.sname_sub
def find_next_node(self, node):
try:
@ -167,7 +167,7 @@ class NodeTreeMap:
def has_child(self, node):
if node is None:
return len(self.sname_sub)
if self.sname_sub.has_key(node) and len(self.sname_sub[node]) > 0:
if node in self.sname_sub and len(self.sname_sub[node]) > 0:
return True
return False

@ -490,7 +490,7 @@ class EditRule(ManagedWindow.ManagedWindow):
t = MyFilters(self.filterdb.get_filters('Event'))
elif v == _('Source filter name:'):
t = MyFilters(self.filterdb.get_filters('Source'))
elif _name2typeclass.has_key(v):
elif v in _name2typeclass:
t = MySelect(_name2typeclass[v])
elif v == _('Inclusive:'):
t = MyBoolean(_('Include original person'))

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: $
# $Id$
#-------------------------------------------------------------------------
#

@ -79,5 +79,5 @@ class HasCommonAncestorWith(Rule):
handle = person.handle
return for_each_ancestor(
db,[handle],
lambda self, handle: self.ancestor_cache.has_key(handle),
lambda self, handle: handle in self.ancestor_cache,
self);

@ -60,7 +60,7 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith,MatchesFilter):
filt.prepare(db)
def init(self, h): self.ancestor_cache[h] = 1
for handle in db.get_person_handles(sort_handles=False):
if (not self.ancestor_cache.has_key (handle)
if (handle not in self.ancestor_cache
and filt.apply (db, db.get_person_from_handle(handle))):
for_each_ancestor(db,[handle],init,self)
filt.reset()

@ -68,7 +68,7 @@ class IsAncestorOf(Rule):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_ancestor_list(self,db,person,first):
if not person:

@ -77,4 +77,4 @@ class IsAncestorOfFilterMatch(IsAncestorOf,MatchesFilter):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map

@ -63,7 +63,7 @@ class IsChildOfFilterMatch(MatchesFilter):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_list(self,person):
if not person:

@ -68,7 +68,7 @@ class IsDescendantOf(Rule):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_list(self,person,first):
if not person:

@ -77,4 +77,4 @@ class IsDescendantOfFilterMatch(IsDescendantOf,MatchesFilter):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map

@ -62,10 +62,10 @@ class IsLessThanNthGenerationAncestorOf(Rule):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_ancestor_list(self, handle,gen):
# if self.map.has_key(p.get_handle()) == 1:
# if p.get_handle() in self.map:
# loop_error(self.orig,p)
if not handle:
return

@ -70,7 +70,7 @@ class IsLessThanNthGenerationAncestorOfBookmarked(Rule):
def init_ancestor_list(self, handle,gen):
# if self.map.has_key(p.get_handle()) == 1:
# if p.get_handle() in self.map:
# loop_error(self.orig,p)
if not handle:
return

@ -63,7 +63,7 @@ class IsLessThanNthGenerationAncestorOfDefaultPerson(Rule):
self.apply = lambda db,p: False
def init_ancestor_list(self, handle,gen):
# if self.map.has_key(p.get_handle()) == 1:
# if p.get_handle() in self.map:
# loop_error(self.orig,p)
if not handle:
return

@ -63,7 +63,7 @@ class IsLessThanNthGenerationDescendantOf(Rule):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_list(self,person,gen):
if not person:

@ -62,10 +62,10 @@ class IsMoreThanNthGenerationAncestorOf(Rule):
self.map = []
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_ancestor_list(self, handle,gen):
# if self.map.has_key(p.get_handle()) == 1:
# if p.get_handle() in self.map:
# loop_error(self.orig,p)
if not handle:
return

@ -63,7 +63,7 @@ class IsMoreThanNthGenerationDescendantOf(Rule):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_list(self,person,gen):
if not person:

@ -63,7 +63,7 @@ class IsParentOfFilterMatch(MatchesFilter):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_list(self,person):
for fam_id in person.get_parent_family_handle_list():

@ -62,7 +62,7 @@ class IsSiblingOfFilterMatch(MatchesFilter):
self.map = {}
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_list(self,person):
if not person:

@ -89,7 +89,7 @@ class RelationshipPathBetween(Rule):
self.apply_filter(rank+1,family.get_mother_handle(),plist,pmap)
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map
def init_list(self,p1_handle,p2_handle):
firstMap = {}
@ -129,5 +129,5 @@ class RelationshipPathBetween(Rule):
def get_intersection(self,target, map1, map2):
for e in map1.keys():
if map2.has_key(e):
if e in map2:
target[e] = map2[e]

@ -172,6 +172,6 @@ class RelationshipPathBetweenBookmarks(Rule):
pass
def apply(self,db,person):
return self.map.has_key(person.handle)
return person.handle in self.map

@ -57,7 +57,7 @@ class FilterParser(handler.ContentHandler):
def startElement(self, tag, attrs):
if tag == "object":
if attrs.has_key('type'):
if 'type' in attrs:
self.namespace = attrs['type']
if self.namespace == 'Media':
self.namespace = 'MediaObject'
@ -66,7 +66,7 @@ class FilterParser(handler.ContentHandler):
elif tag == "filter":
self.f = GenericFilterFactory(self.namespace)()
self.f.set_name(attrs['name'])
if attrs.has_key('function'):
if 'function' in attrs:
try:
if int(attrs['function']):
op = 'or'
@ -75,9 +75,9 @@ class FilterParser(handler.ContentHandler):
except ValueError:
op = attrs['function']
self.f.set_logical_op(op)
if attrs.has_key('invert'):
if 'invert' in attrs:
self.f.set_invert(attrs['invert'])
if attrs.has_key('comment'):
if 'comment' in attrs:
self.f.set_comment(attrs['comment'])
self.gfilter_list.add(self.namespace, self.f)
elif tag == "rule":

@ -237,12 +237,12 @@ class GedcomDescription:
self.tag2gramps_map[tag] = value
def gramps2tag(self,key):
if self.gramps2tag_map.has_key(key):
if key in self.gramps2tag_map:
return self.gramps2tag_map[key]
return ""
def tag2gramps(self,key):
if self.tag2gramps_map.has_key(key):
if key in self.tag2gramps_map:
return self.tag2gramps_map[key]
return key
@ -267,7 +267,7 @@ class GedcomInfoDB:
self.map[name] = obj
def get_description(self, name):
if self.map.has_key(name):
if name in self.map:
return self.map[name]
return self.standard

@ -2827,7 +2827,7 @@ class GedcomParser(UpdateCallback):
@type state: CurrentState
"""
if state.event.get_type().is_custom():
if GED_2_GRAMPS.has_key(line.data):
if line.data in GED_2_GRAMPS:
name = gen.lib.EventType(GED_2_GRAMPS[line.data])
else:
val = self.gedsource.tag2gramps(line.data)
@ -2842,8 +2842,8 @@ class GedcomParser(UpdateCallback):
state.event.set_type(name)
else:
try:
if not GED_2_GRAMPS.has_key(line.data) and \
not GED_2_FAMILY.has_key(line.data) and \
if line.data not in GED_2_GRAMPS and \
line.data not in GED_2_FAMILY and \
line.data[0] != 'Y':
state.event.set_description(line.data)
except IndexError:
@ -3802,7 +3802,7 @@ class GedcomParser(UpdateCallback):
@type state: CurrentState
"""
if state.attr.get_type() == "":
if GED_2_GRAMPS.has_key(line.data):
if line.data in GED_2_GRAMPS:
name = GED_2_GRAMPS[line.data]
else:
val = self.gedsource.tag2gramps(line.data)

@ -79,7 +79,7 @@ def add_to_list(table, key, value):
Add the value to the table entry associated with key. If the entry
does not exist, it is added.
"""
if table.has_key(key):
if key in table:
table[key].append(value)
else:
table[key] = [value]

@ -183,7 +183,7 @@ class IdMapper:
def get_translate(self, gid):
gid = self.clean(gid)
if self.swap.has_key(gid):
if gid in self.swap:
return self.swap[gid]
else:
if self.trans.get(str(gid)):

@ -477,7 +477,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
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'):
elif 'version' not in self.metadata:
# Not new database, but the version is missing.
# Use 0, but it is likely to fail anyway.
self.metadata.put('version', 0, txn=the_txn)
@ -874,7 +874,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
# from the primary object 'obj, or any of its secondary objects.
handle = obj.handle
update = self.reference_map_primary_map.has_key(str(handle))
update = str(handle) in self.reference_map_primary_map
if update:
# First thing to do is get hold of all rows in the reference_map
@ -1330,7 +1330,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
pass
def __get_obj_from_gramps_id(self, val, tbl, class_init, prim_tbl):
if tbl.has_key(str(val)):
if str(val) in tbl:
data = tbl.get(str(val), txn=self.txn)
obj = class_init()
### FIXME: this is a dirty hack that works without no
@ -1476,7 +1476,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
obj = class_type()
hndl = str(hndl)
new = True
if dmap.has_key(hndl):
if hndl in dmap:
data = dmap.get(hndl, txn=self.txn)
obj.unserialize(data)
#references create object with id None before object is really made

@ -884,7 +884,7 @@ class GrampsParser(UpdateCallback):
# Parse witnesses created by older gramps
self.in_witness = True
self.witness_comment = ""
if attrs.has_key('name'):
if 'name' in attrs:
note = gen.lib.Note()
note.handle = Utils.create_id()
note.set(_("Witness name: %s") % attrs['name'])
@ -901,7 +901,7 @@ class GrampsParser(UpdateCallback):
handle = attrs['hlink'].replace('_', '')
person, new = self.db.find_person_from_handle(handle, self.trans)
except KeyError:
if attrs.has_key('ref'):
if 'ref' in attrs:
person, new = self.find_person_by_gramps_id(
self.map_gid(attrs["ref"]))
else:
@ -955,7 +955,7 @@ class GrampsParser(UpdateCallback):
self.eventref = gen.lib.EventRef()
self.eventref.ref = attrs['hlink'].replace('_', '')
self.eventref.private = bool(attrs.get('priv'))
if attrs.has_key('role'):
if 'role' in attrs:
self.eventref.role.set_from_xml_str(attrs['role'])
# We count here on events being already parsed prior to parsing
@ -984,7 +984,7 @@ class GrampsParser(UpdateCallback):
self.attribute = gen.lib.Attribute()
self.attribute.private = bool(attrs.get("priv"))
self.attribute.type = gen.lib.AttributeType()
if attrs.has_key('type'):
if 'type' in attrs:
self.attribute.type.set_from_xml_str(attrs["type"])
self.attribute.value = attrs.get("value", '')
if self.photo:
@ -1071,7 +1071,7 @@ class GrampsParser(UpdateCallback):
self.name_formats.append((number, name, fmt_str, active))
def remap_name_format(self, old_number):
if self.name_formats_map.has_key(old_number): # This should not happen
if old_number in self.name_formats_map: # This should not happen
return self.name_formats_map[old_number]
# Find the lowest new number not taken yet:
new_number = -1
@ -1109,7 +1109,7 @@ class GrampsParser(UpdateCallback):
self.person.marker.set_from_xml_str(attrs.get("marker", ''))
def start_people(self, attrs):
if attrs.has_key('home'):
if 'home' in attrs:
self.home = attrs['home'].replace('_', '')
def start_father(self, attrs):
@ -1144,7 +1144,7 @@ class GrampsParser(UpdateCallback):
# Here we are handling the old XML, in which
# frel and mrel belonged to the "childof" tag
# If that were the case then childref_map has the childref ready
if self.childref_map.has_key((self.family.handle, handle)):
if (self.family.handle, handle) in self.childref_map:
self.family.add_child_ref(
self.childref_map[(self.family.handle, handle)])
@ -1176,7 +1176,7 @@ class GrampsParser(UpdateCallback):
self.person.add_person_ref(self.personref)
def start_url(self, attrs):
if not attrs.has_key("href"):
if "href" not in attrs:
return
url = gen.lib.Url()
url.path = attrs["href"]
@ -1211,7 +1211,7 @@ class GrampsParser(UpdateCallback):
# GRAMPS LEGACY: the type now belongs to <rel> tag
# Here we need to support old format of <family type="Married">
if attrs.has_key('type'):
if 'type' in attrs:
self.family.type.set_from_xml_str(attrs["type"])
# Old and new markers: complete=1 and marker=word both have to work
@ -1221,12 +1221,12 @@ class GrampsParser(UpdateCallback):
self.family.marker.set_from_xml_str(attrs.get("marker", ''))
def start_rel(self, attrs):
if attrs.has_key('type'):
if 'type' in attrs:
self.family.type.set_from_xml_str(attrs["type"])
def start_file(self, attrs):
self.object.mime = attrs['mime']
if attrs.has_key('description'):
if 'description' in attrs:
self.object.desc = attrs['description']
else:
self.object.desc = ""
@ -1251,9 +1251,9 @@ class GrampsParser(UpdateCallback):
# frel and mrel belonged to the "childof" tag
mrel = gen.lib.ChildRefType()
frel = gen.lib.ChildRefType()
if attrs.has_key('mrel'):
if 'mrel' in attrs:
mrel.set_from_xml_str(attrs['mrel'])
if attrs.has_key('frel'):
if 'frel' in attrs:
frel.set_from_xml_str(attrs['frel'])
childref = gen.lib.ChildRef()
@ -1292,11 +1292,11 @@ class GrampsParser(UpdateCallback):
# check if these pointers need to be remapped
# and set the name attributes
if self.name_formats_map.has_key(sort_as):
if sort_as in self.name_formats_map:
self.name.sort_as = self.name_formats_map[sort_as]
else:
self.name.sort_as = sort_as
if self.name_formats_map.has_key(display_as):
if display_as in self.name_formats_map:
self.name.sort_as = self.name_formats_map[display_as]
else:
self.name_display_as = display_as
@ -1739,12 +1739,12 @@ class GrampsParser(UpdateCallback):
except:
rng_day = 0
if attrs.has_key("cformat"):
if "cformat" in attrs:
cal = gen.lib.Date.calendar_names.index(attrs['calendar'])
else:
cal = gen.lib.Date.CAL_GREGORIAN
if attrs.has_key('quality'):
if 'quality' in attrs:
val = attrs['quality']
if val == 'estimated':
qual = gen.lib.Date.QUAL_ESTIMATED
@ -1794,12 +1794,12 @@ class GrampsParser(UpdateCallback):
except:
day = 0
if attrs.has_key("cformat"):
if "cformat" in attrs:
cal = gen.lib.Date.calendar_names.index(attrs['cformat'])
else:
cal = gen.lib.Date.CAL_GREGORIAN
if attrs.has_key('type'):
if 'type' in attrs:
val = attrs['type']
if val == "about":
mod = gen.lib.Date.MOD_ABOUT
@ -1810,7 +1810,7 @@ class GrampsParser(UpdateCallback):
else:
mod = gen.lib.Date.MOD_NONE
if attrs.has_key('quality'):
if 'quality' in attrs:
val = attrs['quality']
if val == 'estimated':
qual = gen.lib.Date.QUAL_ESTIMATED
@ -1840,11 +1840,11 @@ class GrampsParser(UpdateCallback):
date_value.set_as_text(attrs['val'])
def start_created(self, attrs):
if attrs.has_key('sources'):
if 'sources' in attrs:
self.num_srcs = int(attrs['sources'])
else:
self.num_srcs = 0
if attrs.has_key('places'):
if 'places' in attrs:
self.num_places = int(attrs['places'])
else:
self.num_places = 0
@ -2039,7 +2039,7 @@ class GrampsParser(UpdateCallback):
##handle = None
##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):
## if tag in self.place_map:
## place = self.place_map[tag]
## handle = place.get_handle()
## place = None
@ -2377,10 +2377,10 @@ class VersionParser:
def __element_handler(self, tag, attrs):
" Handle XML elements "
if tag == "database" and attrs.has_key('xmlns'):
if tag == "database" and 'xmlns' in attrs:
xmlns = attrs.get('xmlns')
self.__xml_version = xmlns.split('/')[4]
elif tag == "created" and attrs.has_key('version'):
elif tag == "created" and 'version' in attrs:
self.__gramps_version = attrs.get('version')
def get_xmlns_version(self):

@ -210,10 +210,10 @@ def make_date(subdate, calendar, mode, quality):
if prefix:
retval = "%s %s" % (prefix, retval)
if DATE_MODIFIER.has_key(mode):
if mode in DATE_MODIFIER:
retval = "%s %s" % (DATE_MODIFIER[mode], retval)
if DATE_QUALITY.has_key(quality):
if quality in DATE_QUALITY:
retval = "%s %s" % (DATE_QUALITY[quality], retval)
return retval

@ -247,7 +247,7 @@ def import_table(id_table, add_obj, find_next_gramps_id,
# Then we check gramps_id for conflicts and change it if needed
gramps_id = str(obj.gramps_id)
if id_table.has_key(gramps_id):
if gramps_id in id_table:
gramps_id = find_next_gramps_id()
obj.gramps_id = gramps_id
add_obj(obj, trans)

@ -54,7 +54,7 @@ class ErrorReportAssistant:
self.w.show()
def on_page_changed(self, obj,page,data=None):
if self.cb.has_key(page):
if page in self.cb:
self.cb[page]()
def complete(self):

@ -160,7 +160,7 @@ class ListModel:
Callback executed when the text of the cell renderer has changed
"""
self.model[path][col] = new_text
if self.function.has_key(col):
if col in self.function:
self.function[col](int(path), new_text)
def unselect(self):

@ -150,7 +150,7 @@ class MergeSources(ManagedWindow.ManagedWindow):
src2_map = self.s2.get_data_map()
src1_map = self.s1.get_data_map()
for key in src2_map.keys():
if not src1_map.has_key(key):
if key not in src1_map:
src1_map[key] = src2_map[key]
# replace references in other objetcs

@ -64,7 +64,7 @@ def mime_type_is_defined(mime_type):
"""
Return True if a description for a mime type exists.
"""
return _type_map.has_key(mime_type)
return mime_type in _type_map
def find_mime_type_pixbuf(mime_type):
return gtk.gdk.pixbuf_new_from_file(const.ICON)

@ -153,7 +153,7 @@ def _get_extension(mime_type):
'application/abiword' : '.abw',
'application/rtf' : '.rtf',
}
if extmap.has_key(mime_type):
if mime_type in extmap:
extension = extmap[mime_type]
return extension

@ -132,7 +132,7 @@ class FastModel(gtk.GenericTreeModel):
# If we are at the second level we first check to see if we
# have the number of children of this row already in the cache
if not self._num_children_cache.has_key(rowref[0]):
if rowref[0] not in self._num_children_cache:
# If not calculate the number of children and put it in the cache.
self._num_children_cache[rowref[0]] = self._cursor.get_n_children([rowref[0],])
@ -179,7 +179,7 @@ class FastModel(gtk.GenericTreeModel):
if rowref:
# If we are at the second level we first check to see if we
# have the number of children of this row already in the cache
if not self._num_children_cache.has_key(rowref[0]):
if rowref[0] not in self._num_children_cache:
# If not calculate the number of children and put it in the cache.
self._num_children_cache[rowref[0]] = self._cursor.get_n_children([rowref[0],])

@ -108,7 +108,7 @@ class ListCursor(object):
"""
# See if the record is in the cache.
if self._object_cache.has_key(index) and use_cache:
if index in self._object_cache and use_cache:
ret = self._object_cache[index]
# If the record is not in the cache or we are ignoring the

@ -167,7 +167,7 @@ class PathCursor(object):
"""
# See if the record is in the cache.
if self._object_cache.has_key(index) and use_cache:
if index in self._object_cache and use_cache:
ret = self._object_cache[index]['primary']
# If the record is not in the cache or we are ignoring the
@ -262,8 +262,8 @@ class PathCursor(object):
# First check to see if the record has already
# been fetched.
if self._object_cache.has_key(path[0]) and \
self._object_cache[path[0]].has_key(path[1]):
if path[0] in self._object_cache and \
path[1] in self._object_cache[path[0]]:
# return record from cache.
ret = self._object_cache[path[0]][path[1]]

@ -812,7 +812,7 @@ class ListView(BookMarkView):
for pair in [pair for pair in self.column_order() if pair[0]]:
name = self.colinfo[pair[1]]
if self.model and self.model.__dict__.has_key('marker_color_column'):
if self.model and 'marker_color_column' in self.model.__dict__:
mcol = self.model.marker_color_column
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1],
foreground=mcol)

@ -699,7 +699,7 @@ class Menu:
@type option: Option
@return: nothing
"""
if not self.__options.has_key(category):
if category not in self.__options:
self.__categories.append(category)
self.__options[category] = []
self.__options[category].append((name, option))

@ -96,7 +96,7 @@ class OptionList:
@param name: name of the option to remove.
@type name: str
"""
if self.options.has_key(name):
if name in self.options:
del self.options[name]
def get_option(self, name):
@ -268,7 +268,7 @@ class OptionParser(handler.ContentHandler):
self.o = {}
elif tag == "option":
self.oname = attrs['name']
if attrs.has_key('length'):
if 'length' in attrs:
self.an_o = []
else:
self.an_o = attrs['value']
@ -335,7 +335,7 @@ class OptionHandler:
options = self.saved_option_list.get_options()
bad_opts = []
for option_name in options.keys():
if not self.options_dict.has_key(option_name):
if option_name not in self.options_dict:
print "Option %s is present in the %s but is not known "\
"to the module." % (option_name,
self.option_list_collection.filename)

@ -160,7 +160,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
store, node = self.selection.get_selected()
if node:
path = store.get_path(node)
if not node or not self.imap.has_key(path):
if not node or path not in self.imap:
return
data = self.imap[path]
@ -200,7 +200,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
category = _UNSUPPORTED
else:
category = categories[plugin[3]]
if item_hash.has_key(category):
if category in item_hash:
item_hash[category].append(plugin)
else:
item_hash[category] = [plugin]
@ -212,7 +212,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
key_list.reverse()
prev = None
if item_hash.has_key(_UNSUPPORTED):
if _UNSUPPORTED in item_hash:
key = _UNSUPPORTED
data = item_hash[key]
node = self.store.insert_after(None, prev)

@ -400,7 +400,7 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
before the report executes. This task should only be called in
the add_user_options task."""
if self.frames.has_key(frame_name):
if frame_name in self.frames:
self.frames[frame_name].append((label_text, widget))
else:
self.frames[frame_name] = [(label_text, widget)]

@ -803,7 +803,7 @@ class RelationshipCalculator:
self.map_handle = orig_person.handle
for person_handle in secondMap.keys() :
if firstMap.has_key(person_handle) :
if person_handle in firstMap :
com = []
#a common ancestor
for rel1, fam1 in zip(firstMap[person_handle][0],
@ -903,13 +903,13 @@ class RelationshipCalculator:
store = True #normally we store all parents
if stoprecursemap:
store = False #but not if a stop map given
if stoprecursemap.has_key(person.handle):
if person.handle in stoprecursemap:
commonancestor = True
store = True
#add person to the map, take into account that person can be obtained
#from different sides
if pmap.has_key(person.handle):
if person.handle in pmap:
#person is already a grandparent in another branch, we already have
# had lookup of all parents, we call that a crosslink
if not stoprecursemap:
@ -997,7 +997,7 @@ class RelationshipCalculator:
if ref.ref != person.handle]
addstr = self.REL_SIBLING
for chandle in child_list :
if pmap.has_key(chandle) :
if chandle in pmap :
pmap[chandle][0] += [rel_str + addstr]
pmap[chandle][1] += [rel_fam_new]
#person is already a grandparent in another branch

@ -186,7 +186,7 @@ class DocReportDialog(ReportDialog):
def html_file_enable(self, obj):
active = obj.get_active()
text = unicode(obj.get_model()[active][0])
if _template_map.has_key(text):
if text in _template_map:
if _template_map[text]:
self.html_fileentry.set_sensitive(0)
else:
@ -266,7 +266,7 @@ class DocReportDialog(ReportDialog):
model = self.template_combo.get_model()
text = unicode(model[self.template_combo.get_active()][0])
if _template_map.has_key(text):
if text in _template_map:
if text == _user_template:
self.template_name = self.html_fileentry.get_full_path(0)
else:

@ -236,7 +236,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
before the report executes. This task should only be called in
the add_user_options task."""
if self.frames.has_key(frame_name):
if frame_name in self.frames:
self.frames[frame_name].append((label_text, widget))
else:
self.frames[frame_name] = [(label_text, widget)]
@ -389,7 +389,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
row = row + 1
def setup_main_options(self):
if self.frames.has_key(""):
if "" in self.frames:
flist = self.frames[""]
for (text, widget) in flist:
label = gtk.Label("<b>%s</b>" % text)

@ -167,7 +167,7 @@ class TipParser:
self.tlist = []
# Skip all tips with xml:lang attribute, as they are
# already in the translation catalog
self.skip = attrs.has_key('xml:lang')
self.skip = 'xml:lang' in attrs
elif tag != "tips":
# let all the other tags through, except for the "tips" tag
self.tlist.append("<%s>" % tag)

@ -1114,7 +1114,7 @@ def launch(prog_str, path):
if len(prog_data) > 1:
for item in prog_data:
if subval.has_key(item):
if item in subval:
need_path = False
value = subval[item]
else:

@ -1386,7 +1386,7 @@ class ViewManager:
category = _UNSUPPORTED
else:
category = categories[item[3]]
if hash_data.has_key(category):
if category in hash_data:
hash_data[category].append(
(item[0], item[1], item[2], item[4], item[3], item[10]))
else:
@ -1413,7 +1413,7 @@ class ViewManager:
# If there are any unsupported items we add separator
# and the unsupported category at the end of the menu
if hash_data.has_key(_UNSUPPORTED):
if _UNSUPPORTED in hash_data:
ofile.write('<separator/>')
ofile.write('<menu action="%s">' % _UNSUPPORTED)
actions.append((_UNSUPPORTED, None, _UNSUPPORTED))

@ -332,10 +332,10 @@ def ansel_to_utf8(s):
head = ' '
s = s[1:]
else:
if _twobyte.has_key(s[0:2]):
if s[0:2] in _twobyte:
head = _twobyte[s[0:2]]
s = s[2:]
elif _onebyte.has_key(s[0]):
elif s[0] in _onebyte:
head = _onebyte[s[0]]
s = s[1:]
elif s[0] in _acombiners.keys():

@ -132,7 +132,7 @@ def paperstyle_to_pagesetup(paper_style):
# All sizes not included in the translation table (even if a standard size)
# are handled as custom format, because we are not intelligent enough.
if gramps_to_gtk.has_key(gramps_paper_name):
if gramps_paper_name in gramps_to_gtk:
paper_size = gtk.PaperSize(gramps_to_gtk[gramps_paper_name])
log.debug("Selected paper size: %s" % gramps_to_gtk[gramps_paper_name])
else:
@ -257,7 +257,7 @@ class PrintPreview:
##log.debug("Page number %d doesn't exist." % page_no)
##page_no = 0
##if not self._page_surfaces.has_key(page_no):
##if page_no not in self._page_surfaces:
##surface = self.create_surface()
##cr = cairo.Context(surface)

@ -100,11 +100,11 @@ class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
style = style_sheet.get_paragraph_style(style_name)
fgcolor = style.get_font().get_color()
bgcolor = style.get_background_color()
if not self.color_map.has_key(fgcolor):
if fgcolor not in self.color_map:
self.color_map[fgcolor] = index
self.f.write('\\red%d\\green%d\\blue%d;' % fgcolor)
index = index + 1
if not self.color_map.has_key(bgcolor):
if bgcolor not in self.color_map:
self.f.write('\\red%d\\green%d\\blue%d;' % bgcolor)
self.color_map[bgcolor] = index
index = index + 1

@ -650,7 +650,7 @@ class GrampsDbBase(Callback):
person ID prefix.
"""
index = self.person_prefix % self.pmap_index
while self.id_trans.has_key(str(index)):
while str(index) in self.id_trans:
self.pmap_index += 1
index = self.person_prefix % self.pmap_index
self.pmap_index += 1
@ -662,7 +662,7 @@ class GrampsDbBase(Callback):
place ID prefix.
"""
index = self.place_prefix % self.lmap_index
while self.pid_trans.has_key(str(index)):
while str(index) in self.pid_trans:
self.lmap_index += 1
index = self.place_prefix % self.lmap_index
self.lmap_index += 1
@ -674,7 +674,7 @@ class GrampsDbBase(Callback):
event ID prefix.
"""
index = self.event_prefix % self.emap_index
while self.eid_trans.has_key(str(index)):
while str(index) in self.eid_trans:
self.emap_index += 1
index = self.event_prefix % self.emap_index
self.emap_index += 1
@ -686,7 +686,7 @@ class GrampsDbBase(Callback):
off the media object ID prefix.
"""
index = self.mediaobject_prefix % self.omap_index
while self.oid_trans.has_key(str(index)):
while str(index) in self.oid_trans:
self.omap_index += 1
index = self.mediaobject_prefix % self.omap_index
self.omap_index += 1
@ -698,7 +698,7 @@ class GrampsDbBase(Callback):
source ID prefix.
"""
index = self.source_prefix % self.smap_index
while self.sid_trans.has_key(str(index)):
while str(index) in self.sid_trans:
self.smap_index += 1
index = self.source_prefix % self.smap_index
self.smap_index += 1
@ -710,7 +710,7 @@ class GrampsDbBase(Callback):
family ID prefix.
"""
index = self.family_prefix % self.fmap_index
while self.fid_trans.has_key(str(index)):
while str(index) in self.fid_trans:
self.fmap_index += 1
index = self.family_prefix % self.fmap_index
self.fmap_index += 1
@ -722,7 +722,7 @@ class GrampsDbBase(Callback):
off the repository ID prefix.
"""
index = self.repository_prefix % self.rmap_index
while self.rid_trans.has_key(str(index)):
while str(index) in self.rid_trans:
self.rmap_index += 1
index = self.repository_prefix % self.rmap_index
self.rmap_index += 1
@ -734,7 +734,7 @@ class GrampsDbBase(Callback):
note ID prefix.
"""
index = self.note_prefix % self.nmap_index
while self.nid_trans.has_key(str(index)):
while str(index) in self.nid_trans:
self.nmap_index += 1
index = self.note_prefix % self.nmap_index
self.nmap_index += 1
@ -826,7 +826,7 @@ class GrampsDbBase(Callback):
obj = class_type()
handle = str(handle)
new = True
if dmap.has_key(handle):
if handle in dmap:
obj.unserialize(dmap.get(handle))
#references create object with id None before object is really made
if obj.gramps_id is not None:
@ -839,7 +839,7 @@ class GrampsDbBase(Callback):
def __check_from_handle(self, handle, transaction, class_type, dmap,
add_func, set_gid=True):
handle = str(handle)
if not dmap.has_key(handle):
if handle not in dmap:
obj = class_type()
obj.set_handle(handle)
add_func(obj, transaction, set_gid=set_gid)
@ -1283,7 +1283,7 @@ class GrampsDbBase(Callback):
"""
Return if a key exists in the name_group table.
"""
return self.name_group.has_key(str(name))
return str(name) in self.name_group
def set_name_group_mapping(self, name, group):
"""
@ -1483,7 +1483,7 @@ class GrampsDbBase(Callback):
}
table = key2table[obj_key]
return table.has_key(str(gramps_id))
return str(gramps_id) in table
def find_initial_person(self):
person = self.get_default_person()
@ -1814,7 +1814,7 @@ class GrampsDbBase(Callback):
self.emit(signal_root + '-delete', ([handle], ))
del db_map[handle]
else:
if db_map.has_key(handle):
if handle in db_map:
signal = signal_root + '-update'
else:
signal = signal_root + '-add'
@ -2191,49 +2191,49 @@ class GrampsDbBase(Callback):
"""
Return True if the handle exists in the current Person database.
"""
return self.person_map.has_key(str(handle))
return str(handle) in self.person_map
def has_event_handle(self, handle):
"""
Return True if the handle exists in the current Event database.
"""
return self.event_map.has_key(str(handle))
return str(handle) in self.event_map
def has_source_handle(self, handle):
"""
Return True if the handle exists in the current Source database.
"""
return self.source_map.has_key(str(handle))
return str(handle) in self.source_map
def has_place_handle(self, handle):
"""
Return True if the handle exists in the current Place database.
"""
return self.place_map.has_key(str(handle))
return str(handle) in self.place_map
def has_family_handle(self, handle):
"""
Return True if the handle exists in the current Family database.
"""
return self.family_map.has_key(str(handle))
return str(handle) in self.family_map
def has_object_handle(self, handle):
"""
Return True if the handle exists in the current MediaObjectdatabase.
"""
return self.media_map.has_key(str(handle))
return str(handle) in self.media_map
def has_repository_handle(self, handle):
"""
Return True if the handle exists in the current Repository database.
"""
return self.repository_map.has_key(str(handle))
return str(handle) in self.repository_map
def has_note_handle(self, handle):
"""
Return True if the handle exists in the current Note database.
"""
return self.note_map.has_key(str(handle))
return str(handle) in self.note_map
def __sortbyplace(self, first, second):
return locale.strcoll(self.place_map.get(str(first))[2],

@ -540,7 +540,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
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'):
elif 'version' not in self.metadata:
# Not new database, but the version is missing.
# Use 0, but it is likely to fail anyway.
self.metadata.put('version', 0, txn=the_txn)
@ -930,7 +930,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
# from the primary object 'obj' or any of its secondary objects.
handle = obj.handle
update = self.reference_map_primary_map.has_key(str(handle))
update = str(handle) in self.reference_map_primary_map
if update:
# First thing to do is get hold of all rows in the reference_map
@ -1373,7 +1373,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
def __get_obj_from_gramps_id(self, val, tbl, class_init, prim_tbl):
try:
if tbl.has_key(str(val)):
if str(val) in tbl:
data = tbl.get(str(val), txn=self.txn)
obj = class_init()
### FIXME: this is a dirty hack that works without no
@ -1532,7 +1532,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
obj = class_type()
handle = str(handle)
new = True
if dmap.has_key(handle):
if handle in dmap:
data = dmap.get(handle, txn=self.txn)
obj.unserialize(data)
#references create object with id None before object is really made

@ -60,7 +60,7 @@ class GenderStats:
return name.split (' ')[0].replace ('?', '')
def name_stats (self, name):
if self.stats.has_key (name):
if name in self.stats:
return self.stats[name]
return (0, 0, 0)
@ -95,7 +95,7 @@ class GenderStats:
def guess_gender (self, name):
name = self._get_key_from_name (name)
if not name or not self.stats.has_key (name):
if not name or name not in self.stats:
return Person.UNKNOWN
(male, female, unknown) = self.stats[name]

@ -158,7 +158,7 @@ class GrampsType(object):
This method sets the type instance based on the untranslated string
(obtained e.g. from XML).
"""
if self._E2IMAP.has_key(value):
if value in self._E2IMAP:
self.__value = self._E2IMAP[value]
self.__string = u''
else:

@ -29,7 +29,7 @@ import traceback
import locale
import gettext
if os.environ.has_key("GRAMPSI18N"):
if "GRAMPSI18N" in os.environ:
loc = os.environ["GRAMPSI18N"]
else:
loc = "/usr/share/locale"

@ -239,7 +239,7 @@ class Callback(object):
"""A traversal function to walk through all the classes in
the inheritance tree. The return is a list of all the
__signals__ dictionaries."""
if cls.__dict__.has_key('__signals__'):
if '__signals__' in cls.__dict__:
signal_list = [cls.__signals__]
else:
signal_list = []
@ -254,7 +254,7 @@ class Callback(object):
# Build a signal dict from the list of signal dicts
for s in trav(self.__class__):
for (k, v) in s.items():
if self.__signal_map.has_key(k):
if k in self.__signal_map:
# signal name clash
sys.stderr.write("Warning: signal name clash: %s\n" % str(k))
self.__signal_map[k] = v

@ -62,7 +62,7 @@ gobject.threads_init()
# Load internationalization setup
#
#-------------------------------------------------------------------------
if os.environ.has_key("GRAMPSI18N"):
if "GRAMPSI18N" in os.environ:
loc = os.environ["GRAMPSI18N"]
elif os.path.exists( os.path.join(const.ROOT_DIR, "lang") ):
loc = os.path.join(const.ROOT_DIR, "lang")

@ -524,7 +524,7 @@ class BookParser(handler.ContentHandler):
self.o = {}
elif tag == "option":
self.an_o_name = attrs['name']
if attrs.has_key('length'):
if 'length' in attrs:
self.an_o_value = []
else:
converter = Utils.get_type_converter_by_name(attrs['type'])
@ -1165,7 +1165,7 @@ def cl_report(database, name, category, options_str_dict):
if clr.show:
return
if not clr.options_dict.has_key('bookname'):
if 'bookname' not in clr.options_dict:
print "Please Specify a book name"
return

@ -73,7 +73,7 @@ class GenChart:
self.max_y = 0
def get_xy(self,x,y):
if not self.array.has_key(y):
if y not in self.array:
return 0
return self.array[y].get(x,0)
@ -81,7 +81,7 @@ class GenChart:
self.max_x = max(self.max_x,x)
self.max_y = max(self.max_y,y)
if not self.array.has_key(y):
if y not in self.array:
self.array[y] = {}
self.array[y][x] = value

@ -423,7 +423,7 @@ class DetDescendantReport(Report):
ReportUtils.roman(cnt).lower() + ".")
cnt += 1
if self.henry.has_key(child_handle):
if child_handle in self.henry:
self.doc.write_text("%s [%s]. " % (child_name,
self.henry[child_handle]),
child_mark )

@ -114,9 +114,9 @@ class EndOfLineReport(Report):
if person_is_eol:
# This person is the end of a line
person_handle = person.get_handle()
if not self.eol_map.has_key(gen):
if gen not in self.eol_map:
self.eol_map[gen] = {}
if not self.eol_map[gen].has_key(person_handle):
if person_handle not in self.eol_map[gen]:
self.eol_map[gen][person_handle] = []
self.eol_map[gen][person_handle].append( list(pedigree) )

@ -304,7 +304,7 @@ class DisplayChart(ManagedWindow.ManagedWindow):
for ievent_ref in individual.get_event_ref_list():
ievent = self.db.get_event_from_handle(ievent_ref.ref)
event_name = str(ievent.get_type())
if the_map.has_key(event_name):
if event_name in the_map:
the_map[event_name].append(ievent_ref.ref)
else:
the_map[event_name] = [ievent_ref.ref]
@ -318,7 +318,7 @@ class DisplayChart(ManagedWindow.ManagedWindow):
else:
tlist = ["",""]
for ename in self.event_titles:
if the_map.has_key(ename) and len(the_map[ename]) > 0:
if ename in the_map and len(the_map[ename]) > 0:
event_handle = the_map[ename][0]
del the_map[ename][0]
date = ""
@ -364,7 +364,7 @@ class DisplayChart(ManagedWindow.ManagedWindow):
name = str(event.get_type())
if not name:
break
if the_map.has_key(name):
if name in the_map:
the_map[name] = the_map[name] + 1
else:
the_map[name] = 1
@ -375,11 +375,11 @@ class DisplayChart(ManagedWindow.ManagedWindow):
## Presently there's no Birth and Death. Instead there's Birth Date and
## Birth Place, as well as Death Date and Death Place.
## # Move birth and death to the begining of the list
## if the_map.has_key(_("Death")):
## if _("Death") in the_map:
## sort_list.remove(_("Death"))
## sort_list = [_("Death")] + sort_list
## if the_map.has_key(_("Birth")):
## if _("Birth") in the_map:
## sort_list.remove(_("Birth"))
## sort_list = [_("Birth")] + sort_list

@ -206,12 +206,12 @@ class Merge(Tool.Tool,ManagedWindow.ManagedWindow):
p1 = self.db.get_person_from_handle(p1_id)
key = self.gen_key(p1.get_primary_name().get_surname())
if p1.get_gender() == gen.lib.Person.MALE:
if males.has_key(key):
if key in males:
males[key].append(p1_id)
else:
males[key] = [p1_id]
else:
if females.has_key(key):
if key in females:
females[key].append(p1_id)
else:
females[key] = [p1_id]
@ -235,14 +235,14 @@ class Merge(Tool.Tool,ManagedWindow.ManagedWindow):
if p1key == p2key:
continue
p2 = self.db.get_person_from_handle(p2key)
if self.map.has_key(p2key):
if p2key in self.map:
(v,c) = self.map[p2key]
if v == p1key:
continue
chance = self.compare_people(p1,p2)
if chance >= thresh:
if self.map.has_key(p1key):
if p1key in self.map:
val = self.map[p1key]
if val[1] > chance:
self.map[p1key] = (p2key,chance)
@ -591,7 +591,7 @@ class ShowMatches(ManagedWindow.ManagedWindow):
def redraw(self):
list = []
for p1key in self.map.keys():
if self.dellist.has_key(p1key):
if p1key in self.dellist:
continue
(p2key,c) = self.map[p1key]
if p1key == p2key:

@ -260,7 +260,7 @@ class PG30_Def_Table:
# If there is a n_fields entry then this is a table that
# has details about the record format of another file (PER or REL).
if self.parms.has_key('n_fields'):
if 'n_fields' in self.parms:
self.get_fields()
self.recfmt = self.get_recfmt()
self.nam2fld = {}
@ -374,7 +374,7 @@ class PG30_Def_Table:
def diag(self):
txt = self.name + '\n'
if self.parms.has_key('n_fields'):
if 'n_fields' in self.parms:
txt += 'n_fields = %s\n' % self.parms['n_fields']
# Just grab a field
f = self.flds[1]

@ -129,8 +129,8 @@ class KinshipReport(Report):
self.write_people(title,self.kinship_map[Ga][Gb])
if self.inc_spouses and \
self.spouse_map.has_key(Ga) and \
self.spouse_map[Ga].has_key(Gb):
Ga in self.spouse_map and \
Gb in self.spouse_map[Ga]:
title = _("spouses of %s") % title
self.write_people(title,self.spouse_map[Ga][Gb])
@ -189,9 +189,9 @@ class KinshipReport(Report):
"""
Add a person handle to the kin map.
"""
if not self.kinship_map.has_key(Ga):
if Ga not in self.kinship_map:
self.kinship_map[Ga] = {}
if not self.kinship_map[Ga].has_key(Gb):
if Gb not in self.kinship_map[Ga]:
self.kinship_map[Ga][Gb] = []
if person_handle not in self.kinship_map[Ga][Gb]:
self.kinship_map[Ga][Gb].append(person_handle)
@ -200,9 +200,9 @@ class KinshipReport(Report):
"""
Add a person handle to the spouse map.
"""
if not self.spouse_map.has_key(Ga):
if Ga not in self.spouse_map:
self.spouse_map[Ga] = {}
if not self.spouse_map[Ga].has_key(Gb):
if Gb not in self.spouse_map[Ga]:
self.spouse_map[Ga][Gb] = []
if spouse_handle not in self.spouse_map[Ga][Gb]:
self.spouse_map[Ga][Gb].append(spouse_handle)

@ -72,7 +72,7 @@ class MarkerReport(Report):
def write_report(self):
markerstr = self.marker
# Use localized name if this is not a custom marker
if MarkerType._E2IMAP.has_key(self.marker):
if self.marker in MarkerType._E2IMAP:
mtype = MarkerType._E2IMAP[self.marker]
markerstr = MarkerType._I2SMAP[mtype]

@ -2037,7 +2037,7 @@ class IndividualPage(BasePage):
place_handle = event.get_place_handle()
if place_handle:
# TODO. Figure out what this is for.
#if self.place_list.has_key(place_handle):
#if place_handle in self.place_list:
# if lnk not in self.place_list[place_handle]:
# self.place_list[place_handle].append(lnk)
#else:
@ -2468,7 +2468,7 @@ class IndividualPage(BasePage):
descr = event.get_description()
place_handle = event.get_place_handle()
if place_handle:
if self.place_list.has_key(place_handle):
if place_handle in self.place_list:
if lnk not in self.place_list[place_handle]:
self.place_list[place_handle].append(lnk)
else:
@ -2533,7 +2533,7 @@ class IndividualPage(BasePage):
handle = sref.get_reference_handle()
gid_list.append(sref)
if self.src_list.has_key(handle):
if handle in self.src_list:
if lnk not in self.src_list[handle]:
self.src_list[handle].append(lnk)
else:
@ -3296,7 +3296,7 @@ def sort_people(db, handle_list):
sortnames[person_handle] = _nd.sort_string(primary_name)
if sname_sub.has_key(surname):
if surname in sname_sub:
sname_sub[surname].append(person_handle)
else:
sname_sub[surname] = [person_handle]

@ -276,7 +276,7 @@ def import_table(id_table, add_obj, find_next_gramps_id,
# Then we check gramps_id for conflicts and change it if needed
gramps_id = str(obj.gramps_id)
if id_table.has_key(gramps_id):
if gramps_id in id_table:
gramps_id = find_next_gramps_id()
obj.gramps_id = gramps_id
add_obj(obj, trans)

@ -600,7 +600,7 @@ class VerifyResults(ManagedWindow):
if ignore:
handle = row[VerifyResults.OBJ_HANDLE_COL]
rule_id = row[VerifyResults.RULE_ID_COL]
if not new_ignores.has_key(handle):
if handle not in new_ignores:
new_ignores[handle] = set()
new_ignores[handle].add(rule_id)
return new_ignores

@ -200,11 +200,11 @@ class FtreeWriter:
n = sn
count = -1
if name_map.has_key(n):
if n in name_map:
count = 0
while 1:
nn = "%s%d" % (n, count)
if not name_map.has_key(nn):
if nn not in name_map:
break;
count += 1
name_map[nn] = key
@ -228,9 +228,9 @@ class FtreeWriter:
family_handle = p.get_main_parents_family_handle()
if family_handle:
family = self.db.get_family_from_handle(family_handle)
if family.get_father_handle() and id_map.has_key(family.get_father_handle()):
if family.get_father_handle() and family.get_father_handle() in id_map:
father = id_map[family.get_father_handle()]
if family.get_mother_handle() and id_map.has_key(family.get_mother_handle()):
if family.get_mother_handle() and family.get_mother_handle() in id_map:
mother = id_map[family.get_mother_handle()]
#

@ -452,7 +452,7 @@ class GeneWebWriter:
pf_list = person.get_parent_family_handle_list()
if pf_list:
for family_handle in pf_list:
if self.flist.has_key(family_handle):
if family_handle in self.flist:
is_child = 1
if is_child == 0:
self.persons_details_done.append(person.get_handle())
@ -476,7 +476,7 @@ class GeneWebWriter:
firstname = _("Living")
if not (Utils.probably_alive(person,self.db) and self.restrict and self.living):
firstname = self.rem_spaces( person.get_primary_name().get_first_name())
if not self.person_ids.has_key(person.get_handle()):
if person.get_handle() not in self.person_ids:
self.person_ids[person.get_handle()] = len(self.person_ids)
ret = "%s %s.%d" % (surname, firstname, self.person_ids[person.get_handle()])
return ret
@ -486,7 +486,7 @@ class GeneWebWriter:
firstname = _("Living")
if not (Utils.probably_alive(person,self.db) and self.restrict and self.living):
firstname = self.rem_spaces( person.get_primary_name().get_first_name())
if not self.person_ids.has_key(person.get_handle()):
if person.get_handle() not in self.person_ids:
self.person_ids[person.get_handle()] = len(self.person_ids)
if surname != father_lastname:
ret = "%s.%d %s" % (firstname, self.person_ids[person.get_handle()], surname)

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:$
# $Id$
"""
This package implements unittest support for GRAMPS

@ -459,7 +459,7 @@ class StyledTextBuffer(gtk.TextBuffer):
iter = self.get_iter_at_offset(pos)
for tag in iter.get_tags():
name = tag.get_property('name')
if tagdict.has_key(name):
if name in tagdict:
if tagdict[name][-1][1] == pos - 1:
tagdict[name][-1] = (tagdict[name][-1][0], pos)
else: