-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_material_icon_to_res.py
28 lines (24 loc) · 1.01 KB
/
copy_material_icon_to_res.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
import os
import sys
import shutil
import struct
import imghdr
import glob
def main():
if len(sys.argv) != 4:
print('usage : %s <res-folder> <material-design-root-folder> <img-name> \n ex: %s C:\\myproject\\res C:\\material-design-icons-master ic_camera_enhance_white_36dp.png' % (os.path.split(sys.argv[0])[0], os.path.split(sys.argv[0])[0]));
return
MATERIAL_ICONS = glob.glob(os.path.join(sys.argv[2], '*', 'drawable-*', '*.png'));
for material_icon in MATERIAL_ICONS:
if material_icon.endswith(sys.argv[3]):
(root, filename) = os.path.split(material_icon)
(root, folder) = os.path.split(root)
dpi = folder.split('-')[-1]
dst = os.path.join(sys.argv[1], 'drawable-'+dpi)
try:
shutil.copy(material_icon, dst)
print("copied %s to %s\n" %(material_icon, dst))
except:
print("error in copying %s to %s" %(material_icon, dst))
if __name__ == "__main__":
main()