<commit_before>/**
 * @license
 * Visual Blocks Language - Turtle extension
 *
 * Copyright 2015 Grok Learning
 * https://groklearning.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Generating Python for math blocks.
 * @author <EMAIL> (<NAME>)
 */
'use strict';

goog.provide('Blockly.Python.turtle');

goog.require('Blockly.Python');


// Any imports need to be reserved words
Blockly.Python.addReservedWords('turtle');


Blockly.Python['turtle_forward'] = function(block) {
  Blockly.Python.definitions_['import_turtle'] = 'from turtle import *';
  var distance = Blockly.Python.valueToCode(block, 'DISTANCE', Blockly.Python.ORDER_NONE) || 0;
  if (Blockly.isNumber(distance)) {
    distance = parseInt(distance, 10);
  } else {
    distance = 'float(' + distance + ')';
  }
  var code = 'forward(' + distance + ')\n';
  return code;
};

Blockly.Python['turtle_turn'] = function(block) {
  Blockly.Python.definitions_['import_turtle'] = 'from turtle import *';
  var angle = Blockly.Python.valueToCode(block, 'ANGLE', Blockly.Python.ORDER_NONE) || 0;
  if (Blockly.isNumber(angle)) {
    angle = parseInt(angle, 10);
  } else {
    angle = 'float(' + angle + ')';
  }
  var TURN_FUNCTIONS = {
    'RIGHT': 'right',
    'LEFT': 'left',
  };
  var turnFunction = TURN_FUNCTIONS[block.getFieldValue('DIRECTION')];
  var code = turnFunction + '(' + angle + ')\n';
  return code;
};

Blockly.Python['turtle_pen'] = function(block) {
  Blockly.Python.definitions_['import_turtle'] = 'from turtle import *';
  var PEN_FUNCTIONS = {
    'UP': 'penup',
    'DOWN': 'pendown',
  };
  var penFunction = PEN_FUNCTIONS[block.getFieldValue('STATE')];
  var code = penFunction + '()\n';
  return code;<commit_msg>Removed the float protection in turtle forward/turn with variable arguments.<commit_after>/**
 * @license
 * Visual Blocks Language - Turtle extension
 *
 * Copyright 2015 Grok Learning
 * https://groklearning.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Generating Python for math blocks.
 * @author <EMAIL> (<NAME>)
 */
'use strict';

goog.provide('Blockly.Python.turtle');

goog.require('Blockly.Python');


// Any imports need to be reserved words
Blockly.Python.addReservedWords('turtle');


Blockly.Python['turtle_forward'] = function(block) {
  Blockly.Python.definitions_['import_turtle'] = 'from turtle import *';
  var distance = Blockly.Python.valueToCode(block, 'DISTANCE', Blockly.Python.ORDER_NONE) || 0;
  if (Blockly.isNumber(distance)) {
    distance = parseInt(distance, 10);
  }
  var code = 'forward(' + distance + ')\n';
  return code;
};

Blockly.Python['turtle_turn'] = function(block) {
  Blockly.Python.definitions_['import_turtle'] = 'from turtle import *';
  var angle = Blockly.Python.valueToCode(block, 'ANGLE', Blockly.Python.ORDER_NONE) || 0;
  if (Blockly.isNumber(angle)) {
    angle = parseInt(angle, 10);
  }
  var TURN_FUNCTIONS = {
    'RIGHT': 'right',
    'LEFT': 'left',
  };
  var turnFunction = TURN_FUNCTIONS[block.getFieldValue('DIRECTION')];
  var code = turnFunction + '(' + angle + ')\n';
  return code;
};

Blockly.Python['turtle_pen'] = function(block) {
  Blockly.Python.definitions_['import_turtle'] = 'from turtle import *';
  var PEN_FUNCTIONS = {
    'UP': 'penup',
    'DOWN': 'pendown',
  };
  var penFunction = PEN_FUNCTIONS[block.getFieldValue('STATE')];
  var code = penFunction + '()\n';
  return code;
{'fraction_non_alphanumeric': 0.13999549853702453, 'fraction_numerical': 0.006302048165653837, 'mean_word_length': 4.191588785046729, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2983284', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1375, 'n_words': 394}