Hexfile manipulation

>>> from ppci.format.hexfile import HexFile
>>> h = HexFile()
>>> h.add_region(0, bytes([1, 2, 3]))
>>> h.add_region(0x100, 'Hello world of hex'.encode('utf8'))
>>> h
Hexfile containing 21 bytes
>>> h.dump()
Hexfile containing 21 bytes
Region at 0x00000000 of 3 bytes
00000000  01 02 03                                          |...|
Region at 0x00000100 of 18 bytes
00000100  48 65 6c 6c 6f 20 77 6f  72 6c 64 20 6f 66 20 68  |Hello.world.of.h|
00000110  65 78                                             |ex|


Module to work with intel hex files.

This module can be used to work with intel hexfiles.

class ppci.format.hexfile.HexFile

Represents an intel hexfile

add_region(address, data)

Add a chunk of data at the given address


Print info about this hexfile

static load(open_file)

Load a hexfile from file


Save hexfile to file-like object


Write a single hexfile line

exception ppci.format.hexfile.HexFileException

Exception raised when hexfile handling fails

class ppci.format.hexfile.HexFileRegion(address, data=b'')

A continuous region of data starting at some address


Add data to this region


End address for this region


The size of this region

class ppci.format.hexfile.HexLine(address, typ, data=b'')

A single line in a hexfile

classmethod from_line(line: str)

Parses a hexfile line into three parts

to_line() → str

Create an ascii hex line