Return the default extension defined for a given format.
Parameters
- filetype_format: (str)
Returns
- (str) Extension with the dot or empty string
Return the default extension defined for a given format.
@staticmethod
def get_default_extension(filetype_format):
"""Return the default extension defined for a given format.
:param filetype_format: (str)
:return: (str) Extension with the dot or empty string
"""
if filetype_format in list(sppasFiles.DEFAULT_EXTENSIONS.keys()):
return sppasFiles.DEFAULT_EXTENSIONS[filetype_format]
return ''
Return the list of input extensions a format can support.
@staticmethod
def get_informat_extensions(filetype_format):
"""Return the list of input extensions a format can support.
:param filetype_format: (str)
:return: (list) Extensions, starting with the dot.
"""
if filetype_format == 'ANNOT':
all_ext_in = sppasTrsRW.extensions_in()
return ['.' + e for e in all_ext_in]
if filetype_format == 'ANNOT_ANNOT':
annot_ext = sppasTrsRW.annot_extensions()
all_ext_in = sppasTrsRW.extensions_in()
return ['.' + e for e in annot_ext if e in all_ext_in]
if filetype_format == 'ANNOT_MEASURE':
annot_ext = sppasTrsRW.measure_extensions()
all_ext_in = sppasTrsRW.extensions_in()
return ['.' + e for e in annot_ext if e in all_ext_in]
if filetype_format == 'ANNOT_TABLE':
annot_ext = sppasTrsRW.table_extensions()
all_ext_in = sppasTrsRW.extensions_in()
return ['.' + e for e in annot_ext if e in all_ext_in]
if filetype_format == 'IMAGE':
return image_extensions
if filetype_format == 'VIDEO':
return video_extensions
if filetype_format == 'AUDIO':
return sppasExtensionsSettings().AUDIO
logging.warning('Unknown filetype format: {}. Expected one of: {}.'.format(filetype_format, annots.typeformat))
return list()
Return the list of output extensions an out_format can support.
@staticmethod
def get_outformat_extensions(filetype_format):
"""Return the list of output extensions an out_format can support.
:param filetype_format: (str)
:return: (list) Extensions, starting with the dot.
"""
if filetype_format == 'ANNOT':
all_ext_in = sppasTrsRW.extensions_in()
return ['.' + e for e in all_ext_in]
if filetype_format == 'ANNOT_ANNOT':
annot_ext = sppasTrsRW.annot_extensions()
all_ext_out = sppasTrsRW.extensions_out()
return ['.' + e for e in annot_ext if e in all_ext_out]
if filetype_format == 'ANNOT_MEASURE':
annot_ext = sppasTrsRW.measure_extensions()
all_ext_out = sppasTrsRW.extensions_out()
return ['.' + e for e in annot_ext if e in all_ext_out]
if filetype_format == 'ANNOT_TABLE':
annot_ext = sppasTrsRW.table_extensions()
all_ext_out = sppasTrsRW.extensions_out()
return ['.' + e for e in annot_ext if e in all_ext_out]
if filetype_format == 'IMAGE':
return image_extensions
if filetype_format == 'VIDEO':
return video_extensions
if filetype_format == 'AUDIO':
return sppasExtensionsSettings().AUDIO
return list()