36 from sys
import getfilesystemencoding
38 OUTPUT_ENCODING = getfilesystemencoding()
44 def write(file_path, lines, windows_mode, mode='w'):
45 if not os.path.exists(os.path.dirname(file_path)):
46 os.makedirs(os.path.dirname(file_path))
48 f = codecs.open(file_path, mode=windows_mode)
50 if isinstance(item, str):
51 enc_arg = item.encode(
'UTF-8')
56 f.write(
"\n".encode(OUTPUT_ENCODING))
58 f.write(bytes(item,
'UTF-8'))
61 f = codecs.open(file_path, mode,
"UTF-8")
62 f.write(
"\n".join(lines))
def write(file_path, lines, windows_mode, mode='w')