def guess_pygments_highlighter(filename):
 try:
  from pygments.lexers import get_lexer_for_filename, get_lexer_by_name
  from pygments.util import ClassNotFound
 except ImportError:
  return TextSH
 (root, ext) = os.path.splitext(filename)
 if (ext in custom_extension_lexer_mapping):
  lexer = get_lexer_by_name(custom_extension_lexer_mapping[ext])
 else:
  try:
   lexer = get_lexer_for_filename(filename)
  except ClassNotFound:
   return TextSH
 class GuessedPygmentsSH(PygmentsSH, ):
  _lexer = lexer
 return GuessedPygmentsSH

def guess_pygments_highlighter ( filename ) : try : from pygments . lexers import get_lexer_for_filename , get_lexer_by_name from pygments . util import ClassNotFound except ImportError : return TextSH ( root , ext ) = os . path . splitext ( filename ) if ( ext in custom_extension_lexer_mapping ) : lexer = get_lexer_by_name ( custom_extension_lexer_mapping [ ext ] ) else : try : lexer = get_lexer_for_filename ( filename ) except ClassNotFound : return TextSH class GuessedPygmentsSH ( PygmentsSH , ) : _lexer = lexer return GuessedPygmentsSH
factory to generate syntax highlighter for the given filename .