merge#

hexrec.base.merge(in_paths, out_path=None, in_formats=None, out_format=None)[source]#

Merges multiple files.

This is a simple helper function to load multiple files from the filesystem and merge into a new one.

The function returns the list of input file objects and the output file object, for further processing by the user.

Parameters:
  • in_paths (str list) – Sequence of input file paths, in merging order.

  • out_path (str) – Output file path. It can be the same one of in_paths.

  • in_formats (str list) – Name of the input formats, within FILE_TYPES. If the sequence or an item is None, that is guessed via guess_format_name().

  • out_format (str) – Name of the output format, within FILE_TYPES. If None, it is guessed via guess_format_name().

Returns:

(in_files, out_file) – The record file objects used internally.

Examples

>>> from hexrec import merge
>>> merge(['data.dat', 'simple.hex'], 'merge.xtek')  
([<hexrec.formats.raw.RawFile object at ...>,
  <hexrec.formats.ihex.IhexFile object at ...>],
 <hexrec.formats.xtek.XtekFile object at ...>)
>>> merge(['data.dat', 'simple.hex'], 'merge.xtek',
...       in_formats=['raw', None], out_format='xtek')  
([<hexrec.formats.raw.RawFile object at ...>,
  <hexrec.formats.ihex.IhexFile object at ...>],
 <hexrec.formats.xtek.XtekFile object at ...>)