8 definitionToFileDict
= {}
10 with
open("workdir/loplugin.finalclasses.log") as txt
:
12 tokens
= line
.strip().split("\t")
17 elif tokens
[0] == "definition:":
19 # the 1.. is so we skip the leading /
20 fileName
= tokens
[2][1:]
21 definitionSet
.add(clazzName
)
22 definitionToFileDict
[clazzName
] = fileName
24 elif tokens
[0] == "inherited-from:":
26 if (parent
.startswith("class ")):
28 elif (parent
.startswith("struct ")):
30 inheritFromSet
.add(parent
);
33 print( "unknown line: " + line
)
36 for clazz
in sorted(definitionSet
- inheritFromSet
):
37 file = definitionToFileDict
[clazz
]
38 # ignore classes defined inside compilation units, the compiler knows they are final already
39 if (".cxx" in file): continue
40 # ignore test and external code
41 if ("/qa/" in file): continue
42 if (file.startswith("workdir/")): continue
43 tmpset
.add((clazz
, file))
45 # sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely
46 def natural_sort_key(s
, _nsre
=re
.compile('([0-9]+)')):
47 return [int(text
) if text
.isdigit() else text
.lower()
48 for text
in re
.split(_nsre
, s
)]
49 def sort_set_by_natural_key(s
):
50 return sorted(s
, key
=lambda v
: natural_sort_key(v
[1]))
52 # print output, sorted by name and line number
53 with
open("compilerplugins/clang/finalclasses.results", "wt") as f
:
54 for t
in sort_set_by_natural_key(tmpset
):
56 f
.write(" " + t
[0] + "\n")