guess_format_name

hexrec.base.guess_format_name(file_path)[source]

Guesses the record format name.

It analyzes the file extension by file_path against all the record formats registered into file_types. The first record format to match the extension within its own BaseFile.FILE_EXT is returned.

Parameters:

file_path (str) – File path to analyze.

Returns:

str – Record format registered within file_types.

Raises:

ValueError – Cannot guess record file format.

See also

file_types

Examples

>>> from hexrec import guess_format_name
>>> guess_format_name('simple.hex')
'ihex'
>>> guess_format_name('simple.srec')
'srec'
>>> guess_format_name('simple.s19')
'srec'
>>> guess_format_name('simple.mot')
'srec'
>>> guess_format_name('data.dat')
'raw'