Example #1
0
def save_buf(buf):
    path = get_full_path(buf['path'])
    mkdir(os.path.split(path)[0])
    if buf['encoding'] == 'utf8':
        newline = get_line_endings(path) or editor.get_line_endings(path)
    try:
        with open(path, 'wb') as fd:
            if buf['encoding'] == 'utf8':
                out = buf['buf']
                if newline != '\n':
                    out = out.split('\n')
                    out = newline.join(out)
                fd.write(out.encode('utf-8'))
            else:
                fd.write(buf['buf'])
    except Exception as e:
        msg.error('Error saving buf: %s' % str(e))
Example #2
0
def save_buf(buf):
    path = get_full_path(buf["path"])
    mkdir(os.path.split(path)[0])
    if buf["encoding"] == "utf8":
        newline = get_line_endings(path) or editor.get_line_endings(path)
    try:
        with open(path, "wb") as fd:
            if buf["encoding"] == "utf8":
                out = buf["buf"]
                if newline != "\n":
                    out = out.split("\n")
                    out = newline.join(out)
                fd.write(out.encode("utf-8"))
            else:
                fd.write(buf["buf"])
    except Exception as e:
        msg.error("Error saving buf: ", str_e(e))
Example #3
0
def save_buf(buf):
    path = get_full_path(buf['path'])
    mkdir(os.path.split(path)[0])
    if buf['encoding'] == 'utf8':
        newline = get_line_endings(path) or editor.get_line_endings(path)
    try:
        with open(path, 'wb') as fd:
            if buf['encoding'] == 'utf8':
                out = buf['buf']
                if newline != '\n':
                    out = out.split('\n')
                    out = newline.join(out)
                fd.write(out.encode('utf-8'))
            else:
                fd.write(buf['buf'])
    except Exception as e:
        msg.error('Error saving buf: %s' % str_e(e))