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

Fixed some bugs in write_tmpfile.

This commit is contained in:
Øystein Ingmar Skartsæterhagen 2011-10-08 18:10:10 +00:00
parent 6cd76a205d
commit 44553732ca
1 changed files with 5 additions and 2 deletions

View File

@ -1,3 +1,6 @@
import os
import tempfile
def make_result_dict(cursor, row):
d = {}
for i in xrange(len(row)):
@ -82,9 +85,9 @@ def run_editor(filename):
else:
exit("Error: %s: File does not exist!" % filename)
def write_tmpfile(pfix='', content=''):
def write_tmpfile(pfix, content, encoding='utf8'):
file = tempfile.NamedTemporaryFile(prefix=pfix+'-', dir='/tmp', delete=False)
file.write(content.encode(file_encoding))
file.write(content.encode(encoding))
name = file.name
file.close()
return name