PrVrSs / rigel

WIP. Python bytecode manipulation library and analysis framework.

Home Page:https://pyrigel.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


🪐 Rigel - WIP

Python bytecode manipulation library and analysis framework.

Build Status Codecov License Python Version Linting


Example

import dis

from rigel import dump, make_code_object


def main():
    code_object = make_code_object(
        instructions=[
            dis.Instruction(opname='LOAD_NAME', opcode=101, arg=0, argval='print', argrepr='print', offset=0, starts_line=1, is_jump_target=False),
            dis.Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval='string 1', argrepr="'string 1'", offset=2, starts_line=None, is_jump_target=False),
            dis.Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=4, starts_line=None, is_jump_target=False),
            dis.Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=6, starts_line=None, is_jump_target=False),
            dis.Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=None, argrepr='None', offset=8, starts_line=None, is_jump_target=False),
            dis.Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=10, starts_line=None, is_jump_target=False),
        ]
    )
    
    with open('filename.pyc', 'wb') as fp:
        dump(code_object, fp, version=(3, 10))


if __name__ == '__main__':
    main()

Supported Python

  • 3.9
  • 3.10
  • 3.11

About

WIP. Python bytecode manipulation library and analysis framework.

https://pyrigel.readthedocs.io/

License:Apache License 2.0


Languages

Language:Python 99.4%Language:Makefile 0.6%