convert¶
- hexrec.base.convert(in_path_or_stream, out_path, in_format=None, out_format=None)[source]¶
Converts a file into another format.
This is a simple helper function for basic conversion of a file on the filesystem into another record format.
The function returns the input and output file objects, for further processing by the user.
- Parameters:
in_path_or_stream (str) – Input file path or stream.
out_path (str) – Output file path. It can be the same as in_path.
in_format (str) – Name of the input format, within
file_types. IfNone, it is guessed via brute-forceload().out_format (str) – Name of the output format, within
file_types. IfNone, it is guessed viaguess_format_name().
- Returns:
(in_file, out_file) – Input and output file objects used internally.
Examples
>>> from hexrec import convert >>> convert('simple.hex', 'simple.srec') >>> convert('simple.hex', 'simple.srec', in_format='ihex', out_format='srec')