forked from wordpress-mobile/WordPress-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-missing-drawables.py
executable file
·40 lines (35 loc) · 1.1 KB
/
check-missing-drawables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
from collections import defaultdict
from pprint import pprint
import os
import sys
RESDIR="WordPress/src/main/res"
TO_CHECK = ["-hdpi", "-xhdpi", "-xxhdpi"]
def main():
if len(sys.argv) == 2:
check_drawables(sys.argv[1])
else:
check_drawables(RESDIR)
def check_drawables(rootdir):
filenames = defaultdict(set)
results = defaultdict(set)
# scan directories
for subdir, dirs, files in os.walk(rootdir):
for filename in files:
for dpi in TO_CHECK:
if subdir.endswith("drawable" + dpi) and \
filename.endswith("png"):
filenames[subdir].add(filename)
# check missing drawables
for subdir in filenames:
for filename in filenames[subdir]:
for sub in filenames:
if sub == subdir:
continue
if filename not in filenames[sub]:
results[filename].add(sub)
# print results
for i in results:
print(i + " missing in: " + " ".join(results[i]))
if __name__ == "__main__":
main()