Skip to content

Instantly share code, notes, and snippets.

@abitrolly
Last active October 2, 2017 09:37
Show Gist options
  • Save abitrolly/6ab1af736760d78ef6b03a2307a67c55 to your computer and use it in GitHub Desktop.
Save abitrolly/6ab1af736760d78ef6b03a2307a67c55 to your computer and use it in GitHub Desktop.
Count Rust compile warning from build log
#!/usr/bin/env python
logfile = 'log.txt?deansi=true'
import re
from collections import OrderedDict as odict
compiling = re.compile('^ *Compiling ([-\w]+) ([^\( ]+)')
warning = re.compile('^warning: (.*)')
# lib, warnings
table = odict()
lib = None
for line in open(logfile, 'rb'):
match = compiling.match(line.strip())
if match != None:
lib, version = match.groups()
lib = lib + " " + version
table[lib] = 0
else:
match = warning.match(line.strip())
if match != None:
#print(line)
table[lib] += 1
for lib in table:
if table[lib] != 0:
print("{1:5} {0}".format(lib, table[lib]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment