Skip to content

Instantly share code, notes, and snippets.

@cshoe
Created May 14, 2014 18:51
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 cshoe/83696dd39f12f3447ef5 to your computer and use it in GitHub Desktop.
Save cshoe/83696dd39f12f3447ef5 to your computer and use it in GitHub Desktop.
Cleanup interviews for Mo.
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