- Code: Select all
elif (type(obj) == type((,))):
I'm 90% sure it's checking if obj is a tuple, in which case changing type((,)) to type(()) (the inner parenthesis make an empty tuple) should work fine. Wanted to get a second opinion first, though.
I'm not sure I should post the full function from the glue code or not - this is one of Cyan's files, after all. The glue code in the Pahts files is slightly different.
EDIT: nevermind, found the exact same function in Pahts glue code. here it is:
- Code: Select all
def glue_findAndAddAttribs(obj, glue_params):
if isinstance(obj, ptAttribute):
if glue_params.has_key(obj.id):
if glue_verbose:
print 'WARNING: Duplicate attribute ids!'
print ('%s has id %d which is already defined in %s' % (obj.name,
obj.id,
glue_params[obj.id].name,))
else:
glue_params[obj.id] = obj
elif (type(obj) == type([])):
for o in obj:
glue_findAndAddAttribs(o, glue_params)
elif (type(obj) == type({})):
for o in obj.values():
glue_findAndAddAttribs(o, glue_params)
elif (type(obj) == type((,))):
for o in obj:
glue_findAndAddAttribs(o, glue_params)
Looking at it, I think that's ugly. It's testing the types of empty constructs rather than using the build-in TupleType, ListType, etc.