Return filenames with standard extensions from template name
The typical case is returning image and header filenames for an Analyze image, that expects and ‘image’ file type, with, extension .img, and a ‘header’ file type, with extension .hdr.
Parameters : | template_fname : str
types_exts : sequence of sequences
trailing_suffixes : sequence of strings, optional
enforce_extensions : {True, False}, optional
match_case : bool, optional
|
---|---|
Returns : | types_fnames : dict
|
Examples
>>> types_exts = (('t1','.ext1'),('t2', '.ext2'))
>>> tfns = types_filenames('/path/test.ext1', types_exts)
>>> tfns == {'t1': '/path/test.ext1', 't2': '/path/test.ext2'}
True
Bare file roots without extensions get them added
>>> tfns = types_filenames('/path/test', types_exts)
>>> tfns == {'t1': '/path/test.ext1', 't2': '/path/test.ext2'}
True
With enforce_extensions == False, allow first type to have any extension.
>>> tfns = types_filenames('/path/test.funny', types_exts,
... enforce_extensions=False)
>>> tfns == {'t1': '/path/test.funny', 't2': '/path/test.ext2'}
True