Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created August 12, 2009 03:04
Show Gist options
  • Save mlbright/166282 to your computer and use it in GitHub Desktop.
Save mlbright/166282 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# take a master css file and inject @import css files into it.
import re, os, sys
bigcss = []
path = sys.argv[1]
output = sys.argv[2]
fd = open(path + os.sep + 'styles.css')
styles = ""
for line in fd.readlines():
match = re.match(r"@import \"(.*)\"", line)
if match:
cssname = match.group(1)
cssfd = open(path + os.sep + cssname)
bigcss.append(cssfd.read())
else:
styles = styles + line
fd.close()
bigcss.append(styles)
f = open(output, 'w+')
f.write(''.join(bigcss))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment