ISL to Python conversion

Parent Previous Next

Purpose

Use isl2py.exe to convert legacy winIDEA script to python code.

Usage

isl2py.exe [-h] <file> [<file>]… [-o <output directory>]

       -h                     prints help

       <file>                 input file name

       -o <output directory>  valid output directory

Examples

covert  example1.isl into example1.py and save it to current directory:

isl2py.exe example1.isl


covert  example1.isl into example1.py and save it to specified directory:

isl2py.exe example1.isl –o C:/temp/


convert all .isl files to python  and save them to specified directory:

isl2py.exe *.isl –o C:/temp/


Python script header and footer explanation

The isl2py.exe adds auto generated header and footer to the python script. An example of header is:

#auto generate lines by isl2py.exe

import isystem.islAPI

api = isystem.islAPI.IWrapper('')

api.setLogger(isystem.islAPI.LogLevel.INFO, isystem.islAPI.ExceptPrint.YES)

#end of auto generate lines


The first and last lines are comments. The second line imports islAPI wrapper module, located inside python installation subfolder \Lib\site-packages\isystem\. The third line is an IWrapper class instantiation with most recent workspace as default parameter. Any valid workspace given as parameter can override the default option. The fourth line sets the IWrapper log level and enables/disables exception printouts. Class method documentation:

class islAPI.IWrapper

IWrapper.setLogger(logLevel, exceptionsPrintout)

logLevel is an islAPI.LogLevel class item and can have several log levels (from highest to lowest). LogLevel.INFO is a default option, set at  islAPI.IWrapper class instantiation. LogLevel.INFO is also recommended log level option and provides the same level of output as isl script does to winIdea terminal.

       class LogLevel:

CRITICAL = 5

ERROR = 4

                   WARNING = 3

               INFO = 2

               DEBUG = 1

               NOTSET = 0


exceptionsPrintout is an islAPI.ExceptPrint class item. ExceptPrint.NO is a default option, set at islAPI.IWrapper class instantiation. ExceptPrint.YES prints (to python console) potential exceptions raised inside wrapper and provides more information about error (for debug purposes).

class ExceptPrint:

               YES = True

               NO = False


Auto generated Python footer:

#auto generate lines by isl2py.exe

"if __name__ == '__main__':

main()

#end of auto generate lines

Python script extension

There are two possibilities to extend python script using isystem.connect interface.

create a new connection:

...
cm =ic.ConnectionMgr()
cm.connectMRU('')
dbg = ic.CDebugFacade(cm)

dbg.download()

api.APISetBreakpoint(0, "main")
...


get existing connection by IWrapper.getConnectionMgr() method (available since 9.11.29) – preferred method

dbg = ic.CDebugFacade(api.getConnectionMgr())

dbg.download()

api.APISetBreakpoint(0, “main”)