def file_editor(content):
with tempfile.NamedTemporaryFile(suffix=".roamer") as temp:
if sys.version_info[0] == 3:
content = content.encode('utf-8')
temp.write(content)
temp.flush()
if EXTRA_EDITOR_COMMAND:
exit_code = call([EDITOR, EXTRA_EDITOR_COMMAND, temp.name])
else:
exit_code = call(EDITOR.split() + [temp.name])
if exit_code != 0:
sys.exit()
temp.seek(0)
output = temp.read()
if sys.version_info[0] == 3:
output = output.decode('UTF-8')
return output
评论列表
文章目录