| 1378 | } |
| 1379 | |
| 1380 | function 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 | |
| 1397 | function rewriteBlocklyLua (code, { product }) { |
| 1398 | return code |