当前位置: 首页>>代码示例>>Python>>正文


Python CallGraphBuilder.build方法代码示例

本文整理汇总了Python中callgraph.builder.CallGraphBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Python CallGraphBuilder.build方法的具体用法?Python CallGraphBuilder.build怎么用?Python CallGraphBuilder.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在callgraph.builder.CallGraphBuilder的用法示例。


在下文中一共展示了CallGraphBuilder.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_methods_two_ctors_and_one_method

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_methods_two_ctors_and_one_method():
    def fun():
        class B(object):
            def __init__(self):
                pass

            def method(self):
                "".lstrip()

        class A(object):
            def __init__(self):
                pass

            def method(self):
                "".rstrip()

        a = A() if None else B()
        a.method()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.B", "fun.method", "fun.method.rstrip",
            "fun.method", "fun.method.lstrip"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:29,代码来源:methods.py

示例2: test_methods_class_change

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_methods_class_change():
    def fun():
        class B(object):
            def __init__(self):
                pass

            def method_b(self):
                pass

        class A(object):
            def __init__(self):
                pass

            def method_a(self):
                pass

        a = A()
        a.method_a()
        a = B()
        a.method_b()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.method_a", "fun.B", "fun.method_b"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:30,代码来源:methods.py

示例3: test_stmt_with_single

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_stmt_with_single():
    class A(object):
        def __init__(self):
            pass

        def __enter__(self):
            b = ""
            b.find()
            return b
        def __exit__(self, t, v, tb):
            c = ""
            c.index()

    def fun():
        with A() as a:
            a.strip()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.__enter__", "fun.__enter__.find", "fun.strip",
            "fun.__exit__", "fun.__exit__.index"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:27,代码来源:stmt.py

示例4: test_decorators_class

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_decorators_class():
    def fun():
        def decorator(cls):
            def decorating():
                return cls()
            return decorating

        @decorator
        class DecoratedClass(object):
            def __init__(self):
                pass

            def method(self):
                pass

        obj = DecoratedClass()
        obj.method()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.decorating", "fun.decorating.DecoratedClass",
            "fun.method"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:28,代码来源:decorators.py

示例5: test_decorators_chain

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_decorators_chain():
    def kuku(function):
        @wraps(function)
        def decorating():
            return function()
        return decorating

    def decorator1(function):
        @wraps(function)
        def decorating1():
            return function()
        return decorating1

    def decorator2(function):
        @wraps(function)
        def decorating2():
            return function()
        return decorating2

    @decorator1
    @decorator2
    def decorated():
        pass

    builder = CallGraphBuilder()
    root = builder.build(decorated)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["decorating1", "decorating1.decorating2",
            "decorating1.decorating2.decorated"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:34,代码来源:decorators.py

示例6: test_assigns_attr_chain_call

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_assigns_attr_chain_call():
    class A(object):
        def __init__(self):
            pass

        def f(self):
            return B()

    class B(object):
        def __init__(self):
            pass

        def method(self):
            pass

    def fun():
        A().f().method()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.f", "fun.f.B", "fun.method"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:27,代码来源:assings.py

示例7: test_stmt_with_tuple

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_stmt_with_tuple():
    class A():
        def __init__(self):
            pass

        def __enter__(self):
            return 1, ""
        def __exit__(self, t, v, tb):
            pass

    def fun():
        with A() as (a, b):
            a.to_bytes(1, "big")
            a.strip()
            b.to_bytes(1, "big")
            b.strip()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.__enter__", "fun.to_bytes", "fun.strip",
            "fun.__exit__"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:27,代码来源:stmt.py

示例8: test_methods_two_ctors_and_method_and_ctor

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_methods_two_ctors_and_method_and_ctor():
    class A(object):
        def __init__(self):
            pass

        def f(self):
            return ""

    class B(object):
        def __init__(self):
            pass

        def f(self):
            return C

    class C(object):
        def __init__(self):
            pass

        def f(self):
            return []

    def fun():
        a = A() if None else B()
        a.f().strip()
        a.f()().f().sort()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.B", "fun.f", "fun.f", "fun.strip", "fun.C",
            "fun.f", "fun.sort"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:37,代码来源:methods.py

示例9: test_classes_self_between_fun

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_classes_self_between_fun():
    class A(object):
        def __init__(self):
            self.a = "str"

        def method(self):
            self.b = "str"

    def fun1():
        a = A()
        a.method()
        return a

    def fun():
        fun1().b.lstrip()
        b = A()
        b.a.rstrip()
        b.b.index()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.fun1", "fun.fun1.A", "fun.fun1.method", "fun.lstrip",
            "fun.A", "fun.rstrip"]

    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:30,代码来源:classes.py

示例10: test_classes_method_super

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_classes_method_super():
    class A(object):
        def __init__(self):
            pass

        def method(self):
            "".rstrip()

    class B(A):
        def __init__(self):
            pass

        def method(self):
            "".lstrip()
            super().method()

    def fun():
        b = B()
        b.method()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.B", "fun.method", "fun.method.lstrip",
            "fun.method.__super__", "fun.method.method",
            "fun.method.method.rstrip"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:31,代码来源:classes.py

示例11: test_generators_from_two_obj

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_generators_from_two_obj():
    class B(object):
        def __init__(self):
            pass

        def __next__(self):
            return ""

    class A(object):
        def __init__(self):
            pass

        def __iter__(self):
            return B()

    def fun():
        for entry in A():
            entry.strip()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree

    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.__iter__", "fun.__iter__.B", "fun.__next__", "fun.strip"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:29,代码来源:generators.py

示例12: test_methods_self_class

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_methods_self_class():
    def fun():
        class A(object):
            def __init__(self):
                pass

            def method(self):
                pass

            @classmethod
            def class_method(cls):
                self.method()

            @staticmethod
            def static_method():
                self.method()

        a = A()
        a.class_method()
        a.static_method()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.A", "fun.class_method", "fun.static_method"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:30,代码来源:methods.py

示例13: test_functions_recur

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_functions_recur():
    def recur():
        recur()

    builder = CallGraphBuilder()
    root = builder.build(recur)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["recur"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:13,代码来源:functions.py

示例14: test_stmt_raise_simple

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_stmt_raise_simple():
    def fun():
        raise RuntimeError()

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.RuntimeError"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:13,代码来源:stmt.py

示例15: test_ops_bin_add

# 需要导入模块: from callgraph.builder import CallGraphBuilder [as 别名]
# 或者: from callgraph.builder.CallGraphBuilder import build [as 别名]
def test_ops_bin_add():
    def fun():
        if "".strip() + "".find(): return

    builder = CallGraphBuilder()
    root = builder.build(fun)
    from callgraph.indent_printer import dump_tree
    dump_tree(root, lambda x: x.children)

    path = ["fun", "fun.strip", "fun.find"]
    assert list(dfs_node_names(root)) == path
开发者ID:burlog,项目名称:py-static-callgraph,代码行数:13,代码来源:ops.py


注:本文中的callgraph.builder.CallGraphBuilder.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。