Syntax error in glue code

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Syntax error in glue code

Postby Branan » Wed Jun 25, 2008 3:30 pm

I'm getting a syntax error from Python in the glue code. This is in a Cyan-standard file, not in a custom python file. All of Cyan's files have this line, though. It may be a result of the decompyler doing something weird. The line is in thefunction glue_findAndAddAttribs(obj, glue_params)
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.
Image
Your friendly neighborhood shard admin
User avatar
Branan
Gehn Shard Admin
 
Posts: 694
Joined: Fri Nov 16, 2007 9:45 pm
Location: Portland, OR

Re: Syntax error in glue code

Postby D'Lanor » Wed Jun 25, 2008 3:38 pm

I don't have that exact line. The glue code can be found in several posts on this forum so I am not going to worry about posting it here. This is what glue_findAndAddAttribs should look like.

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)


Edit: this was decompiled with UruPython.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Syntax error in glue code

Postby Branan » Wed Jun 25, 2008 3:57 pm

Mine were decompiled with PlasmaShop 2.2.4. Just did a decompile with UruPython, and it looks good. I'll have to remember not to use PlasmaShop for Python stuff, at least for now.
Image
Your friendly neighborhood shard admin
User avatar
Branan
Gehn Shard Admin
 
Posts: 694
Joined: Fri Nov 16, 2007 9:45 pm
Location: Portland, OR


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron