Issue #0002175: Change type() expressions to isinstance() expressions.
Patch from Gerald Britton <gerald.britton@gmail.com> svn: r10762
This commit is contained in:
parent
62b6250d2f
commit
998908175f
@ -167,10 +167,10 @@ class StandardCustomSelector:
|
|||||||
|
|
||||||
if self.additional:
|
if self.additional:
|
||||||
for event_type in self.additional:
|
for event_type in self.additional:
|
||||||
if type(event_type) == str or type(event_type) == unicode :
|
if isinstance(event_type, basestring):
|
||||||
if event_type:
|
if event_type:
|
||||||
self.store.append(row=[self.custom_key, event_type])
|
self.store.append(row=[self.custom_key, event_type])
|
||||||
elif type(event_type) == tuple:
|
elif isinstance(event_type, tuple):
|
||||||
if event_type[1]:
|
if event_type[1]:
|
||||||
self.store.append(row=[event_type[0], event_type[1]])
|
self.store.append(row=[event_type[0], event_type[1]])
|
||||||
else:
|
else:
|
||||||
|
@ -872,7 +872,7 @@ class ParagraphStyle:
|
|||||||
return self.bmargin
|
return self.bmargin
|
||||||
|
|
||||||
def set_tabs(self, tab_stops):
|
def set_tabs(self, tab_stops):
|
||||||
assert(type(tab_stops) == type([]))
|
assert isinstance(tab_stops, list)
|
||||||
self.tabs = tab_stops
|
self.tabs = tab_stops
|
||||||
|
|
||||||
def get_tabs(self):
|
def get_tabs(self):
|
||||||
|
@ -164,10 +164,10 @@ def get_default(key, sample=''):
|
|||||||
value = client.get_default_from_schema(token)
|
value = client.get_default_from_schema(token)
|
||||||
if value == None:
|
if value == None:
|
||||||
raise Errors.GConfSchemaError("No default value for key "+key[1])
|
raise Errors.GConfSchemaError("No default value for key "+key[1])
|
||||||
if type(sample) in (str, unicode):
|
if isinstance(sample, basestring):
|
||||||
return value.get_string()
|
return value.get_string()
|
||||||
elif type(sample) == int:
|
elif isinstance(sample, int):
|
||||||
return value.get_int()
|
return value.get_int()
|
||||||
elif type(sample) == bool:
|
elif isinstance(sample, bool):
|
||||||
return value.get_bool()
|
return value.get_bool()
|
||||||
return None
|
return None
|
||||||
|
@ -364,7 +364,7 @@ class Gramplet(object):
|
|||||||
Runs the generator.
|
Runs the generator.
|
||||||
"""
|
"""
|
||||||
if debug: print "%s _updater" % self.gui.title
|
if debug: print "%s _updater" % self.gui.title
|
||||||
if type(self._generator) != types.GeneratorType:
|
if not isinstance(self._generator, types.GeneratorType):
|
||||||
self._idle_id = 0
|
self._idle_id = 0
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
@ -925,7 +925,7 @@ class GrampletView(PageView.PersonNavView):
|
|||||||
elif key == "column": continue
|
elif key == "column": continue
|
||||||
elif key == "row": continue
|
elif key == "row": continue
|
||||||
elif key == "data":
|
elif key == "data":
|
||||||
if type(base_opts["data"]) not in [list, tuple]:
|
if not isinstance(base_opts["data"], (list, tuple)):
|
||||||
fp.write(("data[0]=%s" + NL) % base_opts["data"])
|
fp.write(("data[0]=%s" + NL) % base_opts["data"])
|
||||||
else:
|
else:
|
||||||
cnt = 0
|
cnt = 0
|
||||||
@ -950,7 +950,7 @@ class GrampletView(PageView.PersonNavView):
|
|||||||
if key == "content": continue
|
if key == "content": continue
|
||||||
elif key == "title": continue
|
elif key == "title": continue
|
||||||
elif key == "data":
|
elif key == "data":
|
||||||
if type(base_opts["data"]) not in [list, tuple]:
|
if not isinstance(base_opts["data"], (list, tuple)):
|
||||||
fp.write(("data[0]=%s" + NL) % base_opts["data"])
|
fp.write(("data[0]=%s" + NL) % base_opts["data"])
|
||||||
else:
|
else:
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
@ -204,7 +204,7 @@ class DbLoader:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if type(filename) not in (str, unicode):
|
if not isinstance(filename, basestring):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
|
@ -105,7 +105,7 @@ class GrampsTab(gtk.HBox):
|
|||||||
hbox = gtk.HBox()
|
hbox = gtk.HBox()
|
||||||
icon = self.get_icon_name()
|
icon = self.get_icon_name()
|
||||||
|
|
||||||
if type(icon) == tuple:
|
if isinstance(icon, tuple):
|
||||||
if icon[0] == 0:
|
if icon[0] == 0:
|
||||||
func = gtk.image_new_from_icon_name
|
func = gtk.image_new_from_icon_name
|
||||||
else:
|
else:
|
||||||
|
@ -136,7 +136,7 @@ class EditMediaRef(EditReference):
|
|||||||
|
|
||||||
self.draw_preview()
|
self.draw_preview()
|
||||||
|
|
||||||
if coord and type(coord) == tuple:
|
if coord and isinstance(coord, tuple):
|
||||||
self.top.get_widget("corner1_x").set_value(coord[0])
|
self.top.get_widget("corner1_x").set_value(coord[0])
|
||||||
self.top.get_widget("corner1_y").set_value(coord[1])
|
self.top.get_widget("corner1_y").set_value(coord[1])
|
||||||
self.top.get_widget("corner2_x").set_value(coord[2])
|
self.top.get_widget("corner2_x").set_value(coord[2])
|
||||||
|
@ -143,7 +143,7 @@ class DbError(Exception):
|
|||||||
"""Error used to report that the request window is already displayed."""
|
"""Error used to report that the request window is already displayed."""
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
Exception.__init__(self)
|
Exception.__init__(self)
|
||||||
if type(value) == tuple:
|
if isinstance(value, tuple):
|
||||||
self.value = value[1]
|
self.value = value[1]
|
||||||
else:
|
else:
|
||||||
self.value = value
|
self.value = value
|
||||||
|
@ -40,8 +40,8 @@ class Rule:
|
|||||||
category = _('Miscellaneous filters')
|
category = _('Miscellaneous filters')
|
||||||
description = _('No description')
|
description = _('No description')
|
||||||
|
|
||||||
def __init__(self, list):
|
def __init__(self, arg):
|
||||||
self.set_list(list)
|
self.set_list(arg)
|
||||||
|
|
||||||
def is_empty(self):
|
def is_empty(self):
|
||||||
return False
|
return False
|
||||||
@ -51,13 +51,13 @@ class Rule:
|
|||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_list(self, list):
|
def set_list(self, arg):
|
||||||
assert type(list) == type([]) or list == None, "Argument is not a list"
|
assert isinstance(arg, list) or arg == None, "Argument is not a list"
|
||||||
assert len(list) == len(self.labels), \
|
assert len(arg) == len(self.labels), \
|
||||||
"Number of arguments does not match number of labels.\n"\
|
"Number of arguments does not match number of labels.\n"\
|
||||||
"list: %s\nlabels: %s" % (list,self.labels)
|
"list: %s\nlabels: %s" % (arg,self.labels)
|
||||||
self.list = list
|
self.list = arg
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
return self.list
|
return self.list
|
||||||
|
@ -57,7 +57,7 @@ class FilterList:
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def add(self, namespace, filt):
|
def add(self, namespace, filt):
|
||||||
assert(type(namespace)==str or type(namespace)==unicode)
|
assert(isinstance(namespace, basestring))
|
||||||
|
|
||||||
if namespace not in self.filter_namespaces.keys():
|
if namespace not in self.filter_namespaces.keys():
|
||||||
self.filter_namespaces[namespace] = []
|
self.filter_namespaces[namespace] = []
|
||||||
|
@ -165,7 +165,7 @@ class StageOne:
|
|||||||
elif key in ("CHIL", "CHILD") and is_xref_value(value):
|
elif key in ("CHIL", "CHILD") and is_xref_value(value):
|
||||||
add_to_list(self.famc, value[1:-1], current_family_id)
|
add_to_list(self.famc, value[1:-1], current_family_id)
|
||||||
elif key == 'CHAR' and not self.enc:
|
elif key == 'CHAR' and not self.enc:
|
||||||
assert(type(value) == str or type(value) == unicode)
|
assert(isinstance(value, basestring))
|
||||||
self.enc = value
|
self.enc = value
|
||||||
|
|
||||||
def get_famc_map(self):
|
def get_famc_map(self):
|
||||||
@ -190,7 +190,7 @@ class StageOne:
|
|||||||
"""
|
"""
|
||||||
Forces the encoding
|
Forces the encoding
|
||||||
"""
|
"""
|
||||||
assert(type(enc) == str or type(enc) == unicode)
|
assert(isinstance(enc, basestring))
|
||||||
self.enc = enc
|
self.enc = enc
|
||||||
|
|
||||||
def get_person_count(self):
|
def get_person_count(self):
|
||||||
|
@ -2084,7 +2084,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
|
|||||||
if name == 'Note':
|
if name == 'Note':
|
||||||
# Special case: we are way down at the very bottom.
|
# Special case: we are way down at the very bottom.
|
||||||
# Create note, commit it, return a list with one handle.
|
# Create note, commit it, return a list with one handle.
|
||||||
if (type(obj) == tuple) and (len(obj) > 0) and \
|
if (isinstance(obj, tuple) and (len(obj) > 0) and \
|
||||||
('strip' in dir(obj[0])) and (obj[0].strip()):
|
('strip' in dir(obj[0])) and (obj[0].strip()):
|
||||||
# Some notes may be None, from early databases.
|
# Some notes may be None, from early databases.
|
||||||
(text, format) = obj
|
(text, format) = obj
|
||||||
|
@ -106,7 +106,7 @@ def import2(database, filename, callback, code_set, use_trans):
|
|||||||
Import the gedcom file.
|
Import the gedcom file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert(type(code_set) == str or type(code_set) == unicode)
|
assert(isinstance(code_set, basestring))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ifile = open(filename, "rU")
|
ifile = open(filename, "rU")
|
||||||
|
@ -138,7 +138,7 @@ class GrampsWindowManager:
|
|||||||
# starting with the given item.
|
# starting with the given item.
|
||||||
# Eventualy, every non-list item (leaf) will be reached
|
# Eventualy, every non-list item (leaf) will be reached
|
||||||
# and the func(item,*args) will be called on that item.
|
# and the func(item,*args) will be called on that item.
|
||||||
if type(item) == list:
|
if isinstance(item, list):
|
||||||
# If this item is a branch
|
# If this item is a branch
|
||||||
# close the children except for the first one
|
# close the children except for the first one
|
||||||
for sub_item in item[1:]:
|
for sub_item in item[1:]:
|
||||||
@ -198,7 +198,7 @@ class GrampsWindowManager:
|
|||||||
|
|
||||||
# Make sure we have a track
|
# Make sure we have a track
|
||||||
parent_item = self.get_item_from_track(track)
|
parent_item = self.get_item_from_track(track)
|
||||||
assert type(parent_item) == list or track == [], \
|
assert isinstance(parent_item, list) or track == [], \
|
||||||
"Gwm: add_item: Incorrect track - Is parent not a leaf?"
|
"Gwm: add_item: Incorrect track - Is parent not a leaf?"
|
||||||
|
|
||||||
# Prepare a new item, depending on whether it is branch or leaf
|
# Prepare a new item, depending on whether it is branch or leaf
|
||||||
@ -220,7 +220,7 @@ class GrampsWindowManager:
|
|||||||
return new_track
|
return new_track
|
||||||
|
|
||||||
def call_back_factory(self, item):
|
def call_back_factory(self, item):
|
||||||
if type(item) != list:
|
if not isinstance(item, list):
|
||||||
def func(obj):
|
def func(obj):
|
||||||
if item.window_id and self.id2item.get(item.window_id):
|
if item.window_id and self.id2item.get(item.window_id):
|
||||||
self.id2item[item.window_id].present()
|
self.id2item[item.window_id].present()
|
||||||
@ -233,7 +233,7 @@ class GrampsWindowManager:
|
|||||||
return str(item.window_id)
|
return str(item.window_id)
|
||||||
|
|
||||||
def display_menu_list(self, data, action_data, mlist):
|
def display_menu_list(self, data, action_data, mlist):
|
||||||
if type(mlist) in (list, tuple):
|
if isinstance(mlist, (list, tuple)):
|
||||||
i = mlist[0]
|
i = mlist[0]
|
||||||
idval = self.generate_id(i)
|
idval = self.generate_id(i)
|
||||||
data.write('<menu action="M:%s">' % idval)
|
data.write('<menu action="M:%s">' % idval)
|
||||||
@ -247,9 +247,9 @@ class GrampsWindowManager:
|
|||||||
action_data.append((idval, None, i.menu_label, None, None,
|
action_data.append((idval, None, i.menu_label, None, None,
|
||||||
self.call_back_factory(i)))
|
self.call_back_factory(i)))
|
||||||
|
|
||||||
if (type(mlist) in (list, tuple)) and (len(mlist) > 1):
|
if isinstance(mlist, (list, tuple)) and (len(mlist) > 1):
|
||||||
for i in mlist[1:]:
|
for i in mlist[1:]:
|
||||||
if type(i) == list:
|
if isinstance(i, list):
|
||||||
self.display_menu_list(data, action_data, i)
|
self.display_menu_list(data, action_data, i)
|
||||||
else:
|
else:
|
||||||
idval = self.generate_id(i)
|
idval = self.generate_id(i)
|
||||||
@ -257,7 +257,7 @@ class GrampsWindowManager:
|
|||||||
% self.generate_id(i))
|
% self.generate_id(i))
|
||||||
action_data.append((idval, None, i.menu_label, None, None,
|
action_data.append((idval, None, i.menu_label, None, None,
|
||||||
self.call_back_factory(i)))
|
self.call_back_factory(i)))
|
||||||
if type(mlist) in (list, tuple):
|
if isinstance(mlist, (list, tuple)):
|
||||||
data.write('</menu>')
|
data.write('</menu>')
|
||||||
|
|
||||||
def build_windows_menu(self):
|
def build_windows_menu(self):
|
||||||
|
@ -157,7 +157,7 @@ class ListCursor(object):
|
|||||||
automatically unpickle it. So this method provides
|
automatically unpickle it. So this method provides
|
||||||
a convenient way to unpickle the object.
|
a convenient way to unpickle the object.
|
||||||
"""
|
"""
|
||||||
if rec and type(rec[1]) == type(""):
|
if rec and isinstance(rec[1], str):
|
||||||
tmp = [rec[0],None]
|
tmp = [rec[0],None]
|
||||||
tmp[1] = cPickle.loads(rec[1])
|
tmp[1] = cPickle.loads(rec[1])
|
||||||
rec = tmp
|
rec = tmp
|
||||||
|
@ -236,7 +236,7 @@ class PathCursor(object):
|
|||||||
automatically unpickle it. So this method provides
|
automatically unpickle it. So this method provides
|
||||||
a convenient way to unpickle the object.
|
a convenient way to unpickle the object.
|
||||||
"""
|
"""
|
||||||
if rec and type(rec[1]) == type(""):
|
if rec and isinstance(rec[1], str):
|
||||||
tmp = [rec[0],None]
|
tmp = [rec[0],None]
|
||||||
tmp[1] = cPickle.loads(rec[1])
|
tmp[1] = cPickle.loads(rec[1])
|
||||||
rec = tmp
|
rec = tmp
|
||||||
|
@ -199,7 +199,7 @@ class OptionListCollection:
|
|||||||
f.write('<module name="%s">\n' % escape(module_name))
|
f.write('<module name="%s">\n' % escape(module_name))
|
||||||
options = option_list.get_options()
|
options = option_list.get_options()
|
||||||
for option_name in options.keys():
|
for option_name in options.keys():
|
||||||
if type(options[option_name]) in (type(list()),type(tuple())):
|
if isinstance(options[option_name], (list, tuple)):
|
||||||
f.write(' <option name="%s" value="" length="%d">\n' % (
|
f.write(' <option name="%s" value="" length="%d">\n' % (
|
||||||
escape(option_name),
|
escape(option_name),
|
||||||
len(options[option_name]) ) )
|
len(options[option_name]) ) )
|
||||||
|
@ -88,9 +88,9 @@ class Tool:
|
|||||||
if issubclass(options_class, MenuToolOptions):
|
if issubclass(options_class, MenuToolOptions):
|
||||||
# FIXME: pass in person_id
|
# FIXME: pass in person_id
|
||||||
self.options = options_class(name, None, dbstate)
|
self.options = options_class(name, None, dbstate)
|
||||||
elif type(options_class) == ClassType:
|
elif isinstance(options_class, ClassType):
|
||||||
self.options = options_class(name)
|
self.options = options_class(name)
|
||||||
elif type(options_class) == InstanceType:
|
elif isinstance(options_class, InstanceType):
|
||||||
self.options = options_class
|
self.options = options_class
|
||||||
self.options.load_previous_values()
|
self.options.load_previous_values()
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ class CommandLineTool:
|
|||||||
self.options_help[self.show][1])
|
self.options_help[self.show][1])
|
||||||
print " Available values are:"
|
print " Available values are:"
|
||||||
vals = self.options_help[self.show][2]
|
vals = self.options_help[self.show][2]
|
||||||
if type(vals) in [list,tuple]:
|
if isinstance(vals, (list, tuple)):
|
||||||
if self.options_help[self.show][3]:
|
if self.options_help[self.show][3]:
|
||||||
for num in range(len(vals)):
|
for num in range(len(vals)):
|
||||||
print " %d\t%s" % (num,vals[num])
|
print " %d\t%s" % (num,vals[num])
|
||||||
|
@ -157,7 +157,7 @@ def run_report(dbstate, uistate, category, handle, func, **kwargs):
|
|||||||
d = TextBufDoc(make_basic_stylesheet(), None, None)
|
d = TextBufDoc(make_basic_stylesheet(), None, None)
|
||||||
d.dbstate = dbstate
|
d.dbstate = dbstate
|
||||||
d.uistate = uistate
|
d.uistate = uistate
|
||||||
if type(handle) in [str, unicode]: # a handle
|
if isinstance(handle, basestring): # a handle
|
||||||
if category == CATEGORY_QR_PERSON :
|
if category == CATEGORY_QR_PERSON :
|
||||||
obj = dbstate.db.get_person_from_handle(handle)
|
obj = dbstate.db.get_person_from_handle(handle)
|
||||||
elif category == CATEGORY_QR_FAMILY :
|
elif category == CATEGORY_QR_FAMILY :
|
||||||
|
@ -353,7 +353,7 @@ class CommandLineReport:
|
|||||||
self.options_help[self.show][1])
|
self.options_help[self.show][1])
|
||||||
print " Available values are:"
|
print " Available values are:"
|
||||||
vals = self.options_help[self.show][2]
|
vals = self.options_help[self.show][2]
|
||||||
if type(vals) in [list,tuple]:
|
if isinstance(vals, (list, tuple)):
|
||||||
if self.options_help[self.show][3]:
|
if self.options_help[self.show][3]:
|
||||||
for num in range(len(vals)):
|
for num in range(len(vals)):
|
||||||
print " %d\t%s" % (num,vals[num])
|
print " %d\t%s" % (num,vals[num])
|
||||||
|
@ -805,10 +805,10 @@ class GraphvizReportDialog(ReportDialog):
|
|||||||
name, translated_name)
|
name, translated_name)
|
||||||
|
|
||||||
def init_options(self, option_class):
|
def init_options(self, option_class):
|
||||||
if type(option_class) == ClassType:
|
if isinstance(option_class, ClassType):
|
||||||
self.options = option_class(self.raw_name,
|
self.options = option_class(self.raw_name,
|
||||||
self.dbstate.get_database())
|
self.dbstate.get_database())
|
||||||
elif type(option_class) == InstanceType:
|
elif isinstance(option_class, InstanceType):
|
||||||
self.options = option_class
|
self.options = option_class
|
||||||
|
|
||||||
################################
|
################################
|
||||||
|
@ -96,9 +96,9 @@ class ReportDialog(ManagedWindow.ManagedWindow):
|
|||||||
self.init_interface()
|
self.init_interface()
|
||||||
|
|
||||||
def init_options(self, option_class):
|
def init_options(self, option_class):
|
||||||
if type(option_class) == ClassType:
|
if isinstance(option_class, ClassType):
|
||||||
self.options = option_class(self.raw_name, self.db)
|
self.options = option_class(self.raw_name, self.db)
|
||||||
elif type(option_class) == InstanceType:
|
elif isinstance(option_class, InstanceType):
|
||||||
self.options = option_class
|
self.options = option_class
|
||||||
|
|
||||||
self.options.load_previous_values()
|
self.options.load_previous_values()
|
||||||
|
@ -1528,7 +1528,7 @@ def estimate_age_on_date(db, person, ddata=_TODAY):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def roman(num):
|
def roman(num):
|
||||||
""" Integer to Roman numeral converter for 0 < num < 4000 """
|
""" Integer to Roman numeral converter for 0 < num < 4000 """
|
||||||
if type(num) != int:
|
if not isinstance(num, int):
|
||||||
return "?"
|
return "?"
|
||||||
if not 0 < num < 4000:
|
if not 0 < num < 4000:
|
||||||
return "?"
|
return "?"
|
||||||
|
@ -612,7 +612,7 @@ class SimpleAccess:
|
|||||||
@rtype: list
|
@rtype: list
|
||||||
"""
|
"""
|
||||||
assert(isinstance(obj, (gen.lib.Person, gen.lib.Family, NoneType)))
|
assert(isinstance(obj, (gen.lib.Person, gen.lib.Family, NoneType)))
|
||||||
assert(type(restrict) == type([]) or restrict == None)
|
assert(isinstance(restrict, list) or restrict == None)
|
||||||
|
|
||||||
if obj:
|
if obj:
|
||||||
event_handles = [ ref.ref for ref in obj.get_event_ref_list() ]
|
event_handles = [ ref.ref for ref in obj.get_event_ref_list() ]
|
||||||
|
@ -179,9 +179,9 @@ class SimpleTable:
|
|||||||
for col in range(len(data)):
|
for col in range(len(data)):
|
||||||
item = data[col]
|
item = data[col]
|
||||||
# FIXME: add better text representations of these objects
|
# FIXME: add better text representations of these objects
|
||||||
if type(item) in [str, unicode]:
|
if isinstance(item, basestring):
|
||||||
retval.append(item)
|
retval.append(item)
|
||||||
elif type(item) in [int, float, long]:
|
elif isinstance(item, (int, float, long)):
|
||||||
retval.append(item)
|
retval.append(item)
|
||||||
self.row_sort_val(col, item)
|
self.row_sort_val(col, item)
|
||||||
elif isinstance(item, gen.lib.Person):
|
elif isinstance(item, gen.lib.Person):
|
||||||
|
@ -193,7 +193,7 @@ class TreeTips(gtk.Widget):
|
|||||||
tip = model.get_value(rowIter, self.column)
|
tip = model.get_value(rowIter, self.column)
|
||||||
# The tip can be either a string or
|
# The tip can be either a string or
|
||||||
# a function that returns a string.
|
# a function that returns a string.
|
||||||
if type(tip) == str:
|
if isinstance(tip, str):
|
||||||
text = tip
|
text = tip
|
||||||
elif callable(tip):
|
elif callable(tip):
|
||||||
text = tip()
|
text = tip()
|
||||||
|
@ -124,7 +124,7 @@ data_recover_msg = _('The data can only be recovered by Undo operation '
|
|||||||
'or by quitting with abandoning changes.')
|
'or by quitting with abandoning changes.')
|
||||||
|
|
||||||
def fix_encoding(value):
|
def fix_encoding(value):
|
||||||
if type(value) != unicode:
|
if not isinstance(value, unicode):
|
||||||
try:
|
try:
|
||||||
return unicode(value)
|
return unicode(value)
|
||||||
except:
|
except:
|
||||||
@ -150,7 +150,7 @@ def xml_lang():
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
def force_unicode(n):
|
def force_unicode(n):
|
||||||
if type(n) != unicode:
|
if not isinstance(n, unicode):
|
||||||
return (unicode(n).lower(), unicode(n))
|
return (unicode(n).lower(), unicode(n))
|
||||||
else:
|
else:
|
||||||
return (n.lower(), n)
|
return (n.lower(), n)
|
||||||
|
@ -76,7 +76,7 @@ class AttributeBase:
|
|||||||
@param attribute: L{Attribute} instance to add.
|
@param attribute: L{Attribute} instance to add.
|
||||||
@type attribute: L{Attribute}
|
@type attribute: L{Attribute}
|
||||||
"""
|
"""
|
||||||
assert type(attribute) != unicode
|
assert not isinstance(attribute, unicode)
|
||||||
self.attribute_list.append(attribute)
|
self.attribute_list.append(attribute)
|
||||||
|
|
||||||
def remove_attribute(self, attribute):
|
def remove_attribute(self, attribute):
|
||||||
|
@ -192,7 +192,7 @@ class Date:
|
|||||||
if len(source) == 0:
|
if len(source) == 0:
|
||||||
source = None
|
source = None
|
||||||
elif len(source) == 1:
|
elif len(source) == 1:
|
||||||
if type(source[0]) == int:
|
if isinstance(source[0], int):
|
||||||
source = (source[0], 0, 0)
|
source = (source[0], 0, 0)
|
||||||
else:
|
else:
|
||||||
source = source[0]
|
source = source[0]
|
||||||
@ -203,7 +203,7 @@ class Date:
|
|||||||
else:
|
else:
|
||||||
raise AttributeError, "invalid args to Date: %s" % source
|
raise AttributeError, "invalid args to Date: %s" % source
|
||||||
#### ok, process either date or tuple
|
#### ok, process either date or tuple
|
||||||
if type(source) == tuple:
|
if isinstance(source, tuple):
|
||||||
if calendar == None:
|
if calendar == None:
|
||||||
self.calendar = Date.CAL_GREGORIAN
|
self.calendar = Date.CAL_GREGORIAN
|
||||||
else:
|
else:
|
||||||
@ -221,7 +221,7 @@ class Date:
|
|||||||
self.sortval = 0
|
self.sortval = 0
|
||||||
self.newyear = 0
|
self.newyear = 0
|
||||||
self.set_yr_mon_day(*source)
|
self.set_yr_mon_day(*source)
|
||||||
elif type(source) == str and source != "":
|
elif isinstance(source, str) and source != "":
|
||||||
if (calendar != None or
|
if (calendar != None or
|
||||||
modifier != None or
|
modifier != None or
|
||||||
quality != None):
|
quality != None):
|
||||||
@ -302,9 +302,9 @@ class Date:
|
|||||||
"""
|
"""
|
||||||
Date arithmetic: Date() + years, or Date() + (years, [months, [days]]).
|
Date arithmetic: Date() + years, or Date() + (years, [months, [days]]).
|
||||||
"""
|
"""
|
||||||
if type(other) == int:
|
if isinstance(other, int):
|
||||||
return self.copy_offset_ymd(other)
|
return self.copy_offset_ymd(other)
|
||||||
elif type(other) in [tuple, list]:
|
elif isinstance(other, (tuple, list)):
|
||||||
return self.copy_offset_ymd(*other)
|
return self.copy_offset_ymd(*other)
|
||||||
else:
|
else:
|
||||||
raise AttributeError, "unknown date add type: %s " % type(other)
|
raise AttributeError, "unknown date add type: %s " % type(other)
|
||||||
@ -319,11 +319,11 @@ class Date:
|
|||||||
"""
|
"""
|
||||||
Date arithmetic: Date() - years, Date - (y,m,d), or Date() - Date().
|
Date arithmetic: Date() - years, Date - (y,m,d), or Date() - Date().
|
||||||
"""
|
"""
|
||||||
if type(other) == int: # Date - value -> Date
|
if isinstance(other, int): # Date - value -> Date
|
||||||
return self.copy_offset_ymd(-other)
|
return self.copy_offset_ymd(-other)
|
||||||
elif type(other) in [tuple, list]: # Date - (y, m, d) -> Date
|
elif isinstance(other, (tuple, list)): # Date - (y, m, d) -> Date
|
||||||
return self.copy_offset_ymd(*map(lambda x: -x, other))
|
return self.copy_offset_ymd(*map(lambda x: -x, other))
|
||||||
elif type(other) == type(self): # Date1 - Date2 -> tuple
|
elif isinstance(other, self): # Date1 - Date2 -> tuple
|
||||||
# We should make sure that Date2 + tuple -> Date1 and
|
# We should make sure that Date2 + tuple -> Date1 and
|
||||||
# Date1 - tuple -> Date2
|
# Date1 - tuple -> Date2
|
||||||
d1 = map(lambda i: i or 1, self.get_ymd())
|
d1 = map(lambda i: i or 1, self.get_ymd())
|
||||||
|
@ -134,13 +134,13 @@ class GrampsType(object):
|
|||||||
self.string = u''
|
self.string = u''
|
||||||
|
|
||||||
def set(self, value):
|
def set(self, value):
|
||||||
if type(value) == tuple:
|
if isinstance(value, tuple):
|
||||||
self.__set_tuple(value)
|
self.__set_tuple(value)
|
||||||
elif type(value) == int:
|
elif isinstance(value, int):
|
||||||
self.__set_int(value)
|
self.__set_int(value)
|
||||||
elif isinstance(value, self.__class__):
|
elif isinstance(value, self.__class__):
|
||||||
self.__set_instance(value)
|
self.__set_instance(value)
|
||||||
elif type(value) in (str,unicode):
|
elif isinstance(value, basestring):
|
||||||
self.__set_str(value)
|
self.__set_str(value)
|
||||||
else:
|
else:
|
||||||
self.val = self._DEFAULT
|
self.val = self._DEFAULT
|
||||||
@ -208,14 +208,14 @@ class GrampsType(object):
|
|||||||
return self._CUSTOM
|
return self._CUSTOM
|
||||||
|
|
||||||
def __cmp__(self, value):
|
def __cmp__(self, value):
|
||||||
if type(value) == int:
|
if isinstance(value, int):
|
||||||
return cmp(self.val, value)
|
return cmp(self.val, value)
|
||||||
elif type(value) in (str, unicode):
|
elif isinstance(value, basestring):
|
||||||
if self.val == self._CUSTOM:
|
if self.val == self._CUSTOM:
|
||||||
return cmp(self.string, value)
|
return cmp(self.string, value)
|
||||||
else:
|
else:
|
||||||
return cmp(self._I2SMAP.get(self.val), value)
|
return cmp(self._I2SMAP.get(self.val), value)
|
||||||
elif type(value) == tuple:
|
elif isinstance(value, tuple):
|
||||||
return cmp((self.val, self.string), value)
|
return cmp((self.val, self.string), value)
|
||||||
else:
|
else:
|
||||||
if value.val == self._CUSTOM:
|
if value.val == self._CUSTOM:
|
||||||
|
@ -71,17 +71,17 @@ class MarkerType(GrampsType):
|
|||||||
else:
|
else:
|
||||||
self.val = value.val
|
self.val = value.val
|
||||||
self.string = value.string
|
self.string = value.string
|
||||||
elif type(value) == tuple:
|
elif isinstance(value, tuple):
|
||||||
if value[0] == self.CUSTOM and value[1] == u'':
|
if value[0] == self.CUSTOM and value[1] == u'':
|
||||||
self.value = self.NONE
|
self.value = self.NONE
|
||||||
self.string = u''
|
self.string = u''
|
||||||
else:
|
else:
|
||||||
self.val = value[0]
|
self.val = value[0]
|
||||||
self.string = value[1]
|
self.string = value[1]
|
||||||
elif type(value) == int:
|
elif isinstance(value, int):
|
||||||
self.val = value
|
self.val = value
|
||||||
self.string = u''
|
self.string = u''
|
||||||
elif type(value) == str:
|
elif isinstance(value, str):
|
||||||
self.val = self._S2IMAP.get(value, self._CUSTOM)
|
self.val = self._S2IMAP.get(value, self._CUSTOM)
|
||||||
if self.val == self._CUSTOM:
|
if self.val == self._CUSTOM:
|
||||||
self.string = value
|
self.string = value
|
||||||
|
@ -709,7 +709,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
|||||||
Person's L{Family} list.
|
Person's L{Family} list.
|
||||||
@type family_handle: str
|
@type family_handle: str
|
||||||
"""
|
"""
|
||||||
if type(family_handle) not in (str, unicode):
|
if not isinstance(family_handle, basestring):
|
||||||
raise ValueError("expecting handle")
|
raise ValueError("expecting handle")
|
||||||
if family_handle not in self.parent_family_list:
|
if family_handle not in self.parent_family_list:
|
||||||
self.parent_family_list.append(family_handle)
|
self.parent_family_list.append(family_handle)
|
||||||
|
@ -397,8 +397,8 @@ class Callback(object):
|
|||||||
for (key, fn) in self.__callback_map[signal_name]:
|
for (key, fn) in self.__callback_map[signal_name]:
|
||||||
self._log("Calling callback with key: %s\n" % (key, ))
|
self._log("Calling callback with key: %s\n" % (key, ))
|
||||||
try:
|
try:
|
||||||
if type(fn) == types.FunctionType or \
|
if isinstance(fn, types.FunctionType) or \
|
||||||
type(fn) == types.MethodType: # call func
|
isinstance(fn, types.MethodType): # call func
|
||||||
fn(*args)
|
fn(*args)
|
||||||
else:
|
else:
|
||||||
self._warn("Badly formed entry in callback map.\n")
|
self._warn("Badly formed entry in callback map.\n")
|
||||||
|
@ -213,26 +213,26 @@ class TestCallback(unittest.TestCase):
|
|||||||
|
|
||||||
t = TestSignals()
|
t = TestSignals()
|
||||||
t.connect('test-int',fn), t.emit('test-int',(1,))
|
t.connect('test-int',fn), t.emit('test-int',(1,))
|
||||||
assert type(rl[0]) == int, "not int"
|
assert isinstance(rl[0], int), "not int"
|
||||||
|
|
||||||
t.connect('test-list',fn), t.emit('test-list',([1,2],))
|
t.connect('test-list',fn), t.emit('test-list',([1,2],))
|
||||||
assert type(rl[1]) == list, "not list"
|
assert isinstance(rl[1], list), "not list"
|
||||||
|
|
||||||
t.connect('test-object',fn), t.emit('test-object',(t,))
|
t.connect('test-object',fn), t.emit('test-object',(t,))
|
||||||
assert isinstance(rl[2], object), "not object"
|
assert isinstance(rl[2], object), "not object"
|
||||||
|
|
||||||
t.connect('test-float',fn), t.emit('test-float',(2.3,))
|
t.connect('test-float',fn), t.emit('test-float',(2.3,))
|
||||||
assert type(rl[3]) == float, "not float"
|
assert isinstance(rl[3], float), "not float"
|
||||||
|
|
||||||
t.connect('test-dict',fn), t.emit('test-dict',({1:2},))
|
t.connect('test-dict',fn), t.emit('test-dict',({1:2},))
|
||||||
assert type(rl[4]) == dict, "not dict"
|
assert isinstance(rl[4], dict), "not dict"
|
||||||
|
|
||||||
rl = []
|
rl = []
|
||||||
def fn2(i,s,l, o,f,r=rl):
|
def fn2(i,s,l, o,f,r=rl):
|
||||||
rl.append(i)
|
rl.append(i)
|
||||||
|
|
||||||
t.connect('test-lots',fn2), t.emit('test-lots',(1,'a',[1,2],t,1.2))
|
t.connect('test-lots',fn2), t.emit('test-lots',(1,'a',[1,2],t,1.2))
|
||||||
assert type(rl[0]) == int, "not lots"
|
assert isinstance(rl[0], int), "not lots"
|
||||||
|
|
||||||
# This should fail because the type of arg1 is wrong
|
# This should fail because the type of arg1 is wrong
|
||||||
res=[]
|
res=[]
|
||||||
|
@ -147,7 +147,7 @@ class GenChart:
|
|||||||
|
|
||||||
def not_blank(self,line):
|
def not_blank(self,line):
|
||||||
for i in line:
|
for i in line:
|
||||||
if i and type(i) == tuple:
|
if i and isinstance(i, tuple):
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ class AncestorTree(Report):
|
|||||||
for x in range(startx,stopx):
|
for x in range(startx,stopx):
|
||||||
value = self.genchart.get_xy(x,y)
|
value = self.genchart.get_xy(x,y)
|
||||||
if value:
|
if value:
|
||||||
if type(value) == tuple:
|
if isinstance(value, tuple):
|
||||||
(person,index) = value
|
(person,index) = value
|
||||||
text = '\n'.join(self.text[index])
|
text = '\n'.join(self.text[index])
|
||||||
self.doc.draw_box("AC2-box",
|
self.doc.draw_box("AC2-box",
|
||||||
@ -426,7 +426,7 @@ class AncestorTree(Report):
|
|||||||
value = self.genchart.get_xy(x,y)
|
value = self.genchart.get_xy(x,y)
|
||||||
if not value:
|
if not value:
|
||||||
continue
|
continue
|
||||||
if type(value) == tuple:
|
if isinstance(value, tuple):
|
||||||
(person,index) = value
|
(person,index) = value
|
||||||
if self.genchart.get(index*2):
|
if self.genchart.get(index*2):
|
||||||
(px,py) = self.genchart.index_to_xy(index*2)
|
(px,py) = self.genchart.index_to_xy(index*2)
|
||||||
|
@ -433,7 +433,7 @@ class BookList:
|
|||||||
options = item.option_class.handler.options_dict
|
options = item.option_class.handler.options_dict
|
||||||
for option_name in options.keys():
|
for option_name in options.keys():
|
||||||
option_value = options[option_name]
|
option_value = options[option_name]
|
||||||
if type(option_value) in (type(list()), type(tuple())):
|
if isinstance(option_value, (list, tuple)):
|
||||||
f.write(' <option name="%s" value="" '
|
f.write(' <option name="%s" value="" '
|
||||||
'length="%d">\n' % (
|
'length="%d">\n' % (
|
||||||
escape(option_name),
|
escape(option_name),
|
||||||
|
@ -858,10 +858,10 @@ class Holidays:
|
|||||||
d = int(d)
|
d = int(d)
|
||||||
ndate = datetime.date(y, m, d)
|
ndate = datetime.date(y, m, d)
|
||||||
if self.debug: print ndate, offset, type(offset)
|
if self.debug: print ndate, offset, type(offset)
|
||||||
if type(offset) == int:
|
if isinstance(offset, int):
|
||||||
if offset != 0:
|
if offset != 0:
|
||||||
ndate = ndate.fromordinal(ndate.toordinal() + offset)
|
ndate = ndate.fromordinal(ndate.toordinal() + offset)
|
||||||
elif type(offset) in [type(u''), str]:
|
elif isinstance(offset, basestring):
|
||||||
dir = 1
|
dir = 1
|
||||||
if offset[0] == "-":
|
if offset[0] == "-":
|
||||||
dir = -1
|
dir = -1
|
||||||
|
@ -326,13 +326,13 @@ class CheckIntegrity:
|
|||||||
|
|
||||||
for handle in self.db.media_map.keys():
|
for handle in self.db.media_map.keys():
|
||||||
data = self.db.media_map[handle]
|
data = self.db.media_map[handle]
|
||||||
if type(data[2]) != unicode or type(data[4]) != unicode:
|
if not isinstance(data[2], unicode) or not isinstance(data[4], unicode):
|
||||||
obj = self.db.get_object_from_handle(handle)
|
obj = self.db.get_object_from_handle(handle)
|
||||||
obj.path = Utils.fix_encoding( obj.path)
|
obj.path = Utils.fix_encoding( obj.path)
|
||||||
obj.desc = Utils.fix_encoding( obj.desc)
|
obj.desc = Utils.fix_encoding( obj.desc)
|
||||||
self.db.commit_media_object(obj,self.trans)
|
self.db.commit_media_object(obj,self.trans)
|
||||||
# Once we are here, fix the mime string if not str
|
# Once we are here, fix the mime string if not str
|
||||||
if type(data[3]) != str:
|
if not isinstance(data[3], str):
|
||||||
obj = self.db.get_object_from_handle(handle)
|
obj = self.db.get_object_from_handle(handle)
|
||||||
try:
|
try:
|
||||||
if data[3] == str(data[3]):
|
if data[3] == str(data[3]):
|
||||||
@ -798,7 +798,7 @@ class CheckIntegrity:
|
|||||||
person.get_event_ref_list().remove(event_ref)
|
person.get_event_ref_list().remove(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.invalid_events.append(key)
|
self.invalid_events.append(key)
|
||||||
elif type(person.get_event_ref_list()) != list:
|
elif not isinstance(person.get_event_ref_list(), list):
|
||||||
# event_list is None or other garbage
|
# event_list is None or other garbage
|
||||||
person.set_event_ref_list([])
|
person.set_event_ref_list([])
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
@ -820,7 +820,7 @@ class CheckIntegrity:
|
|||||||
family.set_event_ref_list(nlist)
|
family.set_event_ref_list(nlist)
|
||||||
self.db.commit_family(family,self.trans)
|
self.db.commit_family(family,self.trans)
|
||||||
self.invalid_events.append(key)
|
self.invalid_events.append(key)
|
||||||
elif type(family.get_event_ref_list()) != list:
|
elif not isinstance(family.get_event_ref_list(), list):
|
||||||
# event_list is None or other garbage
|
# event_list is None or other garbage
|
||||||
family.set_event_ref_list([])
|
family.set_event_ref_list([])
|
||||||
self.db.commit_family(family,self.trans)
|
self.db.commit_family(family,self.trans)
|
||||||
|
@ -180,7 +180,7 @@ class CmdRef(Tool.Tool):
|
|||||||
% escape(oclass.options_help[arg][1]))
|
% escape(oclass.options_help[arg][1]))
|
||||||
|
|
||||||
if len(oclass.options_help[arg])>2:
|
if len(oclass.options_help[arg])>2:
|
||||||
if type(oclass.options_help[arg][2]) in [list,tuple]:
|
if isinstance(oclass.options_help[arg][2], (list, tuple)):
|
||||||
if oclass.options_help[arg][3]:
|
if oclass.options_help[arg][3]:
|
||||||
f.write(' <orderedlist>\n')
|
f.write(' <orderedlist>\n')
|
||||||
for val in oclass.options_help[arg][2]:
|
for val in oclass.options_help[arg][2]:
|
||||||
|
@ -90,7 +90,7 @@ class GenChart:
|
|||||||
|
|
||||||
def not_blank(self,line):
|
def not_blank(self,line):
|
||||||
for i in line:
|
for i in line:
|
||||||
if i and type(i) == tuple:
|
if i and isinstance(i, tuple):
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ class DescendTree(Report):
|
|||||||
phys_x = 0
|
phys_x = 0
|
||||||
for x in range(startx,stopx):
|
for x in range(startx,stopx):
|
||||||
value = self.genchart.get_xy(x,y)
|
value = self.genchart.get_xy(x,y)
|
||||||
if type(value) == str or type(value) == unicode:
|
if isinstance(value, basestring):
|
||||||
text = '\n'.join(self.text[(x,y)])
|
text = '\n'.join(self.text[(x,y)])
|
||||||
xbegin = phys_x*self.delta
|
xbegin = phys_x*self.delta
|
||||||
yend = phys_y*bh+self.offset
|
yend = phys_y*bh+self.offset
|
||||||
|
@ -63,7 +63,7 @@ def run(database, document, person):
|
|||||||
sdb = SimpleAccess(database)
|
sdb = SimpleAccess(database)
|
||||||
sdoc = SimpleDoc(document)
|
sdoc = SimpleDoc(document)
|
||||||
stab = SimpleTable(sdb)
|
stab = SimpleTable(sdb)
|
||||||
if type(person) == str:
|
if isinstance(person, str):
|
||||||
surname = person
|
surname = person
|
||||||
rsurname = person
|
rsurname = person
|
||||||
else:
|
else:
|
||||||
|
@ -1160,10 +1160,10 @@ class Holidays:
|
|||||||
d = int(d)
|
d = int(d)
|
||||||
ndate = datetime.date(y, m, d)
|
ndate = datetime.date(y, m, d)
|
||||||
if self.debug: print ndate, offset, type(offset)
|
if self.debug: print ndate, offset, type(offset)
|
||||||
if type(offset) == int:
|
if isinstance(offset, int):
|
||||||
if offset != 0:
|
if offset != 0:
|
||||||
ndate = ndate.fromordinal(ndate.toordinal() + offset)
|
ndate = ndate.fromordinal(ndate.toordinal() + offset)
|
||||||
elif type(offset) in [type(u''), str]:
|
elif isinstance(offset, basestring):
|
||||||
dir = 1
|
dir = 1
|
||||||
if offset[0] == "-":
|
if offset[0] == "-":
|
||||||
dir = -1
|
dir = -1
|
||||||
|
@ -165,7 +165,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) in (str,unicode):
|
if isinstance(common, basestring):
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -182,8 +182,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -271,8 +271,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -192,8 +192,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -301,8 +301,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -334,8 +334,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -242,8 +242,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -264,7 +264,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
#orig person, apperently secondRel in this function
|
#orig person, apperently secondRel in this function
|
||||||
(secondRel,firstRel,common) = self.get_relationship_distance(orig_person, other_person)
|
(secondRel,firstRel,common) = self.get_relationship_distance(orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
if isinstance(common, basestring):
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -217,8 +217,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -165,8 +165,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
(secondRel,firstRel,common) = \
|
(secondRel,firstRel,common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance(db, orig_person, other_person)
|
||||||
|
|
||||||
if type(common) == types.StringType or \
|
if isinstance(common, basestring):
|
||||||
type(common) == types.UnicodeType:
|
|
||||||
return (common,[])
|
return (common,[])
|
||||||
elif common:
|
elif common:
|
||||||
person_handle = common[0]
|
person_handle = common[0]
|
||||||
|
@ -375,7 +375,7 @@ class MonitoredDataType:
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
val = self.get_val()
|
val = self.get_val()
|
||||||
if type(val) == tuple :
|
if isinstance(val, tuple):
|
||||||
self.sel.set_values(val)
|
self.sel.set_values(val)
|
||||||
else:
|
else:
|
||||||
self.sel.set_values((int(val), str(val)))
|
self.sel.set_values((int(val), str(val)))
|
||||||
|
Loading…
Reference in New Issue
Block a user