Fixed some bugs in write_tmpfile.
This commit is contained in:
parent
6cd76a205d
commit
44553732ca
@ -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
|
||||
|
Reference in New Issue
Block a user