99import networkx as nx
1010
1111from include_analysis import IncludeAnalysisOutput , ParseError , load_include_analysis
12- from typing import Optional , Tuple
12+ from typing import Optional , Set , Tuple
1313from utils import create_graph_from_include_analysis
1414
1515
@@ -26,6 +26,8 @@ def create_include_graph(
2626
2727 if DG .has_edge (includer_idx , included_idx ):
2828 DG .remove_edge (includer_idx , included_idx )
29+ else :
30+ logging .warning (f"Skip edge { includer } -> { included } not found in include graph" )
2931
3032 return DG
3133
@@ -56,7 +58,7 @@ def main():
5658 help = "The include analysis output to use (can be a file path or URL). If not specified, pulls the latest." ,
5759 )
5860 parser .add_argument ("target" , help = "Target file." )
59- parser .add_argument ("--skips" , help = "Edges to remove from the graph." )
61+ parser .add_argument ("--skips" , action = "append" , default = [], help = "Edges to remove from the graph." )
6062 parser .add_argument ("--verbose" , action = "store_true" , default = False , help = "Enable verbose logging." )
6163 args = parser .parse_args ()
6264
@@ -77,13 +79,15 @@ def main():
7779 print (f"error: { target } is not a known file" )
7880 return 1
7981
80- skips : Tuple [Tuple [str , str ]] = []
82+ skips : Set [Tuple [str , str ]] = set ()
8183
82- if args .skips :
83- with open (args .skips , "r" , newline = "" ) as f :
84- skips = [row for row in csv .reader (f ) if row ]
84+ for skips_file in args .skips :
85+ with open (skips_file , "r" , newline = "" ) as f :
86+ skips .update (
87+ [tuple (row ) for row in csv .reader (f ) if row and row [0 ].strip () and not row [0 ].startswith ("#" )]
88+ )
8589
86- DG = create_include_graph (include_analysis , skips )
90+ DG = create_include_graph (include_analysis , tuple ( skips ) )
8791
8892 try :
8993 reachable_roots = count_reachable_roots (include_analysis , DG , args .target )
0 commit comments