Created
June 27, 2013 09:15
-
-
Save orip/5875131 to your computer and use it in GitHub Desktop.
Summarize the warning categories printed by Android Lint. Usage:
lint <src_dir> | android_lint_summarizer.py Reference: http://developer.android.com/tools/help/lint.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Sample usage: | |
# | |
# % lint my_android_app | android_lint_summarizer.py | |
# 26 SpUsage | |
# 10 I18N HardcodedText | |
# 8 Accessibility ContentDescription | |
# 2 Typos | |
# 1 IconDuplicates | |
import fileinput, collections | |
def extract_one_braced(s): | |
start_pos = s.find("[") | |
if start_pos < 0: | |
return None, None | |
end_pos = s.find("]", start_pos) | |
if end_pos < 0: | |
return None, None | |
return s[start_pos+1:end_pos], s[end_pos+1:] | |
def parse_braced(line): | |
groups = [] | |
s = line.strip() | |
while s: | |
x, s = extract_one_braced(s) | |
if x: groups.append(x) | |
return " ".join(groups) | |
def has_braced(line): | |
start = line.find('[') | |
return start >= 0 and line.find(']', start+1) >= 0 | |
def main(): | |
warning_counts = collections.Counter(parse_braced(line) for line in fileinput.input() if has_braced(line)).most_common() | |
_, max_count = warning_counts[0] | |
fmt = "{count:%d} {name}" % len(str(max_count)) | |
for name, count in warning_counts: | |
print fmt.format(count=count, name=name) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment