Python Library - Onix-Systems/GBL-NINJA-SDK-Multiplatform GitHub Wiki

Python Library

Python port of the Kotlin library with identical functionality for GBL file manipulation.

Installation

pip install gbl-ninja==1.0.0

Usage

Parse GBL File

from gbl import Gbl
from results.parse_result import ParseResult

gbl_parser = Gbl()
result = gbl_parser.parse_byte_array(gbl_data)

if isinstance(result, ParseResult.Success):
    print(f"Successfully parsed {len(result.result_list)} tags")
    # Process tags
else:
    print(f"Parse failed: {result.error}")

Create GBL File

builder = Gbl().GblBuilder.create()
builder.application(type_val=32, version=0x10000)
builder.prog(flash_start_address=0x1000, data=firmware_data)

gbl_bytes = builder.build_to_byte_array()

Load from File

with open('firmware.gbl', 'rb') as f:
    gbl_data = f.read()
    
result = gbl_parser.parse_byte_array(gbl_data)

Features

  • Complete Python implementation
  • Identical API to Kotlin version
  • Cross-platform compatibility
  • Easy integration with Python projects