From 4e96b97c84ae5f3d91995fc1f7e926d723df237d Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 22 Nov 2014 17:24:18 +0100 Subject: jinja stream api --- imdb-lookup/imdbinfo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/imdb-lookup/imdbinfo.py b/imdb-lookup/imdbinfo.py index 1e60fa7..5a4c7fe 100755 --- a/imdb-lookup/imdbinfo.py +++ b/imdb-lookup/imdbinfo.py @@ -179,8 +179,11 @@ def do_index(args, imdb_ids): 'title' : 'Movie overview', } assert not os.path.exists("index.html"), "index.html already exists" - output = template.render(mapping).encode("utf-8") - open("index.html", "wb").write(output) + stream = template.generate(mapping) + outfile = open("index.html", "wb") + for output in stream: + output = output.encode("utf-8") + outfile.write(output) class HelpAction(argparse._HelpAction): def __call__(self, parser, namespace, values, option_string=None): -- cgit v1.2.1