コード例 #1
0
def get_args(node):

    if isinstance(node, (ops.Aggregation, ops.Selection)):
        return get_args_selection_aggregation(node)
    else:
        args = (arg for arg in node.args if isinstance(arg, ir.Expr))
        try:
            input_type = node.input_type
        except AttributeError:
            names = node._arg_names
        else:
            names = (arg.name for arg in input_type.types)
        return zip_longest(args, names)
コード例 #2
0
def get_args_selection_aggregation(node):
    return zip_longest(
        itertools.chain([node.table],
                        itertools.chain.from_iterable(
                            getattr(node, argname) or [None]
                            for argname in node._arg_names
                            if argname != 'table')),
        itertools.chain(['table'],
                        itertools.chain.from_iterable([
                            '{}[{:d}]'.format(argname, i)
                            for i in range(len(getattr(node, argname)))
                        ] or [None] for argname in node._arg_names
                                                      if argname != 'table')),
    )