load

hexrec.base.load(in_path_or_stream, *load_args, in_format=None, **load_kwargs)[source]

Loads a file.

This is a simple helper function to load a record file from the filesystem.

All the custom load_args and load_kwargs are forwarded to the actual underlying call to BaseFile.load().

Parameters:
  • in_path_or_stream (str) – Input file path or stream. If None, sys.stdin.buffer is used.

  • in_format (str) – Name of the input format, within file_types. If None, it is guessed via brute-force BaseFile.load().

Returns:

BaseFile – The loaded record file object.

Examples

>>> from hexrec import load
>>> load('simple.hex')
<hexrec.formats.ihex.IhexFile object at ...>
>>> load('simple.hex', in_format='ihex')
<hexrec.formats.ihex.IhexFile object at ...>
>>> load('simple.hex', ignore_errors=True)
<hexrec.formats.ihex.IhexFile object at ...>