MCPcopy Index your code
hub / github.com/codecombat/codecombat / rewriteBlocklyPython

Function rewriteBlocklyPython

app/core/blocklyUtils.js:1380–1395  ·  view source on GitHub ↗
(code, { product })

Source from the content-addressed store, hash-verified

1378}
1379
1380function rewriteBlocklyPython (code, { product }) {
1381 let oldCode
1382 do {
1383 oldCode = code
1384 code = code.replace(/^[a-zA-Z0-9_-s]+ = None\n/, '')
1385 } while (code !== oldCode)
1386
1387 // Replace count, count2, etc. repeat variables with i, j, etc. in Python code
1388 code = code.replace(/\bcount(\d*)\b/g, (match, num) => {
1389 const index = num ? parseInt(num) : 1
1390 const letter = String.fromCharCode(105 + index - 1) // 105 is ASCII code for 'i'
1391 return letter
1392 })
1393
1394 return code.trim()
1395}
1396
1397function rewriteBlocklyLua (code, { product }) {
1398 return code

Callers 1

blocklyUtils.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected