コード例 #1
0
ファイル: dump2dot.py プロジェクト: ryppl/ryppl-cmake
def run(dump_dir=None):
    g = dumps = read_dumps(dump_dir)

    # find all strongly-connected components
    from SCC import SCC
    successors = Successors(g)
    sccs = SCC(str, lambda i: successors(g, i)).getsccs(g)
    # map each vertex to a scc set
    scc = {}
    for component in sccs:
        s = set(component)
        for u in s:
            scc[u] = s

    long_sccs = [s for s in sccs if len(s) > 1]
    print 'long_sccs=', long_sccs

    # color each vertex in an SCC of size > 1 according to its SCC
    color = {}
    for i,s in enumerate(long_sccs):
        for u in s:
            color[u] = colors[i]

    if '--all' in sys.argv[1:]:
        V = g
    else:
        V = set(u for u in g if successors(g,u))

    direct_graph = to_mutable_graph(g, direct_successors, V.__contains__)

    t_redux = to_mutable_graph(g, UsageSuccessors(g), vertex_filter=V.__contains__)
    inplace_transitive_reduction(t_redux)

    class Format(object):
        def vertex_attributes(self, s):
            ret = ['color='+color[s]] if s in color else []
            ret += ['fontsize=9']
            if dumps[s].find('libraries/library') is not None:
                ret+=['shape=box3d','style=bold']
            return ret

        def edge_attributes(self, s, t):
            if t in direct_graph[s]:
                return ['style=bold']
            elif t in t_redux[s]:
                return ['style=dashed','arrowhead=open','color=blue']
            else:
                return ['style=dotted','color=gray']

    if '--all' in sys.argv[1:]:
        full_graph = dict((v, direct_graph[v] | t_redux[v]) for v in g)
        show_digraph(full_graph, formatter=Format(), layout='neato', overlap='scalexy', ordering='out', splines='true')
    else:
        full_graph = to_mutable_graph(g, vertex_filter=V.__contains__)
        show_digraph(full_graph, formatter=Format(), ranksep=1.8, splines='true', layout='dot')
コード例 #2
0
ファイル: make_boost_feeds.py プロジェクト: ryppl/ryppl-cmake
    def __init__(self, dump_dir, feed_dir, source_root, site_metadata_file):
        self.dump_dir = dump_dir
        self.feed_dir = feed_dir
        self.source_root = source_root

        self.dumps = read_dumps(self.dump_dir)

        self.transitive_dependencies = to_mutable_graph(self.dumps)
        inplace_transitive_closure(self.transitive_dependencies)
        
        # eliminate self-loops
        for v0,v1s in self.transitive_dependencies.items():
            v1s.discard(v0)
        
        # Make sure there are no modularity violations
        self._find_dependency_cycles()
        
        self.version = '1.49-post-' + datetime.utcnow().strftime("%Y%m%d%H%M")
        print '### new version =', self.version

        print '### reading Boost library metadata...'
        t = ElementTree()
        t.parse(site_metadata_file)
        self.boost_metadata = t.getroot().findall('library')

        self._delete_old_feeds()
            
        use_threads = True
        if use_threads: 
            self.tasks = threadpool.ThreadPool(8)
        else:
            class Tasks(object): 
                def add_task(self, f, *args): return f(*args)
            self.tasks = Tasks()

        for cluster in self.clusters:
            self.tasks.add_task(self._write_cluster_feed, cluster)

        for cmake_name in self.dumps:
            self.GenerateRepo(self, cmake_name)

        print '### Awaiting completion...'
        self.tasks.wait_completion()
        print '### Done.'
コード例 #3
0
ファイル: depgraph.py プロジェクト: ryppl/ryppl-cmake
def run(dump_dir=None):
    from read_dumps import read_dumps
    from display_graph import show_digraph, show_digraph2
    from transitive import inplace_transitive_reduction

    dumps = read_dumps(dump_dir)

    direct = to_mutable_graph(dumps, direct_successors)
    usage = to_mutable_graph(dumps, usage_successors)

    inplace_transitive_reduction(direct)
    inplace_transitive_reduction(usage)

    show_digraph2(direct, usage, layout="neato", overlap="false", splines="True")

    # from pprint import pprint
    # pprint(direct)

    from SCC import SCC

    sccs = SCC(str, lambda i: successors(dumps, i)).getsccs(dumps)
    long_sccs = [s for s in sccs if len(s) > 1]
    assert len(long_sccs) == 0, str(long_sccs)