hexrec.records.convert_file#
- hexrec.records.convert_file(input_file, output_file, input_type=None, output_type=None, split_args=None, split_kwargs=None, build_args=None, build_kwargs=None)[source]#
Converts a record file to another record type.
Warning
Only binary data is kept; metadata will be overwritten by the call to
Record.build_standalone()
.- Parameters:
input_file (str) – Path of the input file.
output_file (str) – Path of the output file.
input_type (type) – Explicit input record type. If
None
, it is guessed from the file extension.output_type (type) – Explicit output record type. If
None
, it is guessed from the file extension.split_args (list) – Positional arguments for
Record.split()
.split_kwargs (dict) – Keyword arguments for
Record.split()
.build_args (list) – Positional arguments for
Record.build_standalone()
.build_kwargs (dict) – Keyword arguments for
Record.build_standalone()
.
Example
>>> from hexrec.formats.intel import Record as IntelRecord >>> from hexrec.formats.motorola import Record as MotorolaRecord >>> motorola = list(MotorolaRecord.split(bytes(range(256)))) >>> intel = list(IntelRecord.split(bytes(range(256)))) >>> save_records('bytes.mot', motorola) >>> convert_file('bytes.mot', 'bytes.hex') >>> load_records('bytes.hex') == intel True