File size: 28,233 Bytes
c7f4bd0
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/graph.py","language":"python","identifier":"Graph.dot","parameters":"(self)","argument_list":"","return_statement":"return self.dot_template.render({ 'nodes': self.nodes, 'edges': self.edges })","docstring":"returns a dot\/graphviz representation of the graph (a string)","docstring_summary":"returns a dot\/graphviz representation of the graph (a string)","docstring_tokens":["returns","a","dot","\/","graphviz","representation","of","the","graph","(","a","string",")"],"function":"def dot(self):\n        'returns a dot\/graphviz representation of the graph (a string)'\n        return self.dot_template.render({ 'nodes': self.nodes, 'edges': self.edges })","function_tokens":["def","dot","(","self",")",":","return","self",".","dot_template",".","render","(","{","'nodes'",":","self",".","nodes",",","'edges'",":","self",".","edges","}",")"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/graph.py#L22-L24"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/graph.py","language":"python","identifier":"Graph.svg","parameters":"(self)","argument_list":"","return_statement":"return completed.stdout.decode('utf-8')","docstring":"returns an svg representation of the graph (via graphviz\/dot)","docstring_summary":"returns an svg representation of the graph (via graphviz\/dot)","docstring_tokens":["returns","an","svg","representation","of","the","graph","(","via","graphviz","\/","dot",")"],"function":"def svg(self):\n        'returns an svg representation of the graph (via graphviz\/dot)'\n        dot_str = self.dot()\n        completed = subprocess.run(['dot', '-Tsvg'], input=dot_str.encode('utf-8'), stdout=subprocess.PIPE)\n        if completed.returncode != 0:\n            raise\n        return completed.stdout.decode('utf-8')","function_tokens":["def","svg","(","self",")",":","dot_str","=","self",".","dot","(",")","completed","=","subprocess",".","run","(","[","'dot'",",","'-Tsvg'","]",",","input","=","dot_str",".","encode","(","'utf-8'",")",",","stdout","=","subprocess",".","PIPE",")","if","completed",".","returncode","!=","0",":","raise","return","completed",".","stdout",".","decode","(","'utf-8'",")"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/graph.py#L26-L32"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/graph.py","language":"python","identifier":"Graph.json","parameters":"(self)","argument_list":"","return_statement":"return json.dumps({ 'nodes' : dict(nodes), 'edges' : dict(edges) }, indent=4, sort=True)","docstring":"returns a json representation of the graph (a string)","docstring_summary":"returns a json representation of the graph (a string)","docstring_tokens":["returns","a","json","representation","of","the","graph","(","a","string",")"],"function":"def json(self):\n        'returns a json representation of the graph (a string)'\n        return json.dumps({ 'nodes' : dict(nodes), 'edges' : dict(edges) }, indent=4, sort=True)","function_tokens":["def","json","(","self",")",":","return","json",".","dumps","(","{","'nodes'",":","dict","(","nodes",")",",","'edges'",":","dict","(","edges",")","}",",","indent","=","4",",","sort","=","True",")"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/graph.py#L34-L36"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/util.py","language":"python","identifier":"to_seconds","parameters":"(string)","argument_list":"","return_statement":"","docstring":"Parse Terraform time interval into an integer representing seconds.","docstring_summary":"Parse Terraform time interval into an integer representing seconds.","docstring_tokens":["Parse","Terraform","time","interval","into","an","integer","representing","seconds","."],"function":"def to_seconds(string):\n    '''Parse Terraform time interval into an integer representing seconds.'''\n    m = re.match(r'(?P<hours>\\d*h)*(?P<minutes>)\\d*m)*(?P<seconds>\\d*s)*', string)\n    if not m:\n        return TypeError\n    d = m.groupdict()","function_tokens":["def","to_seconds","(","string",")",":","m","=","re",".","match","(","r'(?P<hours>\\d*h)*(?P<minutes>)\\d*m)*(?P<seconds>\\d*s)*'",",","string",")","if","not","m",":","return","TypeError","d","=","m",".","groupdict","(",")"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/util.py#L32-L37"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/handlers\/dot.py","language":"python","identifier":"DotGraph.get_node_by_name","parameters":"(self, label)","argument_list":"","return_statement":"return None","docstring":"return node by label (if exists) otherwise simple_name","docstring_summary":"return node by label (if exists) otherwise simple_name","docstring_tokens":["return","node","by","label","(","if","exists",")","otherwise","simple_name"],"function":"def get_node_by_name(self, label):\n        '''return node by label (if exists) otherwise simple_name'''\n        for n in self.nodes:\n            if n.label == label:\n                return n\n\n        for n in self.nodes:\n            if n.simple_name == label:\n                return n\n        \n        return None","function_tokens":["def","get_node_by_name","(","self",",","label",")",":","for","n","in","self",".","nodes",":","if","n",".","label","==","label",":","return","n","for","n","in","self",".","nodes",":","if","n",".","simple_name","==","label",":","return","n","return","None"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/handlers\/dot.py#L65-L75"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/handlers\/dot.py","language":"python","identifier":"DotGraph.dot","parameters":"(self)","argument_list":"","return_statement":"return self.dot_template.render({ 'nodes': self.nodes, 'edges': self.edges, 'clusters' : self.clusters, 'EdgeType' : EdgeType })","docstring":"returns a dot\/graphviz representation of the graph (a string)","docstring_summary":"returns a dot\/graphviz representation of the graph (a string)","docstring_tokens":["returns","a","dot","\/","graphviz","representation","of","the","graph","(","a","string",")"],"function":"def dot(self):\n        'returns a dot\/graphviz representation of the graph (a string)'\n        return self.dot_template.render({ 'nodes': self.nodes, 'edges': self.edges, 'clusters' : self.clusters, 'EdgeType' : EdgeType })","function_tokens":["def","dot","(","self",")",":","return","self",".","dot_template",".","render","(","{","'nodes'",":","self",".","nodes",",","'edges'",":","self",".","edges",",","'clusters'",":","self",".","clusters",",","'EdgeType'",":","EdgeType","}",")"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/handlers\/dot.py#L81-L83"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/handlers\/dot.py","language":"python","identifier":"DotGraph.stack","parameters":"(self, node_type, threshold=2)","argument_list":"","return_statement":"","docstring":"if a group of nodes of type 'type' number as many as 'threshold', \n        and share the same (single) parent and (single) child, then\n        hide their dependencies, and create a chain of pseudo-dependencies \n        so that they stack one above the next in the final diagram.","docstring_summary":"if a group of nodes of type 'type' number as many as 'threshold', \n        and share the same (single) parent and (single) child, then\n        hide their dependencies, and create a chain of pseudo-dependencies \n        so that they stack one above the next in the final diagram.","docstring_tokens":["if","a","group","of","nodes","of","type","type","number","as","many","as","threshold","and","share","the","same","(","single",")","parent","and","(","single",")","child","then","hide","their","dependencies","and","create","a","chain","of","pseudo","-","dependencies","so","that","they","stack","one","above","the","next","in","the","final","diagram","."],"function":"def stack(self, node_type, threshold=2):\n        '''if a group of nodes of type 'type' number as many as 'threshold', \n        and share the same (single) parent and (single) child, then\n        hide their dependencies, and create a chain of pseudo-dependencies \n        so that they stack one above the next in the final diagram.'''\n        new_edges = []\n\n        for n in self.nodes:\n            if n.type != node_type:\n                continue\n\n            parents  = [ e for e in self.edges if e.target == n.label ]\n            children = [ e for e in self.edges if e.source == n.label ]\n\n            if len(children) > 1 or len(parents) != 1:\n                continue\n\n            # setup the cluster.\n            target = children[0].target if len(children) > 0 else ''\n            n.cluster = 'cluster' + parents[0].source + '_' + node_type + '_' + target\n            self.clusters[n.cluster] = True # <-- OrderedDict, used for its ordering. Pretend its a Set\n\n        for cluster in [ cluster for cluster in self.clusters.keys() if re.match('.*_' +  node_type + '_.*', cluster) ]:\n            nodes     = [ n for n in self.nodes if n.cluster == cluster ]\n            prev      = None\n            last_edge = None\n\n            if len(nodes) == 1:\n                continue\n\n            for n in nodes:\n\n                # 1st iteration.\n                if not prev: \n                    for e in self.edges:\n                        if e.source == n.label:\n                            e.edge_type = EdgeType.HIDDEN\n\n                # subsequent iterations.\n                else:\n                    last_edge = None\n                    for e in self.edges:\n                        if e.target == n.label:\n                            e.edge_type = EdgeType.HIDDEN\n                        if e.source == n.label:\n                            e.edge_type = EdgeType.HIDDEN\n                            last_edge = e\n                    new_edges.append(DotEdge(prev.label, n.label, fmt=Format('style=dashed,arrowhead=none'), edge_type=EdgeType.LAYOUT_SHOWN))\n\n                # each iteration.\n                prev = n\n            \n            if last_edge:\n                last_edge.edge_type = EdgeType.NORMAL\n\n        self.edges = self.edges + new_edges","function_tokens":["def","stack","(","self",",","node_type",",","threshold","=","2",")",":","new_edges","=","[","]","for","n","in","self",".","nodes",":","if","n",".","type","!=","node_type",":","continue","parents","=","[","e","for","e","in","self",".","edges","if","e",".","target","==","n",".","label","]","children","=","[","e","for","e","in","self",".","edges","if","e",".","source","==","n",".","label","]","if","len","(","children",")",">","1","or","len","(","parents",")","!=","1",":","continue","# setup the cluster.","target","=","children","[","0","]",".","target","if","len","(","children",")",">","0","else","''","n",".","cluster","=","'cluster'","+","parents","[","0","]",".","source","+","'_'","+","node_type","+","'_'","+","target","self",".","clusters","[","n",".","cluster","]","=","True","# <-- OrderedDict, used for its ordering. Pretend its a Set","for","cluster","in","[","cluster","for","cluster","in","self",".","clusters",".","keys","(",")","if","re",".","match","(","'.*_'","+","node_type","+","'_.*'",",","cluster",")","]",":","nodes","=","[","n","for","n","in","self",".","nodes","if","n",".","cluster","==","cluster","]","prev","=","None","last_edge","=","None","if","len","(","nodes",")","==","1",":","continue","for","n","in","nodes",":","# 1st iteration.","if","not","prev",":","for","e","in","self",".","edges",":","if","e",".","source","==","n",".","label",":","e",".","edge_type","=","EdgeType",".","HIDDEN","# subsequent iterations.","else",":","last_edge","=","None","for","e","in","self",".","edges",":","if","e",".","target","==","n",".","label",":","e",".","edge_type","=","EdgeType",".","HIDDEN","if","e",".","source","==","n",".","label",":","e",".","edge_type","=","EdgeType",".","HIDDEN","last_edge","=","e","new_edges",".","append","(","DotEdge","(","prev",".","label",",","n",".","label",",","fmt","=","Format","(","'style=dashed,arrowhead=none'",")",",","edge_type","=","EdgeType",".","LAYOUT_SHOWN",")",")","# each iteration.","prev","=","n","if","last_edge",":","last_edge",".","edge_type","=","EdgeType",".","NORMAL","self",".","edges","=","self",".","edges","+","new_edges"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/handlers\/dot.py#L96-L151"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/handlers\/dot.py","language":"python","identifier":"DotGraph.set_module_depth","parameters":"(self, depth)","argument_list":"","return_statement":"","docstring":"group resources belonging to modules into a single node, to simplify \n        presentation. No claims made for this code. It's garbage!","docstring_summary":"group resources belonging to modules into a single node, to simplify \n        presentation. No claims made for this code. It's garbage!","docstring_tokens":["group","resources","belonging","to","modules","into","a","single","node","to","simplify","presentation",".","No","claims","made","for","this","code",".","It","s","garbage!"],"function":"def set_module_depth(self, depth):\n        \"\"\"\n        group resources belonging to modules into a single node, to simplify \n        presentation. No claims made for this code. It's garbage!\n       \"\"\"\n\n        depth += 1 # account for [root] module\n\n        def is_too_deep(modules):\n            if len(modules) >= depth and modules[0] != 'root':\n                return True\n\n        def find_edge(edges, e):\n            for edge in edges:\n                if e.source == edge.source and e.target == edge.target and e.edge_type == edge.edge_type:\n                    return True\n            return False\n        \n        # find DotNodes at too great a depth.\n        too_deep     = [ n for n in self.nodes if is_too_deep(n.modules) ]\n\n        # generate ModuleNodes to stand-in for DotNodes at too great a depth.\n        placeholders = []\n        for n in too_deep:\n            match = False\n            for p in placeholders:\n                if p.is_standin(n.modules):\n                    match = True\n                    break\n            if match == False:\n                placeholders.append(ModuleNode(n.modules[:depth]))\n\n        # create replacement edges\n        new_edges = []\n        for e in self.edges:\n            src_mods = DotNode._label_to_modules(e.source)\n            tgt_mods = DotNode._label_to_modules(e.target)\n\n            if is_too_deep(src_mods) and is_too_deep(tgt_mods):\n                continue\n            elif is_too_deep(src_mods):\n                for p in placeholders:\n                    if p.is_standin(src_mods):\n                        replace = True\n                        for ne in new_edges:\n                            if ne.source == p.label and ne.target == e.target:\n                                replace = False\n                                break\n                        if replace:\n                            new_edges.append(DotEdge(p.label, e.target, fmt=Format('')))\n                        break\n            elif is_too_deep(tgt_mods):\n                for p in placeholders:\n                    if p.is_standin(tgt_mods):\n                        replace = True\n                        for ne in new_edges:\n                            if ne.source == e.source and ne.target == p.label:\n                                replace = False\n                                break\n                        if replace:\n                            new_edges.append(DotEdge(e.source, p.label, fmt=Format('')))\n                        break\n            else:\n                new_edges.append(e)\n\n        # make sure we haven't got any duplicate edges.\n        final_edges = []\n        for e in new_edges:\n            if not find_edge(final_edges, e):\n                final_edges.append(e)\n        self.edges = final_edges\n\n        # add placeholder nodes, remove nodes beyond specified module_depth.\n        self.nodes = list(OrderedSet(placeholders) | (OrderedSet(self.nodes) - OrderedSet(too_deep)))","function_tokens":["def","set_module_depth","(","self",",","depth",")",":","depth","+=","1","# account for [root] module","def","is_too_deep","(","modules",")",":","if","len","(","modules",")",">=","depth","and","modules","[","0","]","!=","'root'",":","return","True","def","find_edge","(","edges",",","e",")",":","for","edge","in","edges",":","if","e",".","source","==","edge",".","source","and","e",".","target","==","edge",".","target","and","e",".","edge_type","==","edge",".","edge_type",":","return","True","return","False","# find DotNodes at too great a depth.","too_deep","=","[","n","for","n","in","self",".","nodes","if","is_too_deep","(","n",".","modules",")","]","# generate ModuleNodes to stand-in for DotNodes at too great a depth.","placeholders","=","[","]","for","n","in","too_deep",":","match","=","False","for","p","in","placeholders",":","if","p",".","is_standin","(","n",".","modules",")",":","match","=","True","break","if","match","==","False",":","placeholders",".","append","(","ModuleNode","(","n",".","modules","[",":","depth","]",")",")","# create replacement edges","new_edges","=","[","]","for","e","in","self",".","edges",":","src_mods","=","DotNode",".","_label_to_modules","(","e",".","source",")","tgt_mods","=","DotNode",".","_label_to_modules","(","e",".","target",")","if","is_too_deep","(","src_mods",")","and","is_too_deep","(","tgt_mods",")",":","continue","elif","is_too_deep","(","src_mods",")",":","for","p","in","placeholders",":","if","p",".","is_standin","(","src_mods",")",":","replace","=","True","for","ne","in","new_edges",":","if","ne",".","source","==","p",".","label","and","ne",".","target","==","e",".","target",":","replace","=","False","break","if","replace",":","new_edges",".","append","(","DotEdge","(","p",".","label",",","e",".","target",",","fmt","=","Format","(","''",")",")",")","break","elif","is_too_deep","(","tgt_mods",")",":","for","p","in","placeholders",":","if","p",".","is_standin","(","tgt_mods",")",":","replace","=","True","for","ne","in","new_edges",":","if","ne",".","source","==","e",".","source","and","ne",".","target","==","p",".","label",":","replace","=","False","break","if","replace",":","new_edges",".","append","(","DotEdge","(","e",".","source",",","p",".","label",",","fmt","=","Format","(","''",")",")",")","break","else",":","new_edges",".","append","(","e",")","# make sure we haven't got any duplicate edges.","final_edges","=","[","]","for","e","in","new_edges",":","if","not","find_edge","(","final_edges",",","e",")",":","final_edges",".","append","(","e",")","self",".","edges","=","final_edges","# add placeholder nodes, remove nodes beyond specified module_depth.","self",".","nodes","=","list","(","OrderedSet","(","placeholders",")","|","(","OrderedSet","(","self",".","nodes",")","-","OrderedSet","(","too_deep",")",")",")"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/handlers\/dot.py#L153-L226"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/handlers\/dot.py","language":"python","identifier":"DotGraph.center","parameters":"(self, node)","argument_list":"","return_statement":"","docstring":"prunes graph to include only (1) the given node, (2) its \n        dependencies, and nodes that depend on it.","docstring_summary":"prunes graph to include only (1) the given node, (2) its \n        dependencies, and nodes that depend on it.","docstring_tokens":["prunes","graph","to","include","only","(","1",")","the","given","node","(","2",")","its","dependencies","and","nodes","that","depend","on","it","."],"function":"def center(self, node):\n        '''\n        prunes graph to include only (1) the given node, (2) its \n        dependencies, and nodes that depend on it.\n        '''\n        edges_by_source = {}\n        for e in self.edges:\n            if e.source in edges_by_source:\n                edges_by_source[e.source].append(e)\n            else:\n                edges_by_source[e.source] = [ e ]\n\n        edges_by_target = {}\n        for e in self.edges: \n            if e.target in edges_by_target:\n                edges_by_target[e.target].append(e)\n            else:\n                edges_by_target[e.target] = [ e ]\n\n        edges_to_save = OrderedSet() # edge objects\n        nodes_to_save = OrderedSet() # label strings\n\n        q = deque()\n        if node.label in edges_by_source:\n            q.append(node.label)\n            nodes_to_save.add(node.label)\n            while len(q) > 0:\n                source = q.pop()\n                if source in edges_by_source:\n                    for e in edges_by_source[source]:\n                        q.append(e.target)\n                        edges_to_save.add(e)\n                        nodes_to_save.add(e.target)\n\n        q = deque()\n        if node.label in edges_by_target:\n            q.append(node.label)\n            nodes_to_save.add(node.label)\n            while len(q) > 0:\n                target = q.pop()\n                if target in edges_by_target:\n                    for e in edges_by_target[target]:\n                        q.append(e.source)\n                        edges_to_save.add(e)\n                        nodes_to_save.add(e.source)\n\n        self.edges = list(edges_to_save)\n        self.nodes = [ n for n in self.nodes if n.label in nodes_to_save ]","function_tokens":["def","center","(","self",",","node",")",":","edges_by_source","=","{","}","for","e","in","self",".","edges",":","if","e",".","source","in","edges_by_source",":","edges_by_source","[","e",".","source","]",".","append","(","e",")","else",":","edges_by_source","[","e",".","source","]","=","[","e","]","edges_by_target","=","{","}","for","e","in","self",".","edges",":","if","e",".","target","in","edges_by_target",":","edges_by_target","[","e",".","target","]",".","append","(","e",")","else",":","edges_by_target","[","e",".","target","]","=","[","e","]","edges_to_save","=","OrderedSet","(",")","# edge objects","nodes_to_save","=","OrderedSet","(",")","# label strings","q","=","deque","(",")","if","node",".","label","in","edges_by_source",":","q",".","append","(","node",".","label",")","nodes_to_save",".","add","(","node",".","label",")","while","len","(","q",")",">","0",":","source","=","q",".","pop","(",")","if","source","in","edges_by_source",":","for","e","in","edges_by_source","[","source","]",":","q",".","append","(","e",".","target",")","edges_to_save",".","add","(","e",")","nodes_to_save",".","add","(","e",".","target",")","q","=","deque","(",")","if","node",".","label","in","edges_by_target",":","q",".","append","(","node",".","label",")","nodes_to_save",".","add","(","node",".","label",")","while","len","(","q",")",">","0",":","target","=","q",".","pop","(",")","if","target","in","edges_by_target",":","for","e","in","edges_by_target","[","target","]",":","q",".","append","(","e",".","source",")","edges_to_save",".","add","(","e",")","nodes_to_save",".","add","(","e",".","source",")","self",".","edges","=","list","(","edges_to_save",")","self",".","nodes","=","[","n","for","n","in","self",".","nodes","if","n",".","label","in","nodes_to_save","]"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/handlers\/dot.py#L229-L276"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/handlers\/dot.py","language":"python","identifier":"DotGraph.focus","parameters":"(self, node)","argument_list":"","return_statement":"","docstring":"prunes graph to include only the given node and its dependencies.","docstring_summary":"prunes graph to include only the given node and its dependencies.","docstring_tokens":["prunes","graph","to","include","only","the","given","node","and","its","dependencies","."],"function":"def focus(self, node):\n        '''\n        prunes graph to include only the given node and its dependencies.\n        '''\n        edges_by_source = {}\n        for e in self.edges:\n            if e.source in edges_by_source:\n                edges_by_source[e.source].append(e)\n            else:\n                edges_by_source[e.source] = [ e ]\n\n        edges_to_save = OrderedSet() # edge objects\n        nodes_to_save = OrderedSet() # label strings\n\n        q = deque()\n        if node.label in edges_by_source:\n            q.append(node.label)\n            nodes_to_save.add(node.label)\n            while len(q) > 0:\n                source = q.pop()\n                if source in edges_by_source:\n                    for e in edges_by_source[source]:\n                        q.append(e.target)\n                        edges_to_save.add(e)\n                        nodes_to_save.add(e.target)\n\n        self.edges = list(edges_to_save)\n        self.nodes = [ n for n in self.nodes if n.label in nodes_to_save ]","function_tokens":["def","focus","(","self",",","node",")",":","edges_by_source","=","{","}","for","e","in","self",".","edges",":","if","e",".","source","in","edges_by_source",":","edges_by_source","[","e",".","source","]",".","append","(","e",")","else",":","edges_by_source","[","e",".","source","]","=","[","e","]","edges_to_save","=","OrderedSet","(",")","# edge objects","nodes_to_save","=","OrderedSet","(",")","# label strings","q","=","deque","(",")","if","node",".","label","in","edges_by_source",":","q",".","append","(","node",".","label",")","nodes_to_save",".","add","(","node",".","label",")","while","len","(","q",")",">","0",":","source","=","q",".","pop","(",")","if","source","in","edges_by_source",":","for","e","in","edges_by_source","[","source","]",":","q",".","append","(","e",".","target",")","edges_to_save",".","add","(","e",")","nodes_to_save",".","add","(","e",".","target",")","self",".","edges","=","list","(","edges_to_save",")","self",".","nodes","=","[","n","for","n","in","self",".","nodes","if","n",".","label","in","nodes_to_save","]"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/handlers\/dot.py#L278-L305"}
{"nwo":"28mm\/blast-radius","sha":"a7ec4ef78141ab0d2a688c65112f799adb9622ba","path":"blastradius\/handlers\/dot.py","language":"python","identifier":"ModuleNode.is_standin","parameters":"(self, modules)","argument_list":"","return_statement":"return True","docstring":"should this ModuleNode standin for the provided DotNode?","docstring_summary":"should this ModuleNode standin for the provided DotNode?","docstring_tokens":["should","this","ModuleNode","standin","for","the","provided","DotNode?"],"function":"def is_standin(self, modules):\n        'should this ModuleNode standin for the provided DotNode?'\n        if len(modules) < len(self.modules):\n            return False\n        for i in range(len(self.modules)):\n            if self.modules[i] != modules[i]:\n                return False\n        return True","function_tokens":["def","is_standin","(","self",",","modules",")",":","if","len","(","modules",")","<","len","(","self",".","modules",")",":","return","False","for","i","in","range","(","len","(","self",".","modules",")",")",":","if","self",".","modules","[","i","]","!=","modules","[","i","]",":","return","False","return","True"],"url":"https:\/\/github.com\/28mm\/blast-radius\/blob\/a7ec4ef78141ab0d2a688c65112f799adb9622ba\/blastradius\/handlers\/dot.py#L484-L491"}