예제 #1
0
파일: functions.py 프로젝트: kulisty/sova
def retrieve(repository):
    functions = repository.retrieve_functions()
    names = {
        (n,repository.address_functions(f,n,l))
        for (n,f,l) in functions
    }
    files = {
        (f,repository.address_files(f))
        for (n,f,l) in functions
    }
    ni = list(a for (n,a) in names)
    nf = list(a for (f,a) in files)
    idx = ni+nf+['.']
    #print(idx)
    #
    graph = model.Graph([],[])
    #
    for (n,a) in names:
        graph.nodes.append(model.Node(n, 'Function', idx.index(a), a, 2))
    for (f,a) in files:
        graph.nodes.append(model.Node(f, 'File', idx.index(a), a, 1))
    graph.nodes.append(model.Node('.', 'File', idx.index('.'), repository.origin))
    for (n,f,l) in functions:
        graph.links.append(model.Link( idx.index(repository.address_files(f)), idx.index(repository.address_functions(f,n,l)), 1, 2))
    for (f,a) in files:
        graph.links.append(model.Link( idx.index(a), idx.index('.'), 1, 1))
    #for (c, p) in parents:
    #    graph.links.append(model.Link( idx.index(c), idx.index(p), 2))
    return graph
예제 #2
0
파일: features.py 프로젝트: kulisty/sova
def retrieve(repository):
    features = repository.retrieve_features()
    names = {
        (n,repository.address_functions(f,n,l),ff[0])
        for (n,f,l,ff) in features
    }
    files = {
        (f,repository.address_files(f))
        for (n,f,l,ff) in features
    }
    ni = list(a for (n,a,c) in names)
    nf = list(a for (f,a) in files)
    idx = ni+nf+['.']
    #print(idx)
    #
    graph = model.Graph([],[])
    #
    for (n,a,c) in names:
        graph.nodes.append( model.Node(name = n, group = 'Function', id = idx.index(a), url = a, visibility = 2, complexity = 5+float(c)/3) )
    for (f,a) in files:
        graph.nodes.append( model.Node(name = f, group = 'File', id = idx.index(a), url = a, visibility = 1, complexity = 4.0))
    #
    graph.nodes.append( model.Node(name = '.', group = 'File', id = idx.index('.'), url = repository.origin, complexity = 6.0) )
    #
    for (n,f,l,ff) in features:
        graph.links.append(model.Link(idx.index(repository.address_files(f)), idx.index(repository.address_functions(f,n,l)), 1, visibility = 2))
    for (f,a) in files:
        graph.links.append(model.Link(idx.index(a), idx.index('.'), 1, visibility = 1))
    #for (c, p) in parents:
    #    graph.links.append(model.Link( idx.index(c), idx.index(p), 2))
    return graph