From 01a113891e75cd58ea25185dd1f47fa3532fce86 Mon Sep 17 00:00:00 2001 From: oysteini Date: Sun, 6 Mar 2011 13:00:17 +0000 Subject: [PATCH] Litt fiksing i tmpfil-skriving. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Koder teksten i utf8. La til en bindestrek mellom det ønskede filnavnet og det som genereres. --- python/worblehat.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/worblehat.py b/python/worblehat.py index e030a8e..5c28f2a 100755 --- a/python/worblehat.py +++ b/python/worblehat.py @@ -14,6 +14,8 @@ import search import placement import tempfile +file_encoding = 'utf8' + def show_book_or_person(ids, commit_format=False, tmp_file=False): objects = map(get_book_or_person, ids) for i in range(len(ids)): @@ -218,8 +220,8 @@ def run_editor(filename): exit("Error: %s: File does not exist!" % filename) def write_tmpfile(pfix='', content=''): - file = tempfile.NamedTemporaryFile(prefix=pfix, dir='/tmp', delete=False) - file.write(content) + file = tempfile.NamedTemporaryFile(prefix=pfix+'-', dir='/tmp', delete=False) + file.write(content.encode(file_encoding)) name = file.name file.close() return name