<commit_before>
function Py2blockEditor(py2block_conveter, ace_editor){
    this.convert = py2block_conveter;
    this.editor = ace_editor;
    this.silentText = false;
    this.silentBlock = false;
    this.lastCodeSnapshot = "";
    this.fromCode = false;
}

Py2blockEditor.prototype.isFuncStartLine = function(line){
    return /^ *?def *?.*?\(.*?\): *?$/.test(line);
}

Py2blockEditor.prototype.isEmptyNewLine = function(line){
    return /^ +?$/.test(line) || line == "";
}

Py2blockEditor.prototype.getIndentOfLine = function(line){
    for(var i = 0 ; i < line.length ; i ++){
        if(line[i] != " "){
            return i;
        }
    }
    return 0;
}

//为函数定义前后增加空行
Py2blockEditor.prototype.addNewLines = function(python_code){
    python_code = python_code.replace("\r\n", "\n")
                            .replace("\r", "\n")
                            .replace("\t", "    ");
    var lines = python_code.split("\n");
    var isFirstLine = true;
    var isNewLine = false;
    var isFuncDefScope = false;
    var indent = 0;
    var new_python_code = "";
    var newLine = "";
    //遍历每行
    for(var i = 0 ; i < lines.length ; i ++){
        var line = lines[i];
        //函数定义的开始行（def XXX()）
        if(this.isFuncStartLine(line)){
            isFuncDefScope = true;
            indent = this.getIndentOfLine(line);
            if(!isFirstLine && !isNewLine){
                line = "\n" + line;
            }
        }else if(isFuncDefScope && this.getIndentOfLine(line) <= indent){//函数定义结束后的第一行
            if(!this.isEmptyNewLine(line)){
               line = "\n" + line;
            }
            isFuncDefScope = false;
        }
        //是否是空行
        if(this.isEmptyNewLine(line)){
            isNewLine = true;
        }else{
            isNewLine = false;<commit_msg>fix empty line in function def<commit_after>
function Py2blockEditor(py2block_conveter, ace_editor){
    this.convert = py2block_conveter;
    this.editor = ace_editor;
    this.silentText = false;
    this.silentBlock = false;
    this.lastCodeSnapshot = "";
    this.fromCode = false;
}

Py2blockEditor.prototype.isFuncStartLine = function(line){
    return /^ *?def *?.*?\(.*?\): *?$/.test(line);
}

Py2blockEditor.prototype.isEmptyNewLine = function(line){
    return /^ +?$/.test(line) || line == "";
}

Py2blockEditor.prototype.getIndentOfLine = function(line){
    for(var i = 0 ; i < line.length ; i ++){
        if(line[i] != " "){
            return i;
        }
    }
    return 0;
}

//为函数定义前后增加空行
Py2blockEditor.prototype.addNewLines = function(python_code){
    python_code = python_code.replace("\r\n", "\n")
                            .replace("\r", "\n")
                            .replace("\t", "    ");
    var lines = python_code.split("\n");
    var isFirstLine = true;
    var isNewLine = false;
    var isFuncDefScope = false;
    var indent = 0;
    var new_python_code = "";
    var newLine = "";
    //遍历每行
    for(var i = 0 ; i < lines.length ; i ++){
        var line = lines[i];
        //函数定义的开始行（def XXX()）
        if(this.isFuncStartLine(line)){
            isFuncDefScope = true;
            indent = this.getIndentOfLine(line);
            if(!isFirstLine && !isNewLine){
                line = "\n" + line;
            }
        }else if(isFuncDefScope && this.getIndentOfLine(line) <= indent){//函数定义结束后的第一行
            if(!this.isEmptyNewLine(line)){
               line = "\n" + line;
            }else {
                isFuncDefScope = false;
            }
        }
        //是否是空行
        if(this.isEmptyNewLine(line)){
            isNewLine = true;
        }else{
            isNewLine = false;
{'fraction_non_alphanumeric': 0.14902392081385757, 'fraction_numerical': 0.006048941435248831, 'mean_word_length': 1.9722222222222223, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '823052', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1235, 'n_words': 215}