-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate.py
More file actions
45 lines (37 loc) · 1.14 KB
/
create.py
File metadata and controls
45 lines (37 loc) · 1.14 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
# Author: Nikola Plejic, github.com/nikolaplejic
import sys
import os
if len(sys.argv) < 2:
print "I can haz argument?"
exit()
extension_templates = {
"html": "<!-- %s -->\n\n%s",
"kit": "<!-- %s -->\n\n%s",
"php": "<!-- %s -->\n\n%s",
"css": "/* %s */\n\n%s",
"scss": "/* %s */\n\n%s",
"less": "/* %s */\n\n%s",
"js": "/* %s */\n\n%s",
}
csv_separator = ","
file_ext_separator = "|"
build_folder = "build"
opts = open(sys.argv[1]).readlines()
try:
os.mkdir(build_folder)
except OSError, e:
print "%s/ folder exists, continuing..." % build_folder
for opt in opts:
# assumption:
# elements[0] = title
# elements[1] = filename
# elements[2] = file extensions (pipe separated)
# elements[3] = description
elements = opt.split(csv_separator)
exts = [ x for x in elements[2].split(file_ext_separator)
if x in extension_templates.keys() ]
for e in exts:
file_name = "%s/_%s.%s" % (build_folder, elements[1], e)
file_contents = extension_templates[e] % (elements[0], elements[3])
with open(file_name, "w") as outfile:
outfile.write(file_contents)