parameters: (_fn, _text, **options)
return_statement: return result[-1][1](**options)
docstring: Lookup all lexers that handle those filenames primary (``filenames``)
      or secondary (``alias_filenames``). Then run a text analysis for those
      lexers and choose the best result.
  
      usage::
  
          >>> from pygments.lexers import guess_lexer_for_filename
          >>> guess_lexer_for_filename('hello.html', '<%= @foo %>')
          <pygments.lexers.templates.RhtmlLexer object at 0xb7d2f32c>
          >>> guess_lexer_for_filename('hello.html', '<h1>{{ title|e }}</h1>')
          <pygments.lexers.templates.HtmlDjangoLexer object at 0xb7d2f2ac>
          >>> guess_lexer_for_filename('style.css', 'a { color: <?= $link ?> }')
          <pygments.lexers.templates.CssPhpLexer object at 0xb7ba518c>
docstring_summary: Lookup all lexers that handle those filenames primary (``filenames``)
      or secondary (``alias_filenames``). Then run a text analysis for those
      lexers and choose the best result.
docstring_tokens: Lookup all lexers that handle those filenames primary ( filenames ) or secondary ( alias_filenames ) . Then run a text analysis for those lexers and choose the best result .
function: def guess_lexer_for_filename(_fn, _text, **options):
      """
      Lookup all lexers that handle those filenames primary (``filenames``)
      or secondary (``alias_filenames``). Then run a text analysis for those
      lexers and choose the best result.
  
      usage::
  
          >>> from pygments.lexers import guess_lexer_for_filename
          >>> guess_lexer_for_filename('hello.html', '<%= @foo %>')
          <pygments.lexers.templates.RhtmlLexer object at 0xb7d2f32c>
          >>> guess_lexer_for_filename('hello.html', '<h1>{{ title|e }}</h1>')
          <pygments.lexers.templates.HtmlDjangoLexer object at 0xb7d2f2ac>
          >>> guess_lexer_for_filename('style.css', 'a { color: <?= $link ?> }')
          <pygments.lexers.templates.CssPhpLexer object at 0xb7ba518c>
      """
      fn = basename(_fn)
      primary = None
      matching_lexers = set()
      for lexer in _iter_lexerclasses():
          for filename in lexer.filenames:
              if fnmatch.fnmatch(fn, filename):
                  matching_lexers.add(lexer)
                  primary = lexer
          for filename in lexer.alias_filenames:
              if fnmatch.fnmatch(fn, filename):
                  matching_lexers.add(lexer)
      if not matching_lexers:
          raise ClassNotFound('no lexer for filename %r found' % fn)
      if len(matching_lexers) == 1:
          return matching_lexers.pop()(**options)
      result = []
      for lexer in matching_lexers:
          rv = lexer.analyse_text(_text)
          if rv == 1.0:
              return lexer(**options)
          result.append((rv, lexer))
      result.sort()
      if not result[-1][0] and primary is not None:
          return primary(**options)
      return result[-1][1](**options)
function_tokens: def guess_lexer_for_filename ( _fn , _text , * * options ) : fn = basename ( _fn ) primary = None matching_lexers = set ( ) for lexer in _iter_lexerclasses ( ) : for filename in lexer . filenames : if fnmatch . fnmatch ( fn , filename ) : matching_lexers . add ( lexer ) primary = lexer for filename in lexer . alias_filenames : if fnmatch . fnmatch ( fn , filename ) : matching_lexers . add ( lexer ) if not matching_lexers : raise ClassNotFound ( 'no lexer for filename %r found' % fn ) if len ( matching_lexers ) == 1 : return matching_lexers . pop ( ) ( * * options ) result = [ ] for lexer in matching_lexers : rv = lexer . analyse_text ( _text ) if rv == 1.0 : return lexer ( * * options ) result . append ( ( rv , lexer ) ) result . sort ( ) if not result [ - 1 ] [ 0 ] and primary is not None : return primary ( * * options ) return result [ - 1 ] [ 1 ] ( * * options )