
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
blocklypy
Advanced tools
LEGO SPIKE and EV3 Mindstorms Code to Pybricks - block-code analyzer and converter to Pybricks python code
This tool and library will read, analyze and convert the LEGO standard graphical blockly files to Pybricks python files.
SPIKE Prime (45678) and SPIKE Essentials (45345) kit and Robot Inventor (51515) kit for word-blocks and icon-blocks transformation and LEGO python for analysis only.
EV3 Mindstorms kit (31313) LabView EV3-G code transformation:
Analysis only:
Blocklypy CLI tool is a standalone tool that one can install and run on a node environment locally.
Generate and print python converted code of a SPIKE blockly source code file.
blocklypy python testfile.llsp3
Detailed documentation of the command line interface tool.
Blocklypy library is a TypeScript library packaged for both browser and node.js environment usage.
const { convertProjectToPython } = require('blocklypy');
const fname = 'testfile.llsp';
const file = fs.readFileSync(fname);
const options = {};
const inputfiles = [{ name: fname, buffer: file }];
const result = convertProjectToPython(inputfiles, options).then((retval) => {
console.log(retval.pycode);
});
Detailed documentation of the blocklypy library.
Attila Farago (@afarago)
Blocklypy CLI tool is a standalone tool that one can install and run on a node environment locally.
Usage: blocklypy [options] [command]
Command line interface for blocklypy to analyze and convert LEGO robotics code to Python.
Blocklypy converts LEGO robotics code to Pybricks python, converting and analyzing word-block, icon-block, ev3g and ev3 compiled code.
Options:
-V, --version output the version number
-o, --open Open the output file in the default viewer
-h, --help display help for command
Commands:
graph|g [options] <input> Generate dependency callgraph content
preview [options] <input> Save preview content
python|py [options] <input> [stackfilter] Convert and save python content, with optional stack filtering
plain [options] <input> Convert and save plain pseudocode content
help [command] display help for command
npm install -g blocklypyblocklypy -hConvert and print a SPIKE blockly source code file to python.
blocklypy python testfile.llsp3
Convert and save an EV3Classroom source code file to python.
blocklypy python --python testfile.lmsp
Generate and save svg dependency call graph of a EV3-G source code file.
blocklypy graph --svg --open testfile.ev3
Generate and save png dependency call graph of a pybricks code module zip and open it locally.
blocklypy graph --png testfile.zip
Decompile an EV3-G compiled RBF source code file and save the pseudocode as a text file.
blocklypy plain --txt testfile.rbf
Extract and save blockly diagram code of an Robot Inventor source code file.
blocklypy preview --svg testfile.lms
Blocklypy library is a TypeScript library packaged for both browser and node.js environment usage.
const { convertProjectToPython } = require('blocklypy');
const file = fs.readFileSync(__FILE__);
const options = {};
const inputfiles = [{ name: __FILE__, buffer: file }];
convertProjectToPython(inputfiles, options).then((retval) => {
console.log(retval.pycode);
});
Type: IPyProjectResult
Type: string | string[]
Python representation of the blockly code in Pybricks flavour.
"""
Project: test1
Slot: 0
Created: 2024-09-02T09:08:14.079Z
Last saved: 2024-09-03T16:57:06.369Z
"""
#region ========================== SECTION: IMPORTS ========================== #
from pybricks.hubs import PrimeHub
from pybricks.tools import wait
#endregion
...
#region ======================= SECTION: PROGRAM CODE ======================== #
# ------------------------------- GROUP: START ------------------------------- #
# STACK #1: flipperevents_whenProgramStarts()
def stack1_whenprogramstarts_fn():
hub.display.pixel(0, 0, 100)
hub.display.icon(convert_icon_matrix("9909999099000009000909990", g_pixel_brightness))
wait(convert_time(g_aa))
hub.display.off()
#endregion
#region ====================== SECTION: MAIN CODE ============================ #
stack1_whenprogramstarts_fn()
#endregion
Type: string
Pseudo code of the blockly code.
flipperevents_whenProgramStarts()
flipperlight_lightDisplaySetPixel(x: "1", y: "1", brightness: 100)
flipperlight_lightDisplayImageOnForTime(matrix: "9909999099000009000909990", value: g_aa)
flippermove_movementSpeed(speed: 50)
flippermove_startMove(direction: "back")
data_setvariableto(value: "0", variable: "aa")
data_changevariableby(value: 13, variable: "aa")
flipperlight_lightDisplayImageOn(matrix: "9909999099000009000909990")
Type: object
Contains input format dependent extra information such as blockly slot and svg preview or rbf disassembly.
{
"blockly.slot": 0,
"blockly.svg": "<svg xmlns='http://www.w3.org/2000/svg…fa6d44c8e6aa1eaca43d65'/><defs></g></svg>"
}
Type: string
Graphviz dot format representation of the python code call structure.
digraph ev3graph {
rankdir = LR
"demo_ev3treevis" -> "TestProgram1"
"demo_ev3treevis" -> "UsingMyBlocks"
"TestProgram1" -> "Limit"
"UsingMyBlocks" -> "DriveCmDetectColor"
...
}
FAQs
BlocklyPy: SPIKE to Pybricks - word-block converter to Pybricks python code
The npm package blocklypy receives a total of 129 weekly downloads. As such, blocklypy popularity was classified as not popular.
We found that blocklypy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.