def find_lexer_for_filename(filename):
 filename = (filename or '')
 (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 TextLexer()
 return lexer

def find_lexer_for_filename ( filename ) : filename = ( filename or '' ) ( 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 TextLexer ( ) return lexer
get a pygments lexer given a filename .