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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ class IsAncestorOf(Rule):
self.map = {} self.map = {}
def apply(self,db,person): 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): def init_ancestor_list(self,db,person,first):
if not person: if not person:

View File

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

View File

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

View File

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

View File

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

View File

@ -62,10 +62,10 @@ class IsLessThanNthGenerationAncestorOf(Rule):
self.map = {} self.map = {}
def apply(self,db,person): 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): 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) # loop_error(self.orig,p)
if not handle: if not handle:
return return

View File

@ -70,7 +70,7 @@ class IsLessThanNthGenerationAncestorOfBookmarked(Rule):
def init_ancestor_list(self, handle,gen): 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) # loop_error(self.orig,p)
if not handle: if not handle:
return return

View File

@ -63,7 +63,7 @@ class IsLessThanNthGenerationAncestorOfDefaultPerson(Rule):
self.apply = lambda db,p: False self.apply = lambda db,p: False
def init_ancestor_list(self, handle,gen): 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) # loop_error(self.orig,p)
if not handle: if not handle:
return return

View File

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

View File

@ -62,10 +62,10 @@ class IsMoreThanNthGenerationAncestorOf(Rule):
self.map = [] self.map = []
def apply(self,db,person): 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): 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) # loop_error(self.orig,p)
if not handle: if not handle:
return return

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 # Then we check gramps_id for conflicts and change it if needed
gramps_id = str(obj.gramps_id) 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() gramps_id = find_next_gramps_id()
obj.gramps_id = gramps_id obj.gramps_id = gramps_id
add_obj(obj, trans) add_obj(obj, trans)

View File

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

View File

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

View File

@ -150,7 +150,7 @@ class MergeSources(ManagedWindow.ManagedWindow):
src2_map = self.s2.get_data_map() src2_map = self.s2.get_data_map()
src1_map = self.s1.get_data_map() src1_map = self.s1.get_data_map()
for key in src2_map.keys(): 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] src1_map[key] = src2_map[key]
# replace references in other objetcs # replace references in other objetcs

View File

@ -64,7 +64,7 @@ def mime_type_is_defined(mime_type):
""" """
Return True if a description for a mime type exists. 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): def find_mime_type_pixbuf(mime_type):
return gtk.gdk.pixbuf_new_from_file(const.ICON) return gtk.gdk.pixbuf_new_from_file(const.ICON)

View File

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

View File

@ -132,7 +132,7 @@ class FastModel(gtk.GenericTreeModel):
# If we are at the second level we first check to see if we # 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 # 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. # 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],]) self._num_children_cache[rowref[0]] = self._cursor.get_n_children([rowref[0],])
@ -179,7 +179,7 @@ class FastModel(gtk.GenericTreeModel):
if rowref: if rowref:
# If we are at the second level we first check to see if we # 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 # 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. # 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],]) self._num_children_cache[rowref[0]] = self._cursor.get_n_children([rowref[0],])

View File

@ -108,7 +108,7 @@ class ListCursor(object):
""" """
# See if the record is in the cache. # 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] ret = self._object_cache[index]
# If the record is not in the cache or we are ignoring the # If the record is not in the cache or we are ignoring the

View File

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

View File

@ -812,7 +812,7 @@ class ListView(BookMarkView):
for pair in [pair for pair in self.column_order() if pair[0]]: for pair in [pair for pair in self.column_order() if pair[0]]:
name = self.colinfo[pair[1]] 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 mcol = self.model.marker_color_column
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1], column = gtk.TreeViewColumn(name, self.renderer, text=pair[1],
foreground=mcol) foreground=mcol)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -100,11 +100,11 @@ class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
style = style_sheet.get_paragraph_style(style_name) style = style_sheet.get_paragraph_style(style_name)
fgcolor = style.get_font().get_color() fgcolor = style.get_font().get_color()
bgcolor = style.get_background_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.color_map[fgcolor] = index
self.f.write('\\red%d\\green%d\\blue%d;' % fgcolor) self.f.write('\\red%d\\green%d\\blue%d;' % fgcolor)
index = index + 1 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.f.write('\\red%d\\green%d\\blue%d;' % bgcolor)
self.color_map[bgcolor] = index self.color_map[bgcolor] = index
index = index + 1 index = index + 1

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -260,7 +260,7 @@ class PG30_Def_Table:
# If there is a n_fields entry then this is a table that # 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). # 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.get_fields()
self.recfmt = self.get_recfmt() self.recfmt = self.get_recfmt()
self.nam2fld = {} self.nam2fld = {}
@ -374,7 +374,7 @@ class PG30_Def_Table:
def diag(self): def diag(self):
txt = self.name + '\n' 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'] txt += 'n_fields = %s\n' % self.parms['n_fields']
# Just grab a field # Just grab a field
f = self.flds[1] f = self.flds[1]

View File

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

View File

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

View File

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

View File

@ -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 # Then we check gramps_id for conflicts and change it if needed
gramps_id = str(obj.gramps_id) 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() gramps_id = find_next_gramps_id()
obj.gramps_id = gramps_id obj.gramps_id = gramps_id
add_obj(obj, trans) add_obj(obj, trans)

View File

@ -600,7 +600,7 @@ class VerifyResults(ManagedWindow):
if ignore: if ignore:
handle = row[VerifyResults.OBJ_HANDLE_COL] handle = row[VerifyResults.OBJ_HANDLE_COL]
rule_id = row[VerifyResults.RULE_ID_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] = set()
new_ignores[handle].add(rule_id) new_ignores[handle].add(rule_id)
return new_ignores return new_ignores

View File

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

View File

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

View File

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

View File

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