Skip to content

Instantly share code, notes, and snippets.

@nikolaplejic
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikolaplejic/e23888a713cd8f295e8d to your computer and use it in GitHub Desktop.
Save nikolaplejic/e23888a713cd8f295e8d to your computer and use it in GitHub Desktop.
Interface Inventory Thingy
import sys
import os
if len(sys.argv) < 2:
print "I can haz argument?"
exit()
extension_templates = {
"html": "<!-- %s -->\n\n%s",
"scss": "/* %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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment