merge¶
- hexrec.base.merge(in_paths_or_streams, out_path_or_stream=Ellipsis, 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_or_streams (str list) – Sequence of input file paths or streams, in merging order.
out_path_or_stream (str) – Output file path. It can be the same one of in_paths_or_streams. If
None,sys.stdout.bufferis used. IfEllipsis, no output is performed (return values only).in_formats (str list) – Name of the input formats, within
file_types. If the sequence or an item isNone, that is guessed viaguess_format_name().out_format (str) – Name of the output format, within
file_types. IfNone, it is guessed viaguess_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 ...>)