コード例 #1
0
ファイル: doc_example.py プロジェクト: vvoody/Cyberbrain
def func_a(foo):
    for i in range(2):
        pass
    ba = [foo]  # b
    func_c(ba)  # c
    foo = func_f(ba)  # f
    cyberbrain.register(foo)  # target
コード例 #2
0
def main():
    def f(x, y):
        return x + y

    x = 1
    y = f(x, f(1, 1))
    cyberbrain.register(y)
コード例 #3
0
def main():
    def f(x, y):
        return x + y

    x = 1
    y = f(x, f(1,
               1))  # y is our target. TODO: add [1 for x in range(4)] as arg.
    cyberbrain.register()  # register has to be called after init
コード例 #4
0
"""Program that has multiline statements."""

import cyberbrain

cyberbrain.init()  # Can we use import hook to achieve this?

y = {
    "longlonglonglonglonglonglonglong": 1,
    "longlonglonglonglonglonglonglonglong": 2,
    "longlonglonglonglonglonglonglonglonglong": 3,
}

cyberbrain.register(y)  # register has to be called after init
コード例 #5
0
"""Just a hello world."""

import cyberbrain

cyberbrain.init()
x = "hello world"
y = x
cyberbrain.register(y)
コード例 #6
0
ファイル: main.py プロジェクト: cherry003/Cyberbrain
"""Program that invokes functions from other modules."""

import cyberbrain
import foo

cyberbrain.init()
foo.func_in_foo()
cyberbrain.register()
コード例 #7
0
"""Program that invokes functions from other modules."""

import cyberbrain
import foo

cyberbrain.init()
x = foo.func_in_foo()
cyberbrain.register(x)
コード例 #8
0
"""A program that calls functions from Python stdlib and 3rd-party libs.

Since we've excluded events from files in installation path, we shouldn't receive any
events from stdlib or 3rd-party libs. Neither will C calls since they are not catched by
settrace (https://stackoverflow.com/q/16115027/2142577).
"""

from collections import Counter

import crayons

import cyberbrain

cyberbrain.init()
c = Counter()
c["red"] += 1
c["blue"] += 1
c["red"] += 1
c.most_common(10)
crayons.blue("blue")
cyberbrain.register(c)