Created
May 14, 2014 18:51
-
-
Save cshoe/83696dd39f12f3447ef5 to your computer and use it in GitHub Desktop.
Cleanup interviews for Mo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from xml.etree import ElementTree | |
from jinja2 import Template | |
template_string = """{\\rtf1\\ansi\\ansicpg1252\cocoartf1265\cocoasubrtf190 | |
{\\fonttbl\\f0\fswiss\\fcharset0 ArialMT;\\f1\\froman\\fcharset0 Times-Roman;} | |
{\colortbl;\\red255\green255\\blue255;} | |
\margl1440\margr1440\\vieww22060\\viewh14300\\viewkind0 | |
\deftab720 | |
\pard\\tx3571\pardeftab720\sl340 | |
{% for scene in scenes %} | |
\\f0\\fs30 {{ scene.text }} | |
\\f1\\fs24 \page \\ | |
{% endfor %} | |
\pard\pardeftab720 | |
\cf0 \\ | |
} | |
""" | |
def main(in_file, out_file): | |
tree = ElementTree.parse(in_file) | |
t = Template(template_string) | |
output = t.render(scenes=tree.findall('scene')) | |
with open(out_file, 'w') as fh: | |
fh.write(output.encode('utf-8')) | |
if __name__ == '__main__': | |
in_file = sys.argv[1] | |
out_file = sys.argv[2] | |
main(in_file, out_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment