Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0

Litt fiksing i tmpfil-skriving.

Koder teksten i utf8.

La til en bindestrek mellom det ønskede filnavnet og det som
genereres.
This commit is contained in:
Øystein Ingmar Skartsæterhagen 2011-03-06 13:00:17 +00:00
parent ae465733f6
commit 01a113891e
1 changed files with 4 additions and 2 deletions

View File

@ -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