Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Last active August 29, 2015 14:08
Show Gist options
  • Save kracekumar/6e7c1981b2369d5ecc29 to your computer and use it in GitHub Desktop.
Save kracekumar/6e7c1981b2369d5ecc29 to your computer and use it in GitHub Desktop.
CLI for converting stylesheet using inlinestyler
import sys
try:
from inlinestyler.utils import inline_css
except ImportError:
sys.stderr.write("inlinestyler is missing. `pip install inlinestyler == 0.2.0`")
if __name__ == "__main__":
if len(sys.argv) != 3:
sys.stderr.write("python inlinestyler_cli.py input_file_fullpath.html output_file_fullpath.html")
else:
print sys.argv[1:]
with open(sys.argv[1]) as input_file:
content = input_file.read()
output = inline_css(content)
with open(sys.argv[2], 'w') as output_file:
output_file.write(output.encode('utf-8'))
print("completed")
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment