(_text, **options)
return best_lexer[1](**options)
Guess a lexer by strong distinctions in the text (eg, shebang).
Guess a lexer by strong distinctions in the text (eg, shebang).
Guess a lexer by strong distinctions in the text ( eg shebang ) .
def guess_lexer(_text, **options):
    """
    Guess a lexer by strong distinctions in the text (eg, shebang).
    """
    best_lexer = [0.0, None]
    for lexer in _iter_lexerclasses():
        rv = lexer.analyse_text(_text)
        if rv == 1.0:
            return lexer(**options)
        if rv > best_lexer[0]:
            best_lexer[:] = (rv, lexer)
    if not best_lexer[0] or best_lexer[1] is None:
        raise ClassNotFound('no lexer matching the text found')
    return best_lexer[1](**options)
def guess_lexer ( _text , * * options ) : best_lexer = [ 0.0 , None ] for lexer in _iter_lexerclasses ( ) : rv = lexer . analyse_text ( _text ) if rv == 1.0 : return lexer ( * * options ) if rv > best_lexer [ 0 ] : best_lexer [ : ] = ( rv , lexer ) if not best_lexer [ 0 ] or best_lexer [ 1 ] is None : raise ClassNotFound ( 'no lexer matching the text found' ) return best_lexer [ 1 ] ( * * options )