blockly 12.2.0-beta.0 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.min.js +861 -837
- package/blockly_compressed.js +767 -742
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +57 -58
- package/blocks_compressed.js.map +1 -1
- package/core/clipboard.d.ts +76 -15
- package/core/comments/collapse_comment_bar_button.d.ts +50 -0
- package/core/comments/comment_bar_button.d.ts +61 -0
- package/core/comments/comment_view.d.ts +13 -25
- package/core/comments/delete_comment_bar_button.d.ts +50 -0
- package/core/comments.d.ts +3 -0
- package/core/field_input.d.ts +3 -3
- package/core/keyboard_nav/block_navigation_policy.d.ts +7 -6
- package/core/keyboard_nav/comment_bar_button_navigation_policy.d.ts +56 -0
- package/core/keyboard_nav/line_cursor.d.ts +8 -8
- package/core/keyboard_nav/workspace_comment_navigation_policy.d.ts +56 -0
- package/core/marker_manager.d.ts +2 -2
- package/core/utils/focusable_tree_traverser.d.ts +2 -2
- package/core/utils/rect.d.ts +9 -0
- package/core/workspace.d.ts +10 -0
- package/core/workspace_svg.d.ts +19 -4
- package/dart_compressed.js +38 -38
- package/dart_compressed.js.map +1 -1
- package/javascript_compressed.js +37 -37
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +30 -30
- package/lua_compressed.js.map +1 -1
- package/package.json +4 -4
- package/php_compressed.js +39 -39
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +32 -32
- package/python_compressed.js.map +1 -1
package/python_compressed.js
CHANGED
|
@@ -15,7 +15,7 @@ var $=__parent__.__namespace__;
|
|
|
15
15
|
var lists_create_empty$$module$build$src$generators$python$lists=function(a,b){return["[]",Order$$module$build$src$generators$python$python_generator.ATOMIC]},lists_create_with$$module$build$src$generators$python$lists=function(a,b){const c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$python$python_generator.NONE)||"None";return["["+c.join(", ")+"]",Order$$module$build$src$generators$python$python_generator.ATOMIC]},lists_repeat$$module$build$src$generators$python$lists=
|
|
16
16
|
function(a,b){const c=b.valueToCode(a,"ITEM",Order$$module$build$src$generators$python$python_generator.NONE)||"None";a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||"0";return["["+c+"] * "+a,Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE]},lists_length$$module$build$src$generators$python$lists=function(a,b){return["len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"[]")+")",
|
|
17
17
|
Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_isEmpty$$module$build$src$generators$python$lists=function(a,b){return["not len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"[]")+")",Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},lists_indexOf$$module$build$src$generators$python$lists=function(a,b){const c=b.valueToCode(a,"FIND",Order$$module$build$src$generators$python$python_generator.NONE)||
|
|
18
|
-
"[]",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''";let e=" -1",f="",g=" - 1";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1",g="");return[(
|
|
18
|
+
"[]",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''";let e=" -1",f="",g=" - 1";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1",g="");return[(a.getFieldValue("END")==="FIRST"?b.provideFunction_("first_index",`
|
|
19
19
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
|
20
20
|
try: index = my_list.index(elem)${f}
|
|
21
21
|
except: index =${e}
|
|
@@ -25,19 +25,19 @@ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
|
|
25
25
|
try: index = len(my_list) - my_list[::-1].index(elem)${g}
|
|
26
26
|
except: index =${e}
|
|
27
27
|
return index
|
|
28
|
-
`))+"("+d+", "+c+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_getIndex$$module$build$src$generators$python$lists=function(a,b){const c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START";var e=b.valueToCode(a,"VALUE","RANDOM"
|
|
29
|
-
if("GET_REMOVE"
|
|
30
|
-
if("GET_REMOVE"
|
|
31
|
-
"import random";if("GET"
|
|
28
|
+
`))+"("+d+", "+c+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_getIndex$$module$build$src$generators$python$lists=function(a,b){const c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START";var e=b.valueToCode(a,"VALUE",d==="RANDOM"?Order$$module$build$src$generators$python$python_generator.NONE:Order$$module$build$src$generators$python$python_generator.MEMBER)||"[]";switch(d){case "FIRST":if(c==="GET")return[e+"[0]",Order$$module$build$src$generators$python$python_generator.MEMBER];
|
|
29
|
+
if(c==="GET_REMOVE")return[e+".pop(0)",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop(0)\n";break;case "LAST":if(c==="GET")return[e+"[-1]",Order$$module$build$src$generators$python$python_generator.MEMBER];if(c==="GET_REMOVE")return[e+".pop()",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop()\n";break;case "FROM_START":a=b.getAdjustedInt(a,"AT");if(c==="GET")return[e+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];
|
|
30
|
+
if(c==="GET_REMOVE")return[e+".pop("+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop("+a+")\n";break;case "FROM_END":a=b.getAdjustedInt(a,"AT",1,!0);if(c==="GET")return[e+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];if(c==="GET_REMOVE")return[e+".pop("+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop("+a+")\n";break;case "RANDOM":b.definitions_.import_random=
|
|
31
|
+
"import random";if(c==="GET")return["random.choice("+e+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];e=b.provideFunction_("lists_remove_random_item",`
|
|
32
32
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
33
33
|
x = int(random.random() * len(myList))
|
|
34
34
|
return myList.pop(x)
|
|
35
|
-
`)+"("+e+")";if("GET_REMOVE"
|
|
36
|
-
"None";switch(e){case "FIRST":if("SET"
|
|
37
|
-
")\n";break;case "RANDOM":b.definitions_.import_random="import random";c.match(/^\w+$/)?a="":(a=b.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),e=a+" = "+c+"\n",c=a,a=e);b=b.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE);a+=b+" = int(random.random() * len("+c+"))\n";if("SET"
|
|
38
|
-
function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.MEMBER)||"[]";var d=a.getFieldValue("WHERE1");const e=a.getFieldValue("WHERE2");switch(d){case "FROM_START":d=b.getAdjustedInt(a,"AT1");0
|
|
39
|
-
0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?0
|
|
40
|
-
a=
|
|
35
|
+
`)+"("+e+")";if(c==="GET_REMOVE")return[e,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+"\n"}throw Error("Unhandled combination (lists_getIndex).");},lists_setIndex$$module$build$src$generators$python$lists=function(a,b){let c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.MEMBER)||"[]";const d=a.getFieldValue("MODE")||"GET";var e=a.getFieldValue("WHERE")||"FROM_START";const f=b.valueToCode(a,"TO",Order$$module$build$src$generators$python$python_generator.NONE)||
|
|
36
|
+
"None";switch(e){case "FIRST":if(d==="SET")return c+"[0] = "+f+"\n";if(d==="INSERT")return c+".insert(0, "+f+")\n";break;case "LAST":if(d==="SET")return c+"[-1] = "+f+"\n";if(d==="INSERT")return c+".append("+f+")\n";break;case "FROM_START":b=b.getAdjustedInt(a,"AT");if(d==="SET")return c+"["+b+"] = "+f+"\n";if(d==="INSERT")return c+".insert("+b+", "+f+")\n";break;case "FROM_END":b=b.getAdjustedInt(a,"AT",1,!0);if(d==="SET")return c+"["+b+"] = "+f+"\n";if(d==="INSERT")return c+".insert("+b+", "+f+
|
|
37
|
+
")\n";break;case "RANDOM":b.definitions_.import_random="import random";c.match(/^\w+$/)?a="":(a=b.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),e=a+" = "+c+"\n",c=a,a=e);b=b.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE);a+=b+" = int(random.random() * len("+c+"))\n";if(d==="SET")return a+(c+"["+b+"] = "+f+"\n");if(d==="INSERT")return a+(c+".insert("+b+", "+f+")\n")}throw Error("Unhandled combination (lists_setIndex).");},lists_getSublist$$module$build$src$generators$python$lists=
|
|
38
|
+
function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.MEMBER)||"[]";var d=a.getFieldValue("WHERE1");const e=a.getFieldValue("WHERE2");switch(d){case "FROM_START":d=b.getAdjustedInt(a,"AT1");d===0&&(d="");break;case "FROM_END":d=b.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":d="";break;default:throw Error("Unhandled option (lists_getSublist)");}switch(e){case "FROM_START":a=b.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",
|
|
39
|
+
0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?a===0&&(a=""):(b.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (lists_getSublist)");}return[c+"["+d+" : "+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER]},lists_sort$$module$build$src$generators$python$lists=function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.NONE)||"[]",d=a.getFieldValue("TYPE");
|
|
40
|
+
a=a.getFieldValue("DIRECTION")==="1"?"False":"True";return[b.provideFunction_("lists_sort",`
|
|
41
41
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
|
|
42
42
|
def try_float(s):
|
|
43
43
|
try:
|
|
@@ -52,16 +52,16 @@ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
|
|
|
52
52
|
key_func = key_funcs[type]
|
|
53
53
|
list_cpy = list(my_list)
|
|
54
54
|
return sorted(list_cpy, key=key_func, reverse=reverse)
|
|
55
|
-
`)+"("+c+', "'+d+'", '+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_split$$module$build$src$generators$python$lists=function(a,b){var c=a.getFieldValue("MODE");if("SPLIT"
|
|
55
|
+
`)+"("+c+', "'+d+'", '+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_split$$module$build$src$generators$python$lists=function(a,b){var c=a.getFieldValue("MODE");if(c==="SPLIT")c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''",a=b.valueToCode(a,"DELIM",Order$$module$build$src$generators$python$python_generator.NONE),a=c+".split("+a+")";else if(c==="JOIN")c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$python$python_generator.NONE)||
|
|
56
56
|
"[]",a=(b.valueToCode(a,"DELIM",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+".join("+c+")";else throw Error("Unknown mode: "+c);return[a,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_reverse$$module$build$src$generators$python$lists=function(a,b){return["list(reversed("+(b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.NONE)||"[]")+"))",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},
|
|
57
|
-
controls_if$$module$build$src$generators$python$logic=function(a,b){let c=0,d="",e,f;b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do f=b.valueToCode(a,"IF"+c,Order$$module$build$src$generators$python$python_generator.NONE)||"False",e=b.statementToCode(a,"DO"+c)||b.PASS,b.STATEMENT_SUFFIX&&(e=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+e),d+=(0
|
|
57
|
+
controls_if$$module$build$src$generators$python$logic=function(a,b){let c=0,d="",e,f;b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do f=b.valueToCode(a,"IF"+c,Order$$module$build$src$generators$python$python_generator.NONE)||"False",e=b.statementToCode(a,"DO"+c)||b.PASS,b.STATEMENT_SUFFIX&&(e=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+e),d+=(c===0?"if ":"elif ")+f+":\n"+e,c++;while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)e=a.getInput("ELSE")?b.statementToCode(a,
|
|
58
58
|
"ELSE")||b.PASS:b.PASS,b.STATEMENT_SUFFIX&&(e=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+e),d+="else:\n"+e;return d},logic_compare$$module$build$src$generators$python$logic=function(a,b){const c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=Order$$module$build$src$generators$python$python_generator.RELATIONAL,e=b.valueToCode(a,"A",d)||"0";a=b.valueToCode(a,"B",d)||"0";return[e+" "+c+" "+a,d]},logic_operation$$module$build$src$generators$python$logic=function(a,
|
|
59
|
-
b){const c=
|
|
60
|
-
"True"),Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},logic_boolean$$module$build$src$generators$python$logic=function(a,b){return[
|
|
59
|
+
b){const c=a.getFieldValue("OP")==="AND"?"and":"or",d=c==="and"?Order$$module$build$src$generators$python$python_generator.LOGICAL_AND:Order$$module$build$src$generators$python$python_generator.LOGICAL_OR;let e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b=c==="and"?"True":"False",e||(e=b),a||(a=b)):a=e="False";return[e+" "+c+" "+a,d]},logic_negate$$module$build$src$generators$python$logic=function(a,b){return["not "+(b.valueToCode(a,"BOOL",Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT)||
|
|
60
|
+
"True"),Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},logic_boolean$$module$build$src$generators$python$logic=function(a,b){return[a.getFieldValue("BOOL")==="TRUE"?"True":"False",Order$$module$build$src$generators$python$python_generator.ATOMIC]},logic_null$$module$build$src$generators$python$logic=function(a,b){return["None",Order$$module$build$src$generators$python$python_generator.ATOMIC]},logic_ternary$$module$build$src$generators$python$logic=function(a,b){const c=
|
|
61
61
|
b.valueToCode(a,"IF",Order$$module$build$src$generators$python$python_generator.CONDITIONAL)||"False",d=b.valueToCode(a,"THEN",Order$$module$build$src$generators$python$python_generator.CONDITIONAL)||"None";a=b.valueToCode(a,"ELSE",Order$$module$build$src$generators$python$python_generator.CONDITIONAL)||"None";return[d+" if "+c+" else "+a,Order$$module$build$src$generators$python$python_generator.CONDITIONAL]},controls_repeat_ext$$module$build$src$generators$python$loops=function(a,b){let c;c=a.getField("TIMES")?
|
|
62
|
-
String(parseInt(a.getFieldValue("TIMES"),10)):b.valueToCode(a,"TIMES",Order$$module$build$src$generators$python$python_generator.NONE)||"0";c=$.isNumber$$module$build$src$core$utils$string(c)?parseInt(c,10):"int("+c+")";let d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a)||b.PASS;return"for "+b.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE)+" in range("+c+"):\n"+d},controls_whileUntil$$module$build$src$generators$python$loops=function(a,b){const c=
|
|
63
|
-
let d=b.valueToCode(a,"BOOL",c?Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT:Order$$module$build$src$generators$python$python_generator.NONE)||"False",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;c&&(d="not "+d);return"while "+d+":\n"+e},controls_for$$module$build$src$generators$python$loops=function(a,b){const c=b.getVariableName(a.getFieldValue("VAR"));var d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python$python_generator.NONE)||"0",
|
|
64
|
-
"TO",Order$$module$build$src$generators$python$python_generator.NONE)||"0",f=b.valueToCode(a,"BY",Order$$module$build$src$generators$python$python_generator.NONE)||"1";let g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a)||b.PASS;let h="";a=function(){return b.provideFunction_("upRange",`
|
|
62
|
+
String(parseInt(a.getFieldValue("TIMES"),10)):b.valueToCode(a,"TIMES",Order$$module$build$src$generators$python$python_generator.NONE)||"0";c=$.isNumber$$module$build$src$core$utils$string(c)?parseInt(c,10):"int("+c+")";let d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a)||b.PASS;return"for "+b.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE)+" in range("+c+"):\n"+d},controls_whileUntil$$module$build$src$generators$python$loops=function(a,b){const c=a.getFieldValue("MODE")===
|
|
63
|
+
"UNTIL";let d=b.valueToCode(a,"BOOL",c?Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT:Order$$module$build$src$generators$python$python_generator.NONE)||"False",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;c&&(d="not "+d);return"while "+d+":\n"+e},controls_for$$module$build$src$generators$python$loops=function(a,b){const c=b.getVariableName(a.getFieldValue("VAR"));var d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python$python_generator.NONE)||"0",
|
|
64
|
+
e=b.valueToCode(a,"TO",Order$$module$build$src$generators$python$python_generator.NONE)||"0",f=b.valueToCode(a,"BY",Order$$module$build$src$generators$python$python_generator.NONE)||"1";let g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a)||b.PASS;let h="";a=function(){return b.provideFunction_("upRange",`
|
|
65
65
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
|
66
66
|
while start <= stop:
|
|
67
67
|
yield start
|
|
@@ -71,19 +71,19 @@ def ${b.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
|
|
71
71
|
while start >= stop:
|
|
72
72
|
yield start
|
|
73
73
|
start -= abs(step)
|
|
74
|
-
`)};if($.isNumber$$module$build$src$core$utils$string(d)&&$.isNumber$$module$build$src$core$utils$string(e)&&$.isNumber$$module$build$src$core$utils$string(f))d=Number(d),e=Number(e),f=Math.abs(Number(f)),
|
|
75
|
-
n,$.NameType$$module$build$src$core$names.VARIABLE),h+=n+" = "+m+"\n",m=n);return m};d=l(d,"_start");e=l(e,"_end");f=l(f,"_inc");
|
|
74
|
+
`)};if($.isNumber$$module$build$src$core$utils$string(d)&&$.isNumber$$module$build$src$core$utils$string(e)&&$.isNumber$$module$build$src$core$utils$string(f))d=Number(d),e=Number(e),f=Math.abs(Number(f)),d%1===0&&e%1===0&&f%1===0?(d<=e?(e++,a=d===0&&f===1?e:d+", "+e,f!==1&&(a+=", "+f)):(e--,a=d+", "+e+", -"+f),a="range("+a+")"):(a=d<e?a():k(),a+="("+d+", "+e+", "+f+")");else{const l=function(m,n){$.isNumber$$module$build$src$core$utils$string(m)?m=String(Number(m)):m.match(/^\w+$/)||(n=b.nameDB_.getDistinctName(c+
|
|
75
|
+
n,$.NameType$$module$build$src$core$names.VARIABLE),h+=n+" = "+m+"\n",m=n);return m};d=l(d,"_start");e=l(e,"_end");f=l(f,"_inc");typeof d==="number"&&typeof e==="number"?(a=d<e?a():k(),a+="("+d+", "+e+", "+f+")"):a="("+d+" <= "+e+") and "+a()+"("+d+", "+e+", "+f+") or "+k()+"("+d+", "+e+", "+f+")"}return h+="for "+c+" in "+a+":\n"+g},controls_forEach$$module$build$src$generators$python$loops=function(a,b){const c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.RELATIONAL)||
|
|
76
76
|
"[]";let e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;return"for "+c+" in "+d+":\n"+e},controls_flow_statements$$module$build$src$generators$python$loops=function(a,b){let c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){const d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break\n";case "CONTINUE":return c+
|
|
77
|
-
"continue\n"}throw Error("Unknown flow statement.");},math_number$$module$build$src$generators$python$math=function(a,b){a=Number(a.getFieldValue("NUM"));return Infinity
|
|
77
|
+
"continue\n"}throw Error("Unknown flow statement.");},math_number$$module$build$src$generators$python$math=function(a,b){a=Number(a.getFieldValue("NUM"));return a===Infinity?['float("inf")',Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]:a===-Infinity?['-float("inf")',Order$$module$build$src$generators$python$python_generator.UNARY_SIGN]:[String(a),a<0?Order$$module$build$src$generators$python$python_generator.UNARY_SIGN:Order$$module$build$src$generators$python$python_generator.ATOMIC]},
|
|
78
78
|
math_arithmetic$$module$build$src$generators$python$math=function(a,b){var c={ADD:[" + ",Order$$module$build$src$generators$python$python_generator.ADDITIVE],MINUS:[" - ",Order$$module$build$src$generators$python$python_generator.ADDITIVE],MULTIPLY:[" * ",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE],DIVIDE:[" / ",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE],POWER:[" ** ",Order$$module$build$src$generators$python$python_generator.EXPONENTIATION]}[a.getFieldValue("OP")];
|
|
79
|
-
const d=c[0];c=c[1];const e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]},math_single$$module$build$src$generators$python$math=function(a,b){const c=a.getFieldValue("OP");let d;if("NEG"
|
|
79
|
+
const d=c[0];c=c[1];const e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]},math_single$$module$build$src$generators$python$math=function(a,b){const c=a.getFieldValue("OP");let d;if(c==="NEG")return d=b.valueToCode(a,"NUM",Order$$module$build$src$generators$python$python_generator.UNARY_SIGN)||"0",["-"+d,Order$$module$build$src$generators$python$python_generator.UNARY_SIGN];b.definitions_.import_math="import math";a=c==="SIN"||c==="COS"||c==="TAN"?b.valueToCode(a,"NUM",
|
|
80
80
|
Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||"0":b.valueToCode(a,"NUM",Order$$module$build$src$generators$python$python_generator.NONE)||"0";switch(c){case "ABS":d="math.fabs("+a+")";break;case "ROOT":d="math.sqrt("+a+")";break;case "LN":d="math.log("+a+")";break;case "LOG10":d="math.log10("+a+")";break;case "EXP":d="math.exp("+a+")";break;case "POW10":d="math.pow(10,"+a+")";break;case "ROUND":d="round("+a+")";break;case "ROUNDUP":d="math.ceil("+a+")";break;case "ROUNDDOWN":d=
|
|
81
81
|
"math.floor("+a+")";break;case "SIN":d="math.sin("+a+" / 180.0 * math.pi)";break;case "COS":d="math.cos("+a+" / 180.0 * math.pi)";break;case "TAN":d="math.tan("+a+" / 180.0 * math.pi)"}if(d)return[d,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];switch(c){case "ASIN":d="math.asin("+a+") / math.pi * 180";break;case "ACOS":d="math.acos("+a+") / math.pi * 180";break;case "ATAN":d="math.atan("+a+") / math.pi * 180";break;default:throw Error("Unknown math operator: "+c);}return[d,
|
|
82
82
|
Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE]},math_constant$$module$build$src$generators$python$math=function(a,b){const c={PI:["math.pi",Order$$module$build$src$generators$python$python_generator.MEMBER],E:["math.e",Order$$module$build$src$generators$python$python_generator.MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",Order$$module$build$src$generators$python$python_generator.MEMBER],
|
|
83
|
-
SQRT1_2:["math.sqrt(1.0 / 2)",Order$$module$build$src$generators$python$python_generator.MEMBER],INFINITY:["float('inf')",Order$$module$build$src$generators$python$python_generator.ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"
|
|
83
|
+
SQRT1_2:["math.sqrt(1.0 / 2)",Order$$module$build$src$generators$python$python_generator.MEMBER],INFINITY:["float('inf')",Order$$module$build$src$generators$python$python_generator.ATOMIC]};a=a.getFieldValue("CONSTANT");a!=="INFINITY"&&(b.definitions_.import_math="import math");return c[a]},math_number_property$$module$build$src$generators$python$math=function(a,b){var c={EVEN:[" % 2 == 0",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,Order$$module$build$src$generators$python$python_generator.RELATIONAL],
|
|
84
84
|
ODD:[" % 2 == 1",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,Order$$module$build$src$generators$python$python_generator.RELATIONAL],WHOLE:[" % 1 == 0",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,Order$$module$build$src$generators$python$python_generator.RELATIONAL],POSITIVE:[" > 0",Order$$module$build$src$generators$python$python_generator.RELATIONAL,Order$$module$build$src$generators$python$python_generator.RELATIONAL],NEGATIVE:[" < 0",
|
|
85
85
|
Order$$module$build$src$generators$python$python_generator.RELATIONAL,Order$$module$build$src$generators$python$python_generator.RELATIONAL],DIVISIBLE_BY:[null,Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,Order$$module$build$src$generators$python$python_generator.RELATIONAL],PRIME:[null,Order$$module$build$src$generators$python$python_generator.NONE,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]};const d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];
|
|
86
|
-
c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if("PRIME"
|
|
86
|
+
c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if(d==="PRIME")b.definitions_.import_math="import math",b.definitions_.from_numbers_import_Number="from numbers import Number",a=b.provideFunction_("math_isPrime",`
|
|
87
87
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(n):
|
|
88
88
|
# https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
89
89
|
# If n is not a number but a string, try parsing it.
|
|
@@ -102,7 +102,7 @@ def ${b.FUNCTION_NAME_PLACEHOLDER_}(n):
|
|
|
102
102
|
if n % (x - 1) == 0 or n % (x + 1) == 0:
|
|
103
103
|
return False
|
|
104
104
|
return True
|
|
105
|
-
`)+"("+c+")";else if("DIVISIBLE_BY"
|
|
105
|
+
`)+"("+c+")";else if(d==="DIVISIBLE_BY"){a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||"0";if(a==="0")return["False",Order$$module$build$src$generators$python$python_generator.ATOMIC];a=c+" % "+a+" == 0"}else a=c+e;return[a,g]},math_change$$module$build$src$generators$python$math=function(a,b){b.definitions_.from_numbers_import_Number="from numbers import Number";const c=b.valueToCode(a,"DELTA",Order$$module$build$src$generators$python$python_generator.ADDITIVE)||
|
|
106
106
|
"0";a=b.getVariableName(a.getFieldValue("VAR"));return a+" = ("+a+" if isinstance("+a+", Number) else 0) + "+c+"\n"},math_on_list$$module$build$src$generators$python$math=function(a,b){const c=a.getFieldValue("OP");a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.NONE)||"[]";switch(c){case "SUM":b="sum("+a+")";break;case "MIN":b="min("+a+")";break;case "MAX":b="max("+a+")";break;case "AVERAGE":b.definitions_.from_numbers_import_Number="from numbers import Number";
|
|
107
107
|
b=b.provideFunction_("math_mean",`
|
|
108
108
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
@@ -156,15 +156,15 @@ a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",Order$$module$build$s
|
|
|
156
156
|
case 1:return a=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$python$python_generator.NONE)||"''",forceString$$module$build$src$generators$python$text(a);case 2:var c=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$python$python_generator.NONE)||"''";a=b.valueToCode(a,"ADD1",Order$$module$build$src$generators$python$python_generator.NONE)||"''";return[forceString$$module$build$src$generators$python$text(c)[0]+" + "+forceString$$module$build$src$generators$python$text(a)[0],Order$$module$build$src$generators$python$python_generator.ADDITIVE];
|
|
157
157
|
default:c=[];for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$python$python_generator.NONE)||"''";a=b.nameDB_.getDistinctName("x",$.NameType$$module$build$src$core$names.VARIABLE);return["''.join([str("+a+") for "+a+" in ["+c.join(", ")+"]])",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]}},text_append$$module$build$src$generators$python$text=function(a,b){const c=b.getVariableName(a.getFieldValue("VAR"));a=b.valueToCode(a,"TEXT",
|
|
158
158
|
Order$$module$build$src$generators$python$python_generator.NONE)||"''";return c+" = str("+c+") + "+forceString$$module$build$src$generators$python$text(a)[0]+"\n"},text_length$$module$build$src$generators$python$text=function(a,b){return["len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''")+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_isEmpty$$module$build$src$generators$python$text=function(a,b){return["not len("+
|
|
159
|
-
(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''")+")",Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},text_indexOf$$module$build$src$generators$python$text=function(a,b){const c=
|
|
160
|
-
"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",Order$$module$build$src$generators$python$python_generator.ADDITIVE]:[b,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_charAt$$module$build$src$generators$python$text=function(a,b){const c=a.getFieldValue("WHERE")||"FROM_START",d=b.valueToCode(a,"VALUE","RANDOM"
|
|
159
|
+
(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''")+")",Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},text_indexOf$$module$build$src$generators$python$text=function(a,b){const c=a.getFieldValue("END")==="FIRST"?"find":"rfind",d=b.valueToCode(a,"FIND",Order$$module$build$src$generators$python$python_generator.NONE)||"''";b=(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+"."+c+
|
|
160
|
+
"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",Order$$module$build$src$generators$python$python_generator.ADDITIVE]:[b,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_charAt$$module$build$src$generators$python$text=function(a,b){const c=a.getFieldValue("WHERE")||"FROM_START",d=b.valueToCode(a,"VALUE",c==="RANDOM"?Order$$module$build$src$generators$python$python_generator.NONE:Order$$module$build$src$generators$python$python_generator.MEMBER)||"''";switch(c){case "FIRST":return[d+
|
|
161
161
|
"[0]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "LAST":return[d+"[-1]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "FROM_START":return a=b.getAdjustedInt(a,"AT"),[d+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "FROM_END":return a=b.getAdjustedInt(a,"AT",1,!0),[d+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "RANDOM":return b.definitions_.import_random="import random",
|
|
162
162
|
[b.provideFunction_("text_random_letter",`
|
|
163
163
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(text):
|
|
164
164
|
x = int(random.random() * len(text))
|
|
165
165
|
return text[x]
|
|
166
|
-
`)+"("+d+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");},text_getSubstring$$module$build$src$generators$python$text=function(a,b){var c=a.getFieldValue("WHERE1");const d=a.getFieldValue("WHERE2"),e=b.valueToCode(a,"STRING",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''";switch(c){case "FROM_START":c=b.getAdjustedInt(a,"AT1");0
|
|
167
|
-
case "FIRST":c="";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(d){case "FROM_START":a=b.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?0
|
|
166
|
+
`)+"("+d+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");},text_getSubstring$$module$build$src$generators$python$text=function(a,b){var c=a.getFieldValue("WHERE1");const d=a.getFieldValue("WHERE2"),e=b.valueToCode(a,"STRING",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''";switch(c){case "FROM_START":c=b.getAdjustedInt(a,"AT1");c===0&&(c="");break;case "FROM_END":c=b.getAdjustedInt(a,"AT1",1,!0);break;
|
|
167
|
+
case "FIRST":c="";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(d){case "FROM_START":a=b.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?a===0&&(a=""):(b.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (text_getSubstring)");}return[e+"["+c+" : "+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER]},
|
|
168
168
|
text_changeCase$$module$build$src$generators$python$text=function(a,b){const c={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[a.getFieldValue("CASE")];return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+c,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_trim$$module$build$src$generators$python$text=function(a,b){const c={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[a.getFieldValue("MODE")];
|
|
169
169
|
return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+c,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_print$$module$build$src$generators$python$text=function(a,b){return"print("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.NONE)||"''")+")\n"},text_prompt_ext$$module$build$src$generators$python$text=function(a,b){var c=b.provideFunction_("text_prompt",`
|
|
170
170
|
def ${b.FUNCTION_NAME_PLACEHOLDER_}(msg):
|
|
@@ -172,7 +172,7 @@ def ${b.FUNCTION_NAME_PLACEHOLDER_}(msg):
|
|
|
172
172
|
return raw_input(msg)
|
|
173
173
|
except NameError:
|
|
174
174
|
return input(msg)
|
|
175
|
-
`);b=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.NONE)||"''";c=c+"("+b+")";
|
|
175
|
+
`);b=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.NONE)||"''";c=c+"("+b+")";a.getFieldValue("TYPE")==="NUMBER"&&(c="float("+c+")");return[c,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_count$$module$build$src$generators$python$text=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''";a=b.valueToCode(a,"SUB",Order$$module$build$src$generators$python$python_generator.NONE)||
|
|
176
176
|
"''";return[c+".count("+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_replace$$module$build$src$generators$python$text=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''",d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python$python_generator.NONE)||"''";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$python$python_generator.NONE)||"''";return[c+".replace("+d+", "+a+")",
|
|
177
177
|
Order$$module$build$src$generators$python$python_generator.MEMBER]},text_reverse$$module$build$src$generators$python$text=function(a,b){return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+"[::-1]",Order$$module$build$src$generators$python$python_generator.MEMBER]},variables_get$$module$build$src$generators$python$variables=function(a,b){return[b.getVariableName(a.getFieldValue("VAR")),Order$$module$build$src$generators$python$python_generator.ATOMIC]},
|
|
178
178
|
variables_set$$module$build$src$generators$python$variables=function(a,b){const c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"0";return b.getVariableName(a.getFieldValue("VAR"))+" = "+c+"\n"},Order$$module$build$src$generators$python$python_generator;
|
|
@@ -180,12 +180,12 @@ variables_set$$module$build$src$generators$python$variables=function(a,b){const
|
|
|
180
180
|
a[a.LOGICAL_NOT=12]="LOGICAL_NOT";a[a.LOGICAL_AND=13]="LOGICAL_AND";a[a.LOGICAL_OR=14]="LOGICAL_OR";a[a.CONDITIONAL=15]="CONDITIONAL";a[a.LAMBDA=16]="LAMBDA";a[a.NONE=99]="NONE"})(Order$$module$build$src$generators$python$python_generator||(Order$$module$build$src$generators$python$python_generator={}));
|
|
181
181
|
var PythonGenerator$$module$build$src$generators$python$python_generator=class extends $.CodeGenerator$$module$build$src$core$generator{constructor(a="Python"){super(a);this.ORDER_OVERRIDES=[[Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL,Order$$module$build$src$generators$python$python_generator.MEMBER],[Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL],[Order$$module$build$src$generators$python$python_generator.MEMBER,
|
|
182
182
|
Order$$module$build$src$generators$python$python_generator.MEMBER],[Order$$module$build$src$generators$python$python_generator.MEMBER,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL],[Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT,Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT],[Order$$module$build$src$generators$python$python_generator.LOGICAL_AND,Order$$module$build$src$generators$python$python_generator.LOGICAL_AND],[Order$$module$build$src$generators$python$python_generator.LOGICAL_OR,
|
|
183
|
-
Order$$module$build$src$generators$python$python_generator.LOGICAL_OR]];this.PASS="";this.isInitialized=!1;for(const b in Order$$module$build$src$generators$python$python_generator)a=Order$$module$build$src$generators$python$python_generator[b],"string"
|
|
183
|
+
Order$$module$build$src$generators$python$python_generator.LOGICAL_OR]];this.PASS="";this.isInitialized=!1;for(const b in Order$$module$build$src$generators$python$python_generator)a=Order$$module$build$src$generators$python$python_generator[b],typeof a!=="string"&&(this["ORDER_"+b]=a);this.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip")}init(a){super.init(a);
|
|
184
184
|
this.PASS=this.INDENT+"pass\n";this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.Names$$module$build$src$core$names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);const b=[];var c=$.allDeveloperVariables$$module$build$src$core$variables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE)+" = None");a=$.allUsedVarModels$$module$build$src$core$variables(a);
|
|
185
185
|
for(c=0;c<a.length;c++)b.push(this.getVariableName(a[c].getId())+" = None");this.definitions_.variables=b.join("\n");this.isInitialized=!0}finish(a){const b=[],c=[];for(let d in this.definitions_){const e=this.definitions_[d];e.match(/^(from\s+\S+\s+)?import\s+\S+/)?b.push(e):c.push(e)}a=super.finish(a);this.isInitialized=!1;this.nameDB_.reset();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a}scrubNakedValue(a){return a+"\n"}quote_(a){a=a.replace(/\\/g,
|
|
186
186
|
"\\\\").replace(/\n/g,"\\\n");let b="'";a.includes("'")&&(a.includes('"')?a=a.replace(/'/g,"\\'"):b='"');return b+a+b}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")}scrub_(a,b,c=!1){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.wrap$$module$build$src$core$utils$string(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","# "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.inputTypes$$module$build$src$core$inputs$input_types.VALUE&&
|
|
187
187
|
(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"# "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c}getAdjustedInt(a,b,c=0,d=!1){a.workspace.options.oneBasedIndex&&c--;const e=a.workspace.options.oneBasedIndex?"1":"0";a=this.valueToCode(a,b,c?Order$$module$build$src$generators$python$python_generator.ADDITIVE:Order$$module$build$src$generators$python$python_generator.NONE)||e;$.isNumber$$module$build$src$core$utils$string(a)?
|
|
188
|
-
(a=parseInt(a,10)+c,d&&(a=-a)):(a=0
|
|
188
|
+
(a=parseInt(a,10)+c,d&&(a=-a)):(a=c>0?"int("+a+" + "+c+")":c<0?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a}},module$build$src$generators$python$python_generator={};module$build$src$generators$python$python_generator.Order=Order$$module$build$src$generators$python$python_generator;module$build$src$generators$python$python_generator.PythonGenerator=PythonGenerator$$module$build$src$generators$python$python_generator;var module$build$src$generators$python$lists={};module$build$src$generators$python$lists.lists_create_empty=lists_create_empty$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_create_with=lists_create_with$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_getIndex=lists_getIndex$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_getSublist=lists_getSublist$$module$build$src$generators$python$lists;
|
|
189
189
|
module$build$src$generators$python$lists.lists_indexOf=lists_indexOf$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_isEmpty=lists_isEmpty$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_length=lists_length$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_repeat=lists_repeat$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_reverse=lists_reverse$$module$build$src$generators$python$lists;
|
|
190
190
|
module$build$src$generators$python$lists.lists_setIndex=lists_setIndex$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_sort=lists_sort$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_split=lists_split$$module$build$src$generators$python$lists;var controls_ifelse$$module$build$src$generators$python$logic=controls_if$$module$build$src$generators$python$logic,module$build$src$generators$python$logic={};module$build$src$generators$python$logic.controls_if=controls_if$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.controls_ifelse=controls_if$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_boolean=logic_boolean$$module$build$src$generators$python$logic;
|
|
191
191
|
module$build$src$generators$python$logic.logic_compare=logic_compare$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_negate=logic_negate$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_null=logic_null$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_operation=logic_operation$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_ternary=logic_ternary$$module$build$src$generators$python$logic;var controls_repeat$$module$build$src$generators$python$loops=controls_repeat_ext$$module$build$src$generators$python$loops,module$build$src$generators$python$loops={};module$build$src$generators$python$loops.controls_flow_statements=controls_flow_statements$$module$build$src$generators$python$loops;module$build$src$generators$python$loops.controls_for=controls_for$$module$build$src$generators$python$loops;module$build$src$generators$python$loops.controls_forEach=controls_forEach$$module$build$src$generators$python$loops;
|