Example #1
0
File: mail.py Project: snits/stgit
def __edit_message(msg):
    fname = '.stgitmail.txt'

    # create the initial file
    with open(fname, 'w') as f:
        f.write(msg)

    call_editor(fname)

    # read the message back
    with open(fname) as f:
        msg = f.read()

    return msg
Example #2
0
File: mail.py Project: snits/stgit
def __edit_message(msg):
    fname = '.stgitmail.txt'

    # create the initial file
    with open(fname, 'w') as f:
        f.write(msg)

    call_editor(fname)

    # read the message back
    with open(fname) as f:
        msg = f.read()

    return msg
Example #3
0
def edit_file(series, line, comment, show_patch=True):
    fname = '.stgitmsg.txt'
    tmpl = templates.get_template('patchdescr.tmpl')

    with open(fname, 'w+') as f:
        if line:
            print(line, file=f)
        elif tmpl:
            print(tmpl, end=' ', file=f)
        else:
            print(file=f)
        print(__comment_prefix, comment, file=f)
        print(__comment_prefix,
              'Lines prefixed with "%s" will be automatically removed.' %
              __comment_prefix,
              file=f)
        print(__comment_prefix,
              'Trailing empty lines will be automatically removed.',
              file=f)

        if show_patch:
            print(__patch_prefix, file=f)
            # series.get_patch(series.get_current()).get_top()
            diff_str = git.diff(
                rev1=series.get_patch(series.get_current()).get_bottom())
            f.write(diff_str)

        # Vim modeline must be near the end.
        print(
            __comment_prefix,
            'vi: set textwidth=75 filetype=diff nobackup:',
            file=f,
        )

    call_editor(fname)

    with open(fname, 'r+') as f:
        __clean_comments(f)
        f.seek(0)
        result = f.read()

    os.remove(fname)

    return result
Example #4
0
File: stack.py Project: snits/stgit
def edit_file(series, line, comment, show_patch = True):
    fname = '.stgitmsg.txt'
    tmpl = templates.get_template('patchdescr.tmpl')

    with open(fname, 'w+') as f:
        if line:
            print(line, file=f)
        elif tmpl:
            print(tmpl, end=' ', file=f)
        else:
            print(file=f)
        print(__comment_prefix, comment, file=f)
        print(__comment_prefix,
              'Lines prefixed with "%s" will be automatically removed.'
              % __comment_prefix, file=f)
        print(__comment_prefix,
              'Trailing empty lines will be automatically removed.', file=f)

        if show_patch:
           print(__patch_prefix, file=f)
           # series.get_patch(series.get_current()).get_top()
           diff_str = git.diff(rev1 = series.get_patch(series.get_current()).get_bottom())
           f.write(diff_str)

        #Vim modeline must be near the end.
        print(__comment_prefix, 'vi: set textwidth=75 filetype=diff nobackup:', file=f)

    call_editor(fname)

    with open(fname, 'r+') as f:
        __clean_comments(f)
        f.seek(0)
        result = f.read()

    os.remove(fname)

    return result