def edit_article(article, directory, editor, repo, default_commit_msg, extension, test, editorflags):
    """edit an article within your docs"""
    # set paths
    a = add_fileextension(article, extension)
    a = os.path.join(directory, a)
    d = os.path.dirname(a)

    # create dir(s)
    if not os.path.isdir(d):
        try:
            os.makedirs(d)
        except OSError:
            print("Error: Creation of path %s is not possible" % d)
            return False

    # start editor
    if test is False:
        try:
            if editorflags is False:
                subprocess.call([editor, a])
            else:
                subprocess.call([editor, editorflags, a])
        except OSError:
            print("Error: '%s' No such file or directory" % editor)
            return False
    else:
        try:
            fp = open(a, "ab+")
            content = "TEST CHANGE"
            fp.write(content)
            fp.close()
        except OSError:
            print("Error: '%s' No such file or directory" % editor)


    # commit into git
    try:
        repo.git.add(a)
        if repo.is_dirty():
            if test is False:
                try:
                    msg = raw_input("Commit message: ")
                    if not msg:
                        msg = default_commit_msg
                except OSError:
                    print("Error: Could not create commit")
            else:
                msg = default_commit_msg
                print("automatic change done")
            try:
                repo.git.commit(m=msg)
            except OSError:
                print("Error: Could not create commit")

        else:
            print("Nothing to commit")
    except (OSError, git.exc.GitCommandError) as e:
        print("Error: Could not create commit")
dataset/ETHPy150Open noqqe/cmddocs/cmddocs/articles.py/edit_article/original