<commit_before>/*
 * Control blocks.
 * ON / when
 * [ PARALLEL ]
 * LOOP
 * IF
 */
 
 /*
  * Timing
  * WAIT
  * WAIT UNTIL
  */
  
 /*
  * Misc
  * LOG
  */
 
 /*
  * Variables
  * SET
  * GET
  */
 
 /*
  * Procedures
  * DEF
  * CALL
  */
 
/**
 * @fileoverview Generating Python-Octo for control blocks.
 * @author <EMAIL> (<NAME>)
 */
'use strict';

goog.provide('Blockly.PythonOcto.control');

goog.require('Blockly.PythonOcto');

Blockly.PythonOcto['controls_if'] = function(block) {
  function stringFill (x, n) { 
    var s = ''; 
    for (;;) { 
      if (n & 1) s += x; 
      n >>= 1; 
      if (n) x += x; 
      else break; 
    } 
    return s; 
  }

  function indent (code, times) {
    var i = Blockly.PythonOcto.INDENT;
    if (times !== undefined) {
      if (times < 1) return code;
      i = stringFill(i, times);
    }
    return Blockly.PythonOcto.prefixLines(code, i)
  }

  // If/elseif/else condition.
  var n = 0;
  var argument = Blockly.PythonOcto.valueToCode(block, 'IF' + n,
      Blockly.PythonOcto.ORDER_NONE) || 'False';
  var branch = Blockly.PythonOcto.statementToCode(block, 'DO' + n) || '[]';
  var code = 'do_if(' + argument + ', \n';
  code += indent(branch);
  
  for (n = 1; n <= block.elseifCount_; n++) {
    argument = Blockly.PythonOcto.valueToCode(block, 'IF' + n,
        Blockly.PythonOcto.ORDER_NONE) || 'False';
    branch = Blockly.PythonOcto.statementToCode(block, 'DO' + n) || '[]';
    code += ',\n';
    code += indent('do_if(' + argument + ', \n' + indent(branch), n);
  }
  if (block.elseCount_) {
    branch = Blockly.PythonOcto.statementToCode(block, 'ELSE') || '[]';
    code += ',\n' + indent(indent(branch) + '\n)', n - 1);
  } else {
    code += '\n' + indent(')', n - 1);
  }
  for (; n > 1; n--) {
    code += '\n' + indent(')', n - 2);
  }
  return code;
};

Blockly.PythonOcto['controls_wait'] = function(block) {
  var argument = Blockly.PythonOcto.valueToCode(block, 'TIME',
      Blockly.PythonOcto.ORDER_NONE) || '0';
  var code = 'wait(' + argument + ')';
  return code;
};

Blockly.PythonOcto['controls_wait_until'] = function(block) {
  var argument = Blockly.PythonOcto.valueToCode(block, 'CONDITION',
      Blockly.PythonOcto.ORDER_NONE) || 'True';
  var code = 'wait_until(' + argument + ')';
  return code;
};

Blockly.PythonOcto['controls_run'] = function(block) {
  var later = block.getFieldValue('MODE') === 'PAUSED';
  var argument = Blockly.PythonOcto.valueToCode(block, 'STACK',
      Blockly.PythonOcto.ORDER_NONE) || 'sequence()';
  var code = 'run' + (later ? '_later' : '') + '(' + argument + ')';
  return code;
};
<commit_msg>Fix blocks in controls_run<commit_after>/*
 * Control blocks.
 * ON / when
 * [ PARALLEL ]
 * LOOP
 * IF
 */
 
 /*
  * Timing
  * WAIT
  * WAIT UNTIL
  */
  
 /*
  * Misc
  * LOG
  */
 
 /*
  * Variables
  * SET
  * GET
  */
 
 /*
  * Procedures
  * DEF
  * CALL
  */
 
/**
 * @fileoverview Generating Python-Octo for control blocks.
 * @author <EMAIL> (<NAME>)
 */
'use strict';

goog.provide('Blockly.PythonOcto.control');

goog.require('Blockly.PythonOcto');

Blockly.PythonOcto['controls_if'] = function(block) {
  function stringFill (x, n) { 
    var s = ''; 
    for (;;) { 
      if (n & 1) s += x; 
      n >>= 1; 
      if (n) x += x; 
      else break; 
    } 
    return s; 
  }

  function indent (code, times) {
    var i = Blockly.PythonOcto.INDENT;
    if (times !== undefined) {
      if (times < 1) return code;
      i = stringFill(i, times);
    }
    return Blockly.PythonOcto.prefixLines(code, i)
  }

  // If/elseif/else condition.
  var n = 0;
  var argument = Blockly.PythonOcto.valueToCode(block, 'IF' + n,
      Blockly.PythonOcto.ORDER_NONE) || 'False';
  var branch = Blockly.PythonOcto.statementToCode(block, 'DO' + n) || '[]';
  var code = 'do_if(' + argument + ', \n';
  code += indent(branch);
  
  for (n = 1; n <= block.elseifCount_; n++) {
    argument = Blockly.PythonOcto.valueToCode(block, 'IF' + n,
        Blockly.PythonOcto.ORDER_NONE) || 'False';
    branch = Blockly.PythonOcto.statementToCode(block, 'DO' + n) || '[]';
    code += ',\n';
    code += indent('do_if(' + argument + ', \n' + indent(branch), n);
  }
  if (block.elseCount_) {
    branch = Blockly.PythonOcto.statementToCode(block, 'ELSE') || '[]';
    code += ',\n' + indent(indent(branch) + '\n)', n - 1);
  } else {
    code += '\n' + indent(')', n - 1);
  }
  for (; n > 1; n--) {
    code += '\n' + indent(')', n - 2);
  }
  return code;
};

Blockly.PythonOcto['controls_wait'] = function(block) {
  var argument = Blockly.PythonOcto.valueToCode(block, 'TIME',
      Blockly.PythonOcto.ORDER_NONE) || '0';
  var code = 'wait(' + argument + ')';
  return code;
};

Blockly.PythonOcto['controls_wait_until'] = function(block) {
  var argument = Blockly.PythonOcto.valueToCode(block, 'CONDITION',
      Blockly.PythonOcto.ORDER_NONE) || 'True';
  var code = 'wait_until(' + argument + ')';
  return code;
};

Blockly.PythonOcto['controls_run'] = function(block) {
  var later = block.getFieldValue('MODE') === 'PAUSED';
  var branch = Blockly.PythonOcto.statementToCode(block, 'STACK') || 'sequence()';
  var code = 'run' + (later ? '_later' : '') + '(' + branch + ')';
  return code;
};

{'fraction_non_alphanumeric': 0.18960889570552147, 'fraction_numerical': 0.003834355828220859, 'mean_word_length': 2.8501845018450185, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '3748455', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1916, 'n_words': 406}