-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdim
More file actions
executable file
·104 lines (86 loc) · 2.9 KB
/
mdim
File metadata and controls
executable file
·104 lines (86 loc) · 2.9 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python
import sys, getopt, os, subprocess
CWD = "/Users/nicolasleloup/scripts/mdim"
VENDORS_DIR = CWD + "/vendors"
MDI_REPO_URL = "https://github.com/google/material-design-icons.git"
MDI_VENDOR_DIR = VENDORS_DIR + '/material-design-icons'
def usage():
print """
Usage:
$ mdim [comand] [options]
mdim, the Material Design Icons Manager for iOS apps.
Commands:
+ require Imports an icon in iOS Xcode project.
Options:
--group The group the icon belongs to.
--icon-name The name of the icon.
--project-src (Optional) The project in whinch you want to import the icon. Default is '.'.
--assets-catalog-name (Optional) The assets catalog in which you want to import the icon. Default is 'Assets.xcassets'.
--rename-with (Optional) The name you want to give the icon.
--help (Optional) the help content.
"""
def execCommand(cmd):
process = os.popen(cmd,"r")
logProcess(process)
def handleColorization(color):
print 'to be defined'
def cloneMDIRepo():
print 'Creating material-design-icons local copy'
execCommand('git clone ' + MDI_REPO_URL + ' ' + MDI_VENDOR_DIR)
def updateMDIRepo():
print 'Updating material-design-icons local copy'
execCommand('cd ' + MDI_VENDOR_DIR + ';git pull origin master')
def logProcess(p):
while 1:
line = p.readline()
if not line: break
print line
def ensureGithubRepoIsAvailable():
if os.path.exists(VENDORS_DIR):
if os.path.isdir(VENDORS_DIR):
if os.path.exists(VENDORS_DIR + '/material-design-icons'):
updateMDIRepo()
else:
cloneMDIRepo()
else:
print 'vendors is not a directory'
else:
print 'Creating vendors directory'
execCommand('mkdir ' + VENDORS_DIR)
cloneMDIRepo()
def main(argv):
group = ""
iconName = ""
projectSrc = "application"
assetsCatalogName = "Assets"
newName = None
try:
opts, args = getopt.getopt(argv, "-h-g:-i:-p:-a:-r", ["help", "group=", "icon-name=", 'project-src=', 'assets-catalog-name=', "rename-with="])
except getopt.GetoptError as err:
print(err)
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-g", "--group"):
group = arg
elif opt in ("-i", "--icon-name"):
iconName = arg
elif opt in ("-p", "--project-src"):
projectSrc = arg
elif opt in ("-a", "--assets-catalog-name"):
assetsCatalogName = arg
elif opt in ("-r", "--rename-with"):
newName = arg
else:
usage()
sys.exit(2)
ensureGithubRepoIsAvailable()
copyCommand = 'cp -r ' + MDI_VENDOR_DIR + '/' + group + '/ios/ic_' + iconName +'.imageset $PWD/' + projectSrc + '/' + assetsCatalogName + '.xcassets/'
if newName is not None:
copyCommand += newName
execCommand(copyCommand)
if __name__ == "__main__":
main(sys.argv[1:])