2022-01-03 14:02:41 +00:00
// Do not edit this file; automatically generated.
2021-08-28 14:28:26 +00:00
/* eslint-disable */
; ( function ( root , factory ) {
if ( typeof define === 'function' && define . amd ) { // AMD
2022-01-03 14:02:41 +00:00
define ( [ "./blockly_compressed.js" ] , factory ) ;
2021-08-28 14:28:26 +00:00
} else if ( typeof exports === 'object' ) { // Node.js
2022-01-03 14:02:41 +00:00
module . exports = factory ( require ( "./blockly_compressed.js" ) ) ;
2021-08-28 14:28:26 +00:00
} else { // Browser
2022-06-07 11:14:29 +00:00
var factoryExports = factory ( root . Blockly ) ;
2022-11-16 13:57:00 +00:00
root . Blockly . Python = factoryExports . pythonGenerator ;
root . Blockly . Python . _ _namespace _ _ = factoryExports . _ _namespace _ _ ;
2021-08-28 14:28:26 +00:00
}
2022-06-07 11:14:29 +00:00
} ( this , function ( _ _parent _ _ ) {
var $ = _ _parent _ _ . _ _namespace _ _ ;
2022-11-16 13:57:00 +00:00
var module$exports$Blockly$Python = { } , module$contents$Blockly$Python _stringUtils = $ . module$build$src$core$utils$string , module$contents$Blockly$Python _Variables = $ . module$build$src$core$variables , module$contents$Blockly$Python _Generator = $ . Generator$$module$build$src$core$generator , module$contents$Blockly$Python _inputTypes = $ . module$build$src$core$input _types . inputTypes , module$contents$Blockly$Python _Names = $ . module$build$src$core$names . Names , module$contents$Blockly$Python _NameType = $ . NameType$$module$build$src$core$names ;
module$exports$Blockly$Python . pythonGenerator = new $ . Generator$$module$build$src$core$generator ( "Python" ) ; module$exports$Blockly$Python . pythonGenerator . 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" ) ;
module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC = 0 ; module$exports$Blockly$Python . pythonGenerator . ORDER _COLLECTION = 1 ; module$exports$Blockly$Python . pythonGenerator . ORDER _STRING _CONVERSION = 1 ; module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER = 2.1 ; module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL = 2.2 ; module$exports$Blockly$Python . pythonGenerator . ORDER _EXPONENTIATION = 3 ; module$exports$Blockly$Python . pythonGenerator . ORDER _UNARY _SIGN = 4 ;
module$exports$Blockly$Python . pythonGenerator . ORDER _BITWISE _NOT = 4 ; module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE = 5 ; module$exports$Blockly$Python . pythonGenerator . ORDER _ADDITIVE = 6 ; module$exports$Blockly$Python . pythonGenerator . ORDER _BITWISE _SHIFT = 7 ; module$exports$Blockly$Python . pythonGenerator . ORDER _BITWISE _AND = 8 ; module$exports$Blockly$Python . pythonGenerator . ORDER _BITWISE _XOR = 9 ; module$exports$Blockly$Python . pythonGenerator . ORDER _BITWISE _OR = 10 ;
module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL = 11 ; module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT = 12 ; module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _AND = 13 ; module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _OR = 14 ; module$exports$Blockly$Python . pythonGenerator . ORDER _CONDITIONAL = 15 ; module$exports$Blockly$Python . pythonGenerator . ORDER _LAMBDA = 16 ; module$exports$Blockly$Python . pythonGenerator . ORDER _NONE = 99 ;
module$exports$Blockly$Python . pythonGenerator . ORDER _OVERRIDES = [ [ module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] , [ module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] , [ module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] , [ module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ,
module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] , [ module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT , module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT ] , [ module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _AND , module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _AND ] , [ module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _OR , module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _OR ] ] ;
module$exports$Blockly$Python . pythonGenerator . isInitialized = ! 1 ;
module$exports$Blockly$Python . pythonGenerator . init = function ( a ) { Object . getPrototypeOf ( this ) . init . call ( this ) ; this . PASS = this . INDENT + "pass\n" ; this . nameDB _ ? this . nameDB _ . reset ( ) : this . nameDB _ = new $ . module$build$src$core$names . Names ( this . RESERVED _WORDS _ ) ; this . nameDB _ . setVariableMap ( a . getVariableMap ( ) ) ; this . nameDB _ . populateVariables ( a ) ; this . nameDB _ . populateProcedures ( a ) ; const b = [ ] ; var c = $ . module$build$src$core$variables . allDeveloperVariables ( a ) ; for ( let d = 0 ; d < c . length ; d ++ ) b . push ( this . nameDB _ . getName ( c [ d ] , $ . module$build$src$core$names . Names . DEVELOPER _VARIABLE _TYPE ) +
" = None" ) ; a = $ . module$build$src$core$variables . allUsedVarModels ( a ) ; for ( c = 0 ; c < a . length ; c ++ ) b . push ( this . nameDB _ . getName ( a [ c ] . getId ( ) , $ . NameType$$module$build$src$core$names . VARIABLE ) + " = None" ) ; this . definitions _ . variables = b . join ( "\n" ) ; this . isInitialized = ! 0 } ;
module$exports$Blockly$Python . pythonGenerator . finish = function ( 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 = Object . getPrototypeOf ( this ) . finish . call ( this , 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 } ; module$exports$Blockly$Python . pythonGenerator . scrubNakedValue = function ( a ) { return a + "\n" } ;
module$exports$Blockly$Python . pythonGenerator . quote _ = function ( a ) { a = a . replace ( /\\/g , "\\\\" ) . replace ( /\n/g , "\\\n" ) ; let b = "'" ; - 1 !== a . indexOf ( "'" ) && ( - 1 === a . indexOf ( '"' ) ? b = '"' : a = a . replace ( /'/g , "\\'" ) ) ; return b + a + b } ; module$exports$Blockly$Python . pythonGenerator . multiline _quote _ = function ( a ) { return a . split ( /\n/g ) . map ( this . quote _ ) . join ( " + '\\n' + \n" ) } ;
module$exports$Blockly$Python . pythonGenerator . scrub _ = function ( a , b , c ) { let d = "" ; if ( ! a . outputConnection || ! a . outputConnection . targetConnection ) { var e = a . getCommentText ( ) ; e && ( e = $ . module$build$src$core$utils$string . wrap ( e , this . COMMENT _WRAP - 3 ) , d += this . prefixLines ( e + "\n" , "# " ) ) ; for ( let f = 0 ; f < a . inputList . length ; f ++ ) a . inputList [ f ] . type === $ . module$build$src$core$input _types . inputTypes . VALUE && ( 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 } ; module$exports$Blockly$Python . pythonGenerator . getAdjustedInt = function ( a , b , c , d ) { c = c || 0 ; a . workspace . options . oneBasedIndex && c -- ; const e = a . workspace . options . oneBasedIndex ? "1" : "0" ; a = this . valueToCode ( a , b , c ? this . ORDER _ADDITIVE : this . ORDER _NONE ) || e ; $ . module$build$src$core$utils$string . isNumber ( a ) ? ( a = parseInt ( a , 10 ) + c , d && ( a = - a ) ) : ( a = 0 < c ? "int(" + a + " + " + c + ")" : 0 > c ? "int(" + a + " - " + - c + ")" : "int(" + a + ")" , d && ( a = "-" + a ) ) ; return a } ; var module$exports$Blockly$Python$variables = { } , module$contents$Blockly$Python$variables _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$Python . pythonGenerator . variables _get = function ( a ) { return [ module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$Python . pythonGenerator . variables _set = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ; return module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) + " = " + b + "\n" } ; var module$exports$Blockly$Python$variablesDynamic = { } ; module$exports$Blockly$Python . pythonGenerator . variables _get _dynamic = module$exports$Blockly$Python . pythonGenerator . variables _get ; module$exports$Blockly$Python . pythonGenerator . variables _set _dynamic = module$exports$Blockly$Python . pythonGenerator . variables _set ; var module$exports$Blockly$Python$texts = { } , module$contents$Blockly$Python$texts _stringUtils = $ . module$build$src$core$utils$string , module$contents$Blockly$Python$texts _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$Python . pythonGenerator . text = function ( a ) { return [ module$exports$Blockly$Python . pythonGenerator . quote _ ( a . getFieldValue ( "TEXT" ) ) , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$Python . pythonGenerator . text _multiline = function ( a ) { a = module$exports$Blockly$Python . pythonGenerator . multiline _quote _ ( a . getFieldValue ( "TEXT" ) ) ; const b = - 1 !== a . indexOf ( "+" ) ? module$exports$Blockly$Python . pythonGenerator . ORDER _ADDITIVE : module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ; return [ a , b ] } ;
var module$contents$Blockly$Python$texts _strRegExp = /^\s*'([^']|\\')*'\s*$/ , module$contents$Blockly$Python$texts _forceString = function ( a ) { return module$contents$Blockly$Python$texts _strRegExp . test ( a ) ? [ a , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] : [ "str(" + a + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . text _join = function ( a ) { switch ( a . itemCount _ ) { case 0 : return [ "''" , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] ; case 1 : return a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ADD0" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" , module$contents$Blockly$Python$texts _forceString ( a ) ; case 2 : var b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ADD0" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) ||
"''" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ADD1" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ; return [ module$contents$Blockly$Python$texts _forceString ( b ) [ 0 ] + " + " + module$contents$Blockly$Python$texts _forceString ( a ) [ 0 ] , module$exports$Blockly$Python . pythonGenerator . ORDER _ADDITIVE ] ; default : b = [ ] ; for ( let c = 0 ; c < a . itemCount _ ; c ++ ) b [ c ] = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ADD" + c , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ;
a = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getDistinctName ( "x" , $ . NameType$$module$build$src$core$names . VARIABLE ) ; return [ "''.join([str(" + a + ") for " + a + " in [" + b . join ( ", " ) + "]])" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } } ;
module$exports$Blockly$Python . pythonGenerator . text _append = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ; return b + " = str(" + b + ") + " + module$contents$Blockly$Python$texts _forceString ( a ) [ 0 ] + "\n" } ;
module$exports$Blockly$Python . pythonGenerator . text _length = function ( a ) { return [ "len(" + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ) + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . text _isEmpty = function ( a ) { return [ "not len(" + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ) + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT ] } ;
module$exports$Blockly$Python . pythonGenerator . text _indexOf = function ( a ) { var b = "FIRST" === a . getFieldValue ( "END" ) ? "find" : "rfind" ; const c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "FIND" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ; b = ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ) + "." + b + "(" + c + ")" ; return a . workspace . options . oneBasedIndex ? [ b + " + 1" , module$exports$Blockly$Python . pythonGenerator . ORDER _ADDITIVE ] :
[ b , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . text _charAt = function ( a ) { const b = a . getFieldValue ( "WHERE" ) || "FROM_START" , c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , "RANDOM" === b ? module$exports$Blockly$Python . pythonGenerator . ORDER _NONE : module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ; switch ( b ) { case "FIRST" : return [ c + "[0]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ; case "LAST" : return [ c + "[-1]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ;
case "FROM_START" : return a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT" ) , [ c + "[" + a + "]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ; case "FROM_END" : return a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT" , 1 , ! 0 ) , [ c + "[" + a + "]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ; case "RANDOM" : return module$exports$Blockly$Python . pythonGenerator . definitions _ . import _random = "import random" , [ module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "text_random_letter" ,
`
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( text ) :
x = int ( random . random ( ) * len ( text ) )
return text [ x ]
` )+"("+c+")",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
module$exports$Blockly$Python . pythonGenerator . text _getSubstring = function ( a ) { var b = a . getFieldValue ( "WHERE1" ) ; const c = a . getFieldValue ( "WHERE2" ) , d = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "STRING" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ; switch ( b ) { case "FROM_START" : b = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT1" ) ; 0 === b && ( b = "" ) ; break ; case "FROM_END" : b = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT1" , 1 , ! 0 ) ; break ; case "FIRST" : b =
"" ; break ; default : throw Error ( "Unhandled option (text_getSubstring)" ) ; } switch ( c ) { case "FROM_START" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT2" , 1 ) ; break ; case "FROM_END" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT2" , 0 , ! 0 ) ; $ . module$build$src$core$utils$string . isNumber ( String ( a ) ) ? 0 === a && ( a = "" ) : ( module$exports$Blockly$Python . pythonGenerator . definitions _ . import _sys = "import sys" , a += " or sys.maxsize" ) ; break ; case "LAST" : a = "" ; break ; default : throw Error ( "Unhandled option (text_getSubstring)" ) ;
} return [ d + "[" + b + " : " + a + "]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] } ; module$exports$Blockly$Python . pythonGenerator . text _changeCase = function ( a ) { const b = { UPPERCASE : ".upper()" , LOWERCASE : ".lower()" , TITLECASE : ".title()" } [ a . getFieldValue ( "CASE" ) ] ; return [ ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ) + b , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . text _trim = function ( a ) { const b = { LEFT : ".lstrip()" , RIGHT : ".rstrip()" , BOTH : ".strip()" } [ a . getFieldValue ( "MODE" ) ] ; return [ ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ) + b , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . text _print = function ( a ) { return "print(" + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ) + ")\n" } ; module$exports$Blockly$Python . pythonGenerator . text _prompt _ext = function ( a ) { var b = module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "text_prompt" , `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( msg ) :
try :
return raw _input ( msg )
except NameError :
return input ( msg )
` );let c;c=a.getField("TEXT")?module $ exports $ Blockly $ Python.pythonGenerator.quote_(a.getFieldValue("TEXT")):module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"TEXT",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_NONE)||"''";b=b+"("+c+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="float("+b+")");return[b,module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL]};module $ exports $ Blockly $ Python.pythonGenerator.text_prompt=module $ exports $ Blockly $ Python.pythonGenerator.text_prompt_ext;
module$exports$Blockly$Python . pythonGenerator . text _count = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "SUB" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ; return [ b + ".count(" + a + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . text _replace = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" , c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "FROM" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TO" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ; return [ b + ".replace(" + c + ", " +
a + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] } ; module$exports$Blockly$Python . pythonGenerator . text _reverse = function ( a ) { return [ ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ) + "[::-1]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] } ; var module$exports$Blockly$Python$procedures = { } , module$contents$Blockly$Python$procedures _Variables = $ . module$build$src$core$variables , module$contents$Blockly$Python$procedures _NameType = $ . NameType$$module$build$src$core$names ;
module$exports$Blockly$Python . pythonGenerator . procedures _defreturn = function ( a ) { var b = [ ] , c = a . workspace , d = $ . module$build$src$core$variables . allUsedVarModels ( c ) || [ ] ; for ( let m = 0 , n ; n = d [ m ] ; m ++ ) { var e = n . name ; - 1 === a . getVars ( ) . indexOf ( e ) && b . push ( module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( e , $ . NameType$$module$build$src$core$names . VARIABLE ) ) } c = $ . module$build$src$core$variables . allDeveloperVariables ( c ) ; for ( d = 0 ; d < c . length ; d ++ ) b . push ( module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( c [ d ] ,
$ . NameType$$module$build$src$core$names . DEVELOPER _VARIABLE ) ) ; c = b . length ? module$exports$Blockly$Python . pythonGenerator . INDENT + "global " + b . join ( ", " ) + "\n" : "" ; b = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "NAME" ) , $ . NameType$$module$build$src$core$names . PROCEDURE ) ; d = "" ; module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX && ( d += module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX , a ) ) ; module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX &&
( d += module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX , a ) ) ; d && ( d = module$exports$Blockly$Python . pythonGenerator . prefixLines ( d , module$exports$Blockly$Python . pythonGenerator . INDENT ) ) ; e = "" ; module$exports$Blockly$Python . pythonGenerator . INFINITE _LOOP _TRAP && ( e = module$exports$Blockly$Python . pythonGenerator . prefixLines ( module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . INFINITE _LOOP _TRAP , a ) ,
module$exports$Blockly$Python . pythonGenerator . INDENT ) ) ; let f = module$exports$Blockly$Python . pythonGenerator . statementToCode ( a , "STACK" ) , g = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "RETURN" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "" , h = "" ; f && g && ( h = d ) ; g ? g = module$exports$Blockly$Python . pythonGenerator . INDENT + "return " + g + "\n" : f || ( f = module$exports$Blockly$Python . pythonGenerator . PASS ) ; const k = [ ] , l = a . getVars ( ) ; for ( let m = 0 ; m < l . length ; m ++ ) k [ m ] = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( l [ m ] ,
$ . NameType$$module$build$src$core$names . VARIABLE ) ; c = "def " + b + "(" + k . join ( ", " ) + "):\n" + c + d + e + f + h + g ; c = module$exports$Blockly$Python . pythonGenerator . scrub _ ( a , c ) ; module$exports$Blockly$Python . pythonGenerator . definitions _ [ "%" + b ] = c ; return null } ; module$exports$Blockly$Python . pythonGenerator . procedures _defnoreturn = module$exports$Blockly$Python . pythonGenerator . procedures _defreturn ;
module$exports$Blockly$Python . pythonGenerator . procedures _callreturn = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "NAME" ) , $ . NameType$$module$build$src$core$names . PROCEDURE ) , c = [ ] , d = a . getVars ( ) ; for ( let e = 0 ; e < d . length ; e ++ ) c [ e ] = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ARG" + e , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "None" ; return [ b + "(" + c . join ( ", " ) + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . procedures _callnoreturn = function ( a ) { return module$exports$Blockly$Python . pythonGenerator . procedures _callreturn ( a ) [ 0 ] + "\n" } ;
module$exports$Blockly$Python . pythonGenerator . procedures _ifreturn = function ( a ) { let b = "if " + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "CONDITION" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "False" ) + ":\n" ; module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX && ( b += module$exports$Blockly$Python . pythonGenerator . prefixLines ( module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX , a ) , module$exports$Blockly$Python . pythonGenerator . INDENT ) ) ;
a . hasReturnValue _ ? ( a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "None" , b += module$exports$Blockly$Python . pythonGenerator . INDENT + "return " + a + "\n" ) : b += module$exports$Blockly$Python . pythonGenerator . INDENT + "return\n" ; return b } ; var module$exports$Blockly$Python$math = { } , module$contents$Blockly$Python$math _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$Python . pythonGenerator . addReservedWords ( "math,random,Number" ) ;
module$exports$Blockly$Python . pythonGenerator . math _number = function ( a ) { a = Number ( a . getFieldValue ( "NUM" ) ) ; let b ; Infinity === a ? ( a = 'float("inf")' , b = module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ) : - Infinity === a ? ( a = '-float("inf")' , b = module$exports$Blockly$Python . pythonGenerator . ORDER _UNARY _SIGN ) : b = 0 > a ? module$exports$Blockly$Python . pythonGenerator . ORDER _UNARY _SIGN : module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ; return [ a , b ] } ;
module$exports$Blockly$Python . pythonGenerator . math _arithmetic = function ( a ) { var b = { ADD : [ " + " , module$exports$Blockly$Python . pythonGenerator . ORDER _ADDITIVE ] , MINUS : [ " - " , module$exports$Blockly$Python . pythonGenerator . ORDER _ADDITIVE ] , MULTIPLY : [ " * " , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ] , DIVIDE : [ " / " , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ] , POWER : [ " ** " , module$exports$Blockly$Python . pythonGenerator . ORDER _EXPONENTIATION ] } [ a . getFieldValue ( "OP" ) ] ;
const c = b [ 0 ] ; b = b [ 1 ] ; const d = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "A" , b ) || "0" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "B" , b ) || "0" ; return [ d + c + a , b ] } ;
module$exports$Blockly$Python . pythonGenerator . math _single = function ( a ) { const b = a . getFieldValue ( "OP" ) ; let c ; if ( "NEG" === b ) return c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "NUM" , module$exports$Blockly$Python . pythonGenerator . ORDER _UNARY _SIGN ) || "0" , [ "-" + c , module$exports$Blockly$Python . pythonGenerator . ORDER _UNARY _SIGN ] ; module$exports$Blockly$Python . pythonGenerator . definitions _ . import _math = "import math" ; a = "SIN" === b || "COS" === b || "TAN" === b ? module$exports$Blockly$Python . pythonGenerator . valueToCode ( a ,
"NUM" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ) || "0" : module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "NUM" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ; switch ( b ) { case "ABS" : c = "math.fabs(" + a + ")" ; break ; case "ROOT" : c = "math.sqrt(" + a + ")" ; break ; case "LN" : c = "math.log(" + a + ")" ; break ; case "LOG10" : c = "math.log10(" + a + ")" ; break ; case "EXP" : c = "math.exp(" + a + ")" ; break ; case "POW10" : c = "math.pow(10," + a + ")" ; break ; case "ROUND" : c = "round(" + a + ")" ; break ; case "ROUNDUP" : c =
"math.ceil(" + a + ")" ; break ; case "ROUNDDOWN" : c = "math.floor(" + a + ")" ; break ; case "SIN" : c = "math.sin(" + a + " / 180.0 * math.pi)" ; break ; case "COS" : c = "math.cos(" + a + " / 180.0 * math.pi)" ; break ; case "TAN" : c = "math.tan(" + a + " / 180.0 * math.pi)" } if ( c ) return [ c , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] ; switch ( b ) { case "ASIN" : c = "math.asin(" + a + ") / math.pi * 180" ; break ; case "ACOS" : c = "math.acos(" + a + ") / math.pi * 180" ; break ; case "ATAN" : c = "math.atan(" + a + ") / math.pi * 180" ; break ; default : throw Error ( "Unknown math operator: " +
b ) ; } return [ c , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ] } ;
module$exports$Blockly$Python . pythonGenerator . math _constant = function ( a ) { const b = { PI : [ "math.pi" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] , E : [ "math.e" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] , GOLDEN _RATIO : [ "(1 + math.sqrt(5)) / 2" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ] , SQRT2 : [ "math.sqrt(2)" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] , SQRT1 _2 : [ "math.sqrt(1.0 / 2)" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ,
INFINITY : [ "float('inf')" , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ; a = a . getFieldValue ( "CONSTANT" ) ; "INFINITY" !== a && ( module$exports$Blockly$Python . pythonGenerator . definitions _ . import _math = "import math" ) ; return b [ a ] } ;
module$exports$Blockly$Python . pythonGenerator . math _number _property = function ( a ) { var b = { EVEN : [ " % 2 == 0" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL ] , ODD : [ " % 2 == 1" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL ] , WHOLE : [ " % 1 == 0" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL ] ,
POSITIVE : [ " > 0" , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL ] , NEGATIVE : [ " < 0" , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL ] , DIVISIBLE _BY : [ null , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL ] , PRIME : [ null , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ,
module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ; const c = a . getFieldValue ( "PROPERTY" ) , [ d , e , f ] = b [ c ] ; b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "NUMBER_TO_CHECK" , e ) || "0" ; if ( "PRIME" === c ) module$exports$Blockly$Python . pythonGenerator . definitions _ . import _math = "import math" , module$exports$Blockly$Python . pythonGenerator . definitions _ . from _numbers _import _Number = "from numbers import Number" , a = module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "math_isPrime" , `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( n ) :
# https : //en.wikipedia.org/wiki/Primality_test#Naive_methods
# If n is not a number but a string , try parsing it .
if not isinstance ( n , Number ) :
try :
n = float ( n )
except :
return False
if n == 2 or n == 3 :
return True
# False if n is negative , is 1 , or not whole , or if n is divisible by 2 or 3.
if n <= 1 or n % 1 != 0 or n % 2 == 0 or n % 3 == 0 :
return False
# Check all the numbers of form 6 k + / - 1 , u p t o s q r t ( n ) .
for x in range ( 6 , int ( math . sqrt ( n ) ) + 2 , 6 ) :
if n % ( x - 1 ) == 0 or n % ( x + 1 ) == 0 :
return False
return True
` )+"("+b+")";else if("DIVISIBLE_BY"===c){a=module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"DIVISOR",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["False",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_ATOMIC];a=b+" % "+a+" == 0"}else a=b+d;return[a,f]};
module$exports$Blockly$Python . pythonGenerator . math _change = function ( a ) { module$exports$Blockly$Python . pythonGenerator . definitions _ . from _numbers _import _Number = "from numbers import Number" ; const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "DELTA" , module$exports$Blockly$Python . pythonGenerator . ORDER _ADDITIVE ) || "0" ; a = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) ; return a + " = (" + a + " if isinstance(" +
a + ", Number) else 0) + " + b + "\n" } ; module$exports$Blockly$Python . pythonGenerator . math _round = module$exports$Blockly$Python . pythonGenerator . math _single ; module$exports$Blockly$Python . pythonGenerator . math _trig = module$exports$Blockly$Python . pythonGenerator . math _single ;
module$exports$Blockly$Python . pythonGenerator . math _on _list = function ( a ) { var b = a . getFieldValue ( "OP" ) ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "[]" ; switch ( b ) { case "SUM" : b = "sum(" + a + ")" ; break ; case "MIN" : b = "min(" + a + ")" ; break ; case "MAX" : b = "max(" + a + ")" ; break ; case "AVERAGE" : module$exports$Blockly$Python . pythonGenerator . definitions _ . from _numbers _import _Number = "from numbers import Number" ; b = module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "math_mean" ,
`
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( myList ) :
localList = [ e for e in myList if isinstance ( e , Number ) ]
if not localList : return
return float ( sum ( localList ) ) / len ( localList )
` )+"("+a+")";break;case "MEDIAN":module $ exports $ Blockly $ Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";b=module $ exports $ Blockly $ Python.pythonGenerator.provideFunction_("math_median", `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( myList ) :
localList = sorted ( [ e for e in myList if isinstance ( e , Number ) ] )
if not localList : return
if len ( localList ) % 2 == 0 :
return ( localList [ len ( localList ) // 2 - 1] + localList[len(localList) // 2]) / 2.0
else :
return localList [ ( len ( localList ) - 1 ) // 2]
` )+"("+a+")";break;case "MODE":b=module $ exports $ Blockly $ Python.pythonGenerator.provideFunction_("math_modes", `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( some _list ) :
modes = [ ]
# Using a lists of [ item , count ] to keep count rather than dict
# to avoid "unhashable" errors when the counted item is itself a list or dict .
counts = [ ]
maxCount = 1
for item in some _list :
found = False
for count in counts :
if count [ 0 ] == item :
count [ 1 ] += 1
maxCount = max ( maxCount , count [ 1 ] )
found = True
if not found :
counts . append ( [ item , 1 ] )
for counted _item , item _count in counts :
if item _count == maxCount :
modes . append ( counted _item )
return modes
` )+"("+a+")";break;case "STD_DEV":module $ exports $ Blockly $ Python.pythonGenerator.definitions_.import_math="import math";b=module $ exports $ Blockly $ Python.pythonGenerator.provideFunction_("math_standard_deviation", `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( numbers ) :
n = len ( numbers )
if n == 0 : return
mean = float ( sum ( numbers ) ) / n
variance = sum ( ( x - mean ) * * 2 for x in numbers ) / n
return math . sqrt ( variance )
` )+"("+a+")";break;case "RANDOM":module $ exports $ Blockly $ Python.pythonGenerator.definitions_.import_random="import random";b="random.choice("+a+")";break;default:throw Error("Unknown operator: "+b);}return[b,module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$Python . pythonGenerator . math _modulo = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "DIVIDEND" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ) || "0" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "DIVISOR" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ) || "0" ; return [ b + " % " + a , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ] } ;
module$exports$Blockly$Python . pythonGenerator . math _constrain = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" , c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "LOW" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "HIGH" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "float('inf')" ; return [ "min(max(" +
b + ", " + c + "), " + a + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . math _random _int = function ( a ) { module$exports$Blockly$Python . pythonGenerator . definitions _ . import _random = "import random" ; const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "FROM" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TO" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ; return [ "random.randint(" + b + ", " + a + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . math _random _float = function ( a ) { module$exports$Blockly$Python . pythonGenerator . definitions _ . import _random = "import random" ; return [ "random.random()" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . math _atan2 = function ( a ) { module$exports$Blockly$Python . pythonGenerator . definitions _ . import _math = "import math" ; const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "X" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ; return [ "math.atan2(" + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "Y" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ) + ", " + b + ") / math.pi * 180" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ] } ; var module$exports$Blockly$Python$loops = { } , module$contents$Blockly$Python$loops _stringUtils = $ . module$build$src$core$utils$string , module$contents$Blockly$Python$loops _NameType = $ . NameType$$module$build$src$core$names ;
module$exports$Blockly$Python . pythonGenerator . controls _repeat _ext = function ( a ) { let b ; b = a . getField ( "TIMES" ) ? String ( parseInt ( a . getFieldValue ( "TIMES" ) , 10 ) ) : module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TIMES" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" ; b = $ . module$build$src$core$utils$string . isNumber ( b ) ? parseInt ( b , 10 ) : "int(" + b + ")" ; let c = module$exports$Blockly$Python . pythonGenerator . statementToCode ( a , "DO" ) ; c = module$exports$Blockly$Python . pythonGenerator . addLoopTrap ( c , a ) ||
module$exports$Blockly$Python . pythonGenerator . PASS ; return "for " + module$exports$Blockly$Python . pythonGenerator . nameDB _ . getDistinctName ( "count" , $ . NameType$$module$build$src$core$names . VARIABLE ) + " in range(" + b + "):\n" + c } ; module$exports$Blockly$Python . pythonGenerator . controls _repeat = module$exports$Blockly$Python . pythonGenerator . controls _repeat _ext ;
module$exports$Blockly$Python . pythonGenerator . controls _whileUntil = function ( a ) { const b = "UNTIL" === a . getFieldValue ( "MODE" ) ; let c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "BOOL" , b ? module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT : module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "False" , d = module$exports$Blockly$Python . pythonGenerator . statementToCode ( a , "DO" ) ; d = module$exports$Blockly$Python . pythonGenerator . addLoopTrap ( d , a ) || module$exports$Blockly$Python . pythonGenerator . PASS ;
b && ( c = "not " + c ) ; return "while " + c + ":\n" + d } ;
module$exports$Blockly$Python . pythonGenerator . controls _for = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) ; var c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "FROM" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" , d = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TO" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "0" , e = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a ,
"BY" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "1" ; let f = module$exports$Blockly$Python . pythonGenerator . statementToCode ( a , "DO" ) ; f = module$exports$Blockly$Python . pythonGenerator . addLoopTrap ( f , a ) || module$exports$Blockly$Python . pythonGenerator . PASS ; let g = "" ; const h = function ( ) { return module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "upRange" , `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( start , stop , step ) :
while start <= stop :
yield start
start += abs ( step )
` )},k=function(){return module $ exports $ Blockly $ Python.pythonGenerator.provideFunction_("downRange", `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( start , stop , step ) :
while start >= stop :
yield start
start -= abs ( step )
` )};a=function(l,m,n){return"("+l+" <= "+m+") and "+h()+"("+l+", "+m+", "+n+") or "+k()+"("+l+", "+m+", "+n+")"};if( $ .module $ build $ src $ core $ utils $ string.isNumber(c)&& $ .module $ build $ src $ core $ utils $ string.isNumber(d)&& $ .module $ build $ src $ core $ utils $ string.isNumber(e))c=Number(c),d=Number(d),e=Math.abs(Number(e)),0===c%1&&0===d%1&&0===e%1?(c<=d?(d++,a=0===c&&1===e?d:c+", "+d,1!==e&&(a+=", "+e)):(d--,a=c+", "+d+", -"+e),a="range("+a+")"):(a=c<d?h():k(),a+="("+c+", "+d+", "+e+")");else{const l=function(m,
n ) { $ . module$build$src$core$utils$string . isNumber ( m ) ? m = Number ( m ) : m . match ( /^\w+$/ ) || ( n = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getDistinctName ( b + n , $ . NameType$$module$build$src$core$names . VARIABLE ) , g += n + " = " + m + "\n" , m = n ) ; return m } ; c = l ( c , "_start" ) ; d = l ( d , "_end" ) ; e = l ( e , "_inc" ) ; "number" === typeof c && "number" === typeof d ? ( a = c < d ? h ( ) : k ( ) , a += "(" + c + ", " + d + ", " + e + ")" ) : a = a ( c , d , e ) } return g += "for " + b + " in " + a + ":\n" + f } ;
module$exports$Blockly$Python . pythonGenerator . controls _forEach = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) , c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL ) || "[]" ; let d = module$exports$Blockly$Python . pythonGenerator . statementToCode ( a , "DO" ) ; d = module$exports$Blockly$Python . pythonGenerator . addLoopTrap ( d , a ) || module$exports$Blockly$Python . pythonGenerator . PASS ;
return "for " + b + " in " + c + ":\n" + d } ;
module$exports$Blockly$Python . pythonGenerator . controls _flow _statements = function ( a ) { let b = "" ; module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX && ( b += module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX , a ) ) ; module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX && ( b += module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX , a ) ) ; if ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX ) { const c =
a . getSurroundLoop ( ) ; c && ! c . suppressPrefixSuffix && ( b += module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX , c ) ) } switch ( a . getFieldValue ( "FLOW" ) ) { case "BREAK" : return b + "break\n" ; case "CONTINUE" : return b + "continue\n" } throw Error ( "Unknown flow statement." ) ; } ; var module$exports$Blockly$Python$logic = { } ;
module$exports$Blockly$Python . pythonGenerator . controls _if = function ( a ) { let b = 0 , c = "" , d , e ; module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX && ( c += module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _PREFIX , a ) ) ; do e = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "IF" + b , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "False" , d = module$exports$Blockly$Python . pythonGenerator . statementToCode ( a , "DO" + b ) || module$exports$Blockly$Python . pythonGenerator . PASS ,
module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX && ( d = module$exports$Blockly$Python . pythonGenerator . prefixLines ( module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX , a ) , module$exports$Blockly$Python . pythonGenerator . INDENT ) + d ) , c += ( 0 === b ? "if " : "elif " ) + e + ":\n" + d , b ++ ; while ( a . getInput ( "IF" + b ) ) ; if ( a . getInput ( "ELSE" ) || module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX ) d = module$exports$Blockly$Python . pythonGenerator . statementToCode ( a ,
"ELSE" ) || module$exports$Blockly$Python . pythonGenerator . PASS , module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX && ( d = module$exports$Blockly$Python . pythonGenerator . prefixLines ( module$exports$Blockly$Python . pythonGenerator . injectId ( module$exports$Blockly$Python . pythonGenerator . STATEMENT _SUFFIX , a ) , module$exports$Blockly$Python . pythonGenerator . INDENT ) + d ) , c += "else:\n" + d ; return c } ; module$exports$Blockly$Python . pythonGenerator . controls _ifelse = module$exports$Blockly$Python . pythonGenerator . controls _if ;
module$exports$Blockly$Python . pythonGenerator . logic _compare = function ( a ) { const b = { EQ : "==" , NEQ : "!=" , LT : "<" , LTE : "<=" , GT : ">" , GTE : ">=" } [ a . getFieldValue ( "OP" ) ] , c = module$exports$Blockly$Python . pythonGenerator . ORDER _RELATIONAL , d = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "A" , c ) || "0" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "B" , c ) || "0" ; return [ d + " " + b + " " + a , c ] } ;
module$exports$Blockly$Python . pythonGenerator . logic _operation = function ( a ) { const b = "AND" === a . getFieldValue ( "OP" ) ? "and" : "or" , c = "and" === b ? module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _AND : module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _OR ; let d = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "A" , c ) ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "B" , c ) ; if ( d || a ) { const e = "and" === b ? "True" : "False" ; d || ( d = e ) ; a || ( a = e ) } else a = d = "False" ; return [ d + " " + b + " " + a ,
c ] } ; module$exports$Blockly$Python . pythonGenerator . logic _negate = function ( a ) { return [ "not " + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "BOOL" , module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT ) || "True" ) , module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT ] } ; module$exports$Blockly$Python . pythonGenerator . logic _boolean = function ( a ) { return [ "TRUE" === a . getFieldValue ( "BOOL" ) ? "True" : "False" , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$Python . pythonGenerator . logic _null = function ( a ) { return [ "None" , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$Python . pythonGenerator . logic _ternary = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "IF" , module$exports$Blockly$Python . pythonGenerator . ORDER _CONDITIONAL ) || "False" , c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "THEN" , module$exports$Blockly$Python . pythonGenerator . ORDER _CONDITIONAL ) || "None" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ELSE" , module$exports$Blockly$Python . pythonGenerator . ORDER _CONDITIONAL ) || "None" ;
return [ c + " if " + b + " else " + a , module$exports$Blockly$Python . pythonGenerator . ORDER _CONDITIONAL ] } ; var module$exports$Blockly$Python$lists = { } , module$contents$Blockly$Python$lists _stringUtils = $ . module$build$src$core$utils$string , module$contents$Blockly$Python$lists _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$Python . pythonGenerator . lists _create _empty = function ( a ) { return [ "[]" , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$Python . pythonGenerator . lists _create _with = function ( a ) { const b = Array ( a . itemCount _ ) ; for ( let c = 0 ; c < a . itemCount _ ; c ++ ) b [ c ] = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ADD" + c , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "None" ; return [ "[" + b . join ( ", " ) + "]" , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$Python . pythonGenerator . lists _repeat = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "ITEM" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "None" ; a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "NUM" , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ) || "0" ; return [ "[" + b + "] * " + a , module$exports$Blockly$Python . pythonGenerator . ORDER _MULTIPLICATIVE ] } ;
module$exports$Blockly$Python . pythonGenerator . lists _length = function ( a ) { return [ "len(" + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "[]" ) + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . lists _isEmpty = function ( a ) { return [ "not len(" + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "[]" ) + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _LOGICAL _NOT ] } ;
module$exports$Blockly$Python . pythonGenerator . lists _indexOf = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "FIND" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "[]" , c = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "''" ; let d = " -1" , e = "" , f = " - 1" ; a . workspace . options . oneBasedIndex && ( d = " 0" , e = " + 1" , f = "" ) ; return [ ( "FIRST" === a . getFieldValue ( "END" ) ? module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "first_index" ,
`
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( my _list , elem ) :
try : index = my _list . index ( elem ) $ { e }
except : index = $ { d }
return index
` ):module $ exports $ Blockly $ Python.pythonGenerator.provideFunction_("last_index", `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( my _list , elem ) :
try : index = len ( my _list ) - my _list [ : : - 1 ] . index ( elem ) $ { f }
except : index = $ { d }
return index
` ))+"("+c+", "+b+")",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$Python . pythonGenerator . lists _getIndex = function ( a ) { const b = a . getFieldValue ( "MODE" ) || "GET" , c = a . getFieldValue ( "WHERE" ) || "FROM_START" ; var d = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "VALUE" , "RANDOM" === c ? module$exports$Blockly$Python . pythonGenerator . ORDER _NONE : module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "[]" ; switch ( c ) { case "FIRST" : if ( "GET" === b ) return [ d + "[0]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d +
".pop(0)" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".pop(0)\n" ; break ; case "LAST" : if ( "GET" === b ) return [ d + "[-1]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d + ".pop()" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".pop()\n" ; break ; case "FROM_START" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT" ) ; if ( "GET" === b ) return [ d + "[" + a + "]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ;
if ( "GET_REMOVE" === b ) return [ d + ".pop(" + a + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".pop(" + a + ")\n" ; break ; case "FROM_END" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT" , 1 , ! 0 ) ; if ( "GET" === b ) return [ d + "[" + a + "]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d + ".pop(" + a + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".pop(" + a + ")\n" ; break ; case "RANDOM" : module$exports$Blockly$Python . pythonGenerator . definitions _ . import _random =
"import random" ; if ( "GET" === b ) return [ "random.choice(" + d + ")" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] ; d = module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "lists_remove_random_item" , `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( myList ) :
x = int ( random . random ( ) * len ( myList ) )
return myList . pop ( x )
` )+"("+d+")";if("GET_REMOVE"===b)return[d,module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+" \n "}throw Error("Unhandled combination (lists_getIndex).");};
module$exports$Blockly$Python . pythonGenerator . lists _setIndex = function ( a ) { let b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "[]" ; const c = a . getFieldValue ( "MODE" ) || "GET" ; var d = a . getFieldValue ( "WHERE" ) || "FROM_START" ; const e = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "TO" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "None" ; switch ( d ) { case "FIRST" : if ( "SET" === c ) return b + "[0] = " + e + "\n" ; if ( "INSERT" ===
c ) return b + ".insert(0, " + e + ")\n" ; break ; case "LAST" : if ( "SET" === c ) return b + "[-1] = " + e + "\n" ; if ( "INSERT" === c ) return b + ".append(" + e + ")\n" ; break ; case "FROM_START" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT" ) ; if ( "SET" === c ) return b + "[" + a + "] = " + e + "\n" ; if ( "INSERT" === c ) return b + ".insert(" + a + ", " + e + ")\n" ; break ; case "FROM_END" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT" , 1 , ! 0 ) ; if ( "SET" === c ) return b + "[" + a + "] = " + e + "\n" ; if ( "INSERT" === c ) return b + ".insert(" + a + ", " +
e + ")\n" ; break ; case "RANDOM" : module$exports$Blockly$Python . pythonGenerator . definitions _ . import _random = "import random" ; b . match ( /^\w+$/ ) ? a = "" : ( a = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getDistinctName ( "tmp_list" , $ . NameType$$module$build$src$core$names . VARIABLE ) , d = a + " = " + b + "\n" , b = a , a = d ) ; d = module$exports$Blockly$Python . pythonGenerator . nameDB _ . getDistinctName ( "tmp_x" , $ . NameType$$module$build$src$core$names . VARIABLE ) ; a += d + " = int(random.random() * len(" + b + "))\n" ; if ( "SET" === c ) return a + ( b + "[" +
d + "] = " + e + "\n" ) ; if ( "INSERT" === c ) return a + ( b + ".insert(" + d + ", " + e + ")\n" ) } throw Error ( "Unhandled combination (lists_setIndex)." ) ; } ;
module$exports$Blockly$Python . pythonGenerator . lists _getSublist = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "[]" ; var c = a . getFieldValue ( "WHERE1" ) ; const d = a . getFieldValue ( "WHERE2" ) ; switch ( c ) { case "FROM_START" : c = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT1" ) ; 0 === c && ( c = "" ) ; break ; case "FROM_END" : c = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT1" , 1 , ! 0 ) ; break ;
case "FIRST" : c = "" ; break ; default : throw Error ( "Unhandled option (lists_getSublist)" ) ; } switch ( d ) { case "FROM_START" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT2" , 1 ) ; break ; case "FROM_END" : a = module$exports$Blockly$Python . pythonGenerator . getAdjustedInt ( a , "AT2" , 0 , ! 0 ) ; $ . module$build$src$core$utils$string . isNumber ( String ( a ) ) ? 0 === a && ( a = "" ) : ( module$exports$Blockly$Python . pythonGenerator . definitions _ . import _sys = "import sys" , a += " or sys.maxsize" ) ; break ; case "LAST" : a = "" ; break ; default : throw Error ( "Unhandled option (lists_getSublist)" ) ;
} return [ b + "[" + c + " : " + a + "]" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ] } ; module$exports$Blockly$Python . pythonGenerator . lists _sort = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "[]" , c = a . getFieldValue ( "TYPE" ) ; a = "1" === a . getFieldValue ( "DIRECTION" ) ? "False" : "True" ; return [ module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "lists_sort" , `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( my _list , type , reverse ) :
def try _float ( s ) :
try :
return float ( s )
except :
return 0
key _funcs = {
"NUMERIC" : try _float ,
"TEXT" : str ,
"IGNORE_CASE" : lambda s : str ( s ) . lower ( )
}
key _func = key _funcs [ type ]
list _cpy = list ( my _list )
return sorted ( list _cpy , key = key _func , reverse = reverse )
` )+"("+b+', "'+c+'", '+a+")",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$Python . pythonGenerator . lists _split = function ( a ) { var b = a . getFieldValue ( "MODE" ) ; if ( "SPLIT" === b ) b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "INPUT" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" , a = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "DELIM" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) , a = b + ".split(" + a + ")" ; else if ( "JOIN" === b ) b = module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "INPUT" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) ||
"[]" , a = ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "DELIM" , module$exports$Blockly$Python . pythonGenerator . ORDER _MEMBER ) || "''" ) + ".join(" + b + ")" ; else throw Error ( "Unknown mode: " + b ) ; return [ a , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . lists _reverse = function ( a ) { return [ "list(reversed(" + ( module$exports$Blockly$Python . pythonGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$Python . pythonGenerator . ORDER _NONE ) || "[]" ) + "))" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ; var module$exports$Blockly$Python$colour = { } ; module$exports$Blockly$Python . pythonGenerator . colour _picker = function ( a ) { return [ module$exports$Blockly$Python . pythonGenerator . quote _ ( a . getFieldValue ( "COLOUR" ) ) , module$exports$Blockly$Python . pythonGenerator . ORDER _ATOMIC ] } ; module$exports$Blockly$Python . pythonGenerator . colour _random = function ( a ) { module$exports$Blockly$Python . pythonGenerator . definitions _ . import _random = "import random" ; return [ "'#%06x' % random.randint(0, 2**24 - 1)" , module$exports$Blockly$Python . pythonGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$Python . pythonGenerator . colour _rgb = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "colour_rgb" , `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( r , g , b ) :
r = round ( min ( 100 , max ( 0 , r ) ) * 2.55 )
g = round ( min ( 100 , max ( 0 , g ) ) * 2.55 )
b = round ( min ( 100 , max ( 0 , b ) ) * 2.55 )
return '#%02x%02x%02x' % ( r , g , b )
` ),c=module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"RED",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_NONE)||0,d=module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"GREEN",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_NONE)||0;a=module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"BLUE",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$Python . pythonGenerator . colour _blend = function ( a ) { const b = module$exports$Blockly$Python . pythonGenerator . provideFunction _ ( "colour_blend" , `
def $ { module$exports$Blockly$Python . pythonGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( colour1 , colour2 , ratio ) :
r1 , r2 = int ( colour1 [ 1 : 3 ] , 16 ) , int ( colour2 [ 1 : 3 ] , 16 )
g1 , g2 = int ( colour1 [ 3 : 5 ] , 16 ) , int ( colour2 [ 3 : 5 ] , 16 )
b1 , b2 = int ( colour1 [ 5 : 7 ] , 16 ) , int ( colour2 [ 5 : 7 ] , 16 )
ratio = min ( 1 , max ( 0 , ratio ) )
r = round ( r1 * ( 1 - ratio ) + r2 * ratio )
g = round ( g1 * ( 1 - ratio ) + g2 * ratio )
b = round ( b1 * ( 1 - ratio ) + b2 * ratio )
return '#%02x%02x%02x' % ( r , g , b )
` ),c=module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"COLOUR1",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_NONE)||"'#000000'",d=module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"COLOUR2",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_NONE)||"'#000000'";a=module $ exports $ Blockly $ Python.pythonGenerator.valueToCode(a,"RATIO",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module $ exports $ Blockly $ Python.pythonGenerator.ORDER_FUNCTION_CALL]};var module $ exports $ Blockly $ Python $ all=module $ exports $ Blockly $ Python;
module$exports$Blockly$Python . _ _namespace _ _ = $ ;
return module$exports$Blockly$Python ;
2021-08-28 14:28:26 +00:00
} ) ) ;
//# sourceMappingURL=python_compressed.js.map