Using (python code) .py fileis it possible to generate XML block? (python code to xml code)

181 views
Skip to first unread message

Naresh Chaudhari

unread,
Apr 8, 2021, 11:08:03 AM4/8/21
to Blockly
Hi @all.

I have python file and it is contains import libraries, some class and no of methods(functions). 

for ex: 
import time
import traceback
import sys
import copy
import os

import logger.logger as logger
from regal.utility import GetRegal

class Enum0nfWithoutSubIdSignalling():
    """
    comments.
    """
    def __init__(self):
        self._log = logger.GetLogger("Enum0nfWithoutSubIdSignalling")
        self._log.debug(">")
        self._system_alerts = []
        self._failure_causes = []
        self._note = []
         .......
        self._validate_stats_obj = ValidateStats(stats_config)
        self._log.debug("<")

    def _start_simulator(self):
        self._log.debug(">")
        // code
        self._log.debug("<")

    def _stop_simulator(self):
        self._log.debug(">")
        // code
        self._log.debug("<")


Similar to (BlockMirror) or below image
Capture1.PNG

So Here in the BlockMirror its is generating the xml block keyword-by-keyword(statement to statement) like that how do i can generate in blockly workspace using the file.

I have done it from JSON code to XML block code here (https://groups.google.com/u/4/g/blockly/c/H3a-bGIFprc)

Coda Highland

unread,
Apr 8, 2021, 12:50:00 PM4/8/21
to blo...@googlegroups.com
There's nothing prebuilt for it. Python's parser module may be helpful in getting a syntax tree you can analyze and then you can assemble blocks out of what you process there.

/s/ Adam

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/b4d3e742-d61b-40dd-b830-e7eccbde1cd8n%40googlegroups.com.

Mark Friedman

unread,
Apr 8, 2021, 1:47:58 PM4/8/21
to blo...@googlegroups.com
I'll also point out that BlockMirror is an open source project, so you can take a look at how they do it here.

-Mark


Reply all
Reply to author
Forward
0 new messages