SPPAS 4.20

Module sppas.src.annotations

Class sppasFiles

Public functions

get_default_extension

Return the default extension defined for a given format.

Parameters
  • filetype_format: (str)
Returns
  • (str) Extension with the dot or empty string
View Source
@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 ''
get_informat_extensions

Return the list of input extensions a format can support.

Parameters
  • filetype_format: (str)
Returns
  • (list) Extensions, starting with the dot.
View Source
@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 audio_extensions
    logging.warning('Unknown filetype format: {}. Expected one of: {}.'.format(filetype_format, annots.typeformat))
    return list()
get_outformat_extensions

Return the list of output extensions an out_format can support.

Parameters
  • filetype_format: (str)
Returns
  • (list) Extensions, starting with the dot.
View Source
@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 audio_extensions
    return list()