def generateArgList(arglist): """Generate an arg list marking TupleArgs""" args = [] extra = [] count = 0 for i in range(len(arglist)): elt = arglist[i] if isinstance(elt, str): args.append(elt) elif isinstance(elt, tuple): args.append(TupleArg(i * 2, elt)) extra.extend(misc.flatten(elt)) count = count + 1 else: raise ValueError, "unexpect argument type:", elt return args + extra, count
def generateArgList(arglist): """Generate an arg list marking TupleArgs""" args = [] extra = [] count = 0 for i in range(len(arglist)): elt = arglist[i] if isinstance(elt, ast.SimpleArg): args.append(elt.name) elif isinstance(elt, ast.NestedArgs): t = tuple(_nested_names(elt)) args.append(TupleArg(i * 2, t)) extra.extend(misc.flatten(t)) count = count + 1 else: raise ValueError, "unexpect argument type:", elt return args + extra, count
def generateArgList(arglist): """Generate an arg list marking TupleArgs""" args = [] extra = [] count = 0 for i in range(len(arglist)): elt = arglist[i] if util.is_unicode(elt): args.append(elt) # for Python 2 -- not sure why I got non-unicode elif isinstance(elt, str): args.append(elt) elif isinstance(elt, tuple): args.append(TupleArg(i * 2, elt)) extra.extend(misc.flatten(elt)) count = count + 1 else: # Not in Python 2. #raise ValueError("unexpect argument type:").with_traceback(elt) raise ValueError("unexpect argument type: %r (%s)" % (elt, type(elt))) return args + extra, count
import imp