diff --git a/cli/util.py b/cli/util.py index e207c46..81cd483 100644 --- a/cli/util.py +++ b/cli/util.py @@ -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