def add_parser_to_cascade(self, parser: AnyParser, typ: Type = None):
        """
        Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
        to the parser capabilities (single and multifile support, extensions).
        Subsequent parsers will have to support the same capabilities at least, to be added.

        :param parser:
        :param typ:
        :return:
        """
        # the first parser added will configure the cascade
        if not self.configured:
            self.supported_exts = parser.supported_exts
            self.supported_types = parser.supported_types

        # check if new parser is compliant with previous ones
        if self.supports_singlefile():
            if not parser.supports_singlefile():
                raise ValueError(
                    'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
                    'configuration (singlefile support)')

        if self.supports_multifile():
            if not parser.supports_multifile():
                raise ValueError(
                    'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
                    'configuration (multifile support)')

        if AnyObject not in parser.supported_types:
            if typ is None:
                # in that case the expected types for this parser will be self.supported_types
                if AnyObject in self.supported_types:
                    raise ValueError(
                        'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
                        'configuration (the cascade supports any type while the parser only supports '
                        + str(parser.supported_types) + ')')
                else:
                    missing_types = set(self.supported_types) - set(parser.supported_types)
                    if len(missing_types) > 0:
                        raise ValueError(
                            'Cannot add this parser to this parsing cascade : it does not match the rest of the '
                            'cascades configuration (supported types should at least contain the supported types '
                            'already in place. The parser misses type(s) ' + str(missing_types) + ')')
            else:
                # a parser is added but with a specific type target (parallel cascade)
                if typ == AnyObject:
                    raise ValueError(
                        'Cannot add this parser to this parsing cascade : it does not match the expected type "Any", '
                        'it only supports ' + str(parser.supported_types))
                # else:
                #     if get_base_generic_type(typ) not in parser.supported_types:
                #         raise ValueError(
                #             'Cannot add this parser to this parsing cascade : it does not match the expected type ' +
                #             str(typ) + ', it only supports ' + str(parser.supported_types))

        missing_exts = set(self.supported_exts) - set(parser.supported_exts)
        if len(missing_exts) > 0:
            raise ValueError(
                'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
                'configuration (supported extensions should at least contain the supported extensions already in '
                'place. The parser misses extension(s) ' + str(missing_exts) + ')')

        # finally add it
        self._parsers_list.append((typ, parser))
def add_parser_to_cascade ( self , parser : AnyParser , typ : Type = None ) : if not self . configured : self . supported_exts = parser . supported_exts self . supported_types = parser . supported_types if self . supports_singlefile ( ) : if not parser . supports_singlefile ( ) : raise ValueError ( 'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades ' 'configuration (singlefile support)' ) if self . supports_multifile ( ) : if not parser . supports_multifile ( ) : raise ValueError ( 'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades ' 'configuration (multifile support)' ) if AnyObject not in parser . supported_types : if typ is None : if AnyObject in self . supported_types : raise ValueError ( 'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades ' 'configuration (the cascade supports any type while the parser only supports ' + str ( parser . supported_types ) + ')' ) else : missing_types = set ( self . supported_types ) - set ( parser . supported_types ) if len ( missing_types ) > 0 : raise ValueError ( 'Cannot add this parser to this parsing cascade : it does not match the rest of the ' 'cascades configuration (supported types should at least contain the supported types ' 'already in place. The parser misses type(s) ' + str ( missing_types ) + ')' ) else : if typ == AnyObject : raise ValueError ( 'Cannot add this parser to this parsing cascade : it does not match the expected type "Any", ' 'it only supports ' + str ( parser . supported_types ) ) missing_exts = set ( self . supported_exts ) - set ( parser . supported_exts ) if len ( missing_exts ) > 0 : raise ValueError ( 'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades ' 'configuration (supported extensions should at least contain the supported extensions already in ' 'place. The parser misses extension(s) ' + str ( missing_exts ) + ')' ) self . _parsers_list . append ( ( typ , parser ) )
Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
        to the parser capabilities (single and multifile support, extensions).
        Subsequent parsers will have to support the same capabilities at least, to be added.

        :param parser:
        :param typ:
        :return: