コード例 #1
0
def handle_FunctionDef(x):
    t = aterm.ATConstructor()
    t.setName("FunctionDef")
    name = x.name
    t.addChild(handle(name))

    args = x.args
    t.addChild(handle(args))

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'decorator_list'):
        decorator_list = x.decorator_list
        tkid = aterm.ATList()
        for elt in decorator_list:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'returns'):
        returns = x.returns
        t.addChild(handle(returns))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    return t
コード例 #2
0
ファイル: py2_to_aterm.py プロジェクト: CCA-Forum/compose-hpc
def handle_ClassDef(x):
    t = aterm.ATConstructor()
    t.setName("ClassDef")
    name = x.name
    t.addChild(handle(name))

    if hasattr(x, 'bases'):
        bases = x.bases
        tkid = aterm.ATList()
        for elt in bases:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'decorator_list'):
        decorator_list = x.decorator_list
        tkid = aterm.ATList()
        for elt in decorator_list:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #3
0
def handle_Try(x):
    t = aterm.ATConstructor()
    t.setName("Try")
    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'handlers'):
        handlers = x.handlers
        tkid = aterm.ATList()
        for elt in handlers:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'orelse'):
        orelse = x.orelse
        tkid = aterm.ATList()
        for elt in orelse:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'finalbody'):
        finalbody = x.finalbody
        tkid = aterm.ATList()
        for elt in finalbody:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #4
0
def handle_ClassDef(x):
    t = aterm.ATConstructor()
    t.setName("ClassDef")
    name = x.name
    t.addChild(handle(name))

    if hasattr(x, 'bases'):
        bases = x.bases
        tkid = aterm.ATList()
        for elt in bases:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'keywords'):
        keywords = x.keywords
        tkid = aterm.ATList()
        for elt in keywords:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'starargs'):
        starargs = x.starargs
        t.addChild(handle(starargs))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'kwargs'):
        kwargs = x.kwargs
        t.addChild(handle(kwargs))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'decorator_list'):
        decorator_list = x.decorator_list
        tkid = aterm.ATList()
        for elt in decorator_list:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #5
0
def handle_ImportFrom(x):
    t = aterm.ATConstructor()
    t.setName("ImportFrom")
    #OPTIONAL
    if hasattr(x, 'module'):
        module = x.module
        t.addChild(handle(module))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    if hasattr(x, 'names'):
        names = x.names
        tkid = aterm.ATList()
        for elt in names:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'level'):
        level = x.level
        t.addChild(handle(level))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    return t
コード例 #6
0
def handle_ExceptHandler(x):
    t = aterm.ATConstructor()
    t.setName("ExceptHandler")
    #OPTIONAL
    if hasattr(x, 'type'):
        type = x.type
        t.addChild(handle(type))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'name'):
        name = x.name
        t.addChild(handle(name))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #7
0
def handle_Dict(x):
    t = aterm.ATConstructor()
    t.setName("Dict")
    if hasattr(x, 'keys'):
        keys = x.keys
        tkid = aterm.ATList()
        for elt in keys:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'values'):
        values = x.values
        tkid = aterm.ATList()
        for elt in values:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #8
0
ファイル: py2_to_aterm.py プロジェクト: CCA-Forum/compose-hpc
def handle_TryFinally(x):
    t = aterm.ATConstructor()
    t.setName("TryFinally")
    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'finalbody'):
        finalbody = x.finalbody
        tkid = aterm.ATList()
        for elt in finalbody:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #9
0
def handle_With(x):
    t = aterm.ATConstructor()
    t.setName("With")
    if hasattr(x, 'items'):
        items = x.items
        tkid = aterm.ATList()
        for elt in items:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #10
0
def handle_Nonlocal(x):
    t = aterm.ATConstructor()
    t.setName("Nonlocal")
    if hasattr(x, 'names'):
        names = x.names
        tkid = aterm.ATList()
        for elt in names:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #11
0
def handle_Delete(x):
    t = aterm.ATConstructor()
    t.setName("Delete")
    if hasattr(x, 'targets'):
        targets = x.targets
        tkid = aterm.ATList()
        for elt in targets:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #12
0
def handle_ExtSlice(x):
    t = aterm.ATConstructor()
    t.setName("ExtSlice")
    if hasattr(x, 'dims'):
        dims = x.dims
        tkid = aterm.ATList()
        for elt in dims:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #13
0
def handle_Set(x):
    t = aterm.ATConstructor()
    t.setName("Set")
    if hasattr(x, 'elts'):
        elts = x.elts
        tkid = aterm.ATList()
        for elt in elts:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #14
0
def handle_Suite(x):
    t = aterm.ATConstructor()
    t.setName("Suite")
    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #15
0
def handle_If(x):
    t = aterm.ATConstructor()
    t.setName("If")
    test = x.test
    t.addChild(handle(test))

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'orelse'):
        orelse = x.orelse
        tkid = aterm.ATList()
        for elt in orelse:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #16
0
def handle_Compare(x):
    t = aterm.ATConstructor()
    t.setName("Compare")
    left = x.left
    t.addChild(handle(left))

    if hasattr(x, 'ops'):
        ops = x.ops
        tkid = aterm.ATList()
        for elt in ops:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'comparators'):
        comparators = x.comparators
        tkid = aterm.ATList()
        for elt in comparators:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #17
0
def handle_Call(x):
    t = aterm.ATConstructor()
    t.setName("Call")
    func = x.func
    t.addChild(handle(func))

    if hasattr(x, 'args'):
        args = x.args
        tkid = aterm.ATList()
        for elt in args:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'keywords'):
        keywords = x.keywords
        tkid = aterm.ATList()
        for elt in keywords:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'starargs'):
        starargs = x.starargs
        t.addChild(handle(starargs))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'kwargs'):
        kwargs = x.kwargs
        t.addChild(handle(kwargs))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    return t
コード例 #18
0
def handle_GeneratorExp(x):
    t = aterm.ATConstructor()
    t.setName("GeneratorExp")
    elt = x.elt
    t.addChild(handle(elt))

    if hasattr(x, 'generators'):
        generators = x.generators
        tkid = aterm.ATList()
        for elt in generators:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #19
0
def handle_BoolOp(x):
    t = aterm.ATConstructor()
    t.setName("BoolOp")
    op = x.op
    t.addChild(handle(op))

    if hasattr(x, 'values'):
        values = x.values
        tkid = aterm.ATList()
        for elt in values:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #20
0
def handle_Tuple(x):
    t = aterm.ATConstructor()
    t.setName("Tuple")
    if hasattr(x, 'elts'):
        elts = x.elts
        tkid = aterm.ATList()
        for elt in elts:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    ctx = x.ctx
    t.addChild(handle(ctx))

    return t
コード例 #21
0
def handle_Assign(x):
    t = aterm.ATConstructor()
    t.setName("Assign")
    if hasattr(x, 'targets'):
        targets = x.targets
        tkid = aterm.ATList()
        for elt in targets:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    value = x.value
    t.addChild(handle(value))

    return t
コード例 #22
0
ファイル: py2_to_aterm.py プロジェクト: CCA-Forum/compose-hpc
def handle_FunctionDef(x):
    t = aterm.ATConstructor()
    t.setName("FunctionDef")
    name = x.name
    t.addChild(handle(name))

    args = x.args
    t.addChild(handle(args))

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'decorator_list'):
        decorator_list = x.decorator_list
        tkid = aterm.ATList()
        for elt in decorator_list:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #23
0
def handle_For(x):
    t = aterm.ATConstructor()
    t.setName("For")
    target = x.target
    t.addChild(handle(target))

    iter = x.iter
    t.addChild(handle(iter))

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    if hasattr(x, 'orelse'):
        orelse = x.orelse
        tkid = aterm.ATList()
        for elt in orelse:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #24
0
ファイル: py2_to_aterm.py プロジェクト: CCA-Forum/compose-hpc
def handle_arguments(x):
    t = aterm.ATConstructor()
    t.setName("arguments")
    if hasattr(x, 'args'):
        args = x.args
        tkid = aterm.ATList()
        for elt in args:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'vararg'):
        vararg = x.vararg
        t.addChild(handle(vararg))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    #OPTIONAL
    if hasattr(x, 'kwarg'):
        kwarg = x.kwarg
        t.addChild(handle(kwarg))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    if hasattr(x, 'defaults'):
        defaults = x.defaults
        tkid = aterm.ATList()
        for elt in defaults:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #25
0
def handle_DictComp(x):
    t = aterm.ATConstructor()
    t.setName("DictComp")
    key = x.key
    t.addChild(handle(key))

    value = x.value
    t.addChild(handle(value))

    if hasattr(x, 'generators'):
        generators = x.generators
        tkid = aterm.ATList()
        for elt in generators:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #26
0
def handle_comprehension(x):
    t = aterm.ATConstructor()
    t.setName("comprehension")
    target = x.target
    t.addChild(handle(target))

    iter = x.iter
    t.addChild(handle(iter))

    if hasattr(x, 'ifs'):
        ifs = x.ifs
        tkid = aterm.ATList()
        for elt in ifs:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t
コード例 #27
0
ファイル: py2_to_aterm.py プロジェクト: CCA-Forum/compose-hpc
def handle_Print(x):
    t = aterm.ATConstructor()
    t.setName("Print")
    #OPTIONAL
    if hasattr(x, 'dest'):
        dest = x.dest
        t.addChild(handle(dest))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    if hasattr(x, 'values'):
        values = x.values
        tkid = aterm.ATList()
        for elt in values:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    nl = x.nl
    t.addChild(handle(nl))

    return t
コード例 #28
0
ファイル: py2_to_aterm.py プロジェクト: CCA-Forum/compose-hpc
def handle_With(x):
    t = aterm.ATConstructor()
    t.setName("With")
    context_expr = x.context_expr
    t.addChild(handle(context_expr))

    #OPTIONAL
    if hasattr(x, 'optional_vars'):
        optional_vars = x.optional_vars
        t.addChild(handle(optional_vars))
    else:
        tkid = aterm.ATConstant()
        tkid.setValue('None')
        t.addChild(tkid)

    if hasattr(x, 'body'):
        body = x.body
        tkid = aterm.ATList()
        for elt in body:
            tkid.addChild(handle(elt))
        t.addChild(tkid)

    return t