force some languages to be recognized as others

This commit is contained in:
Alan Hamlett 2013-10-26 14:06:54 -07:00
parent 1038529fd0
commit ffd557dfef

View file

@ -26,7 +26,11 @@ log = logging.getLogger(__name__)
# force file name extensions to be recognized as a certain language # force file name extensions to be recognized as a certain language
EXTENSIONS = { EXTENSIONS = {
'md': 'Markdown', 'md': 'Markdown',
'js': 'JavaScript', }
TRANSLATIONS = {
'JavaScript+Lasso': 'JavaScript',
'CSS+Lasso': 'CSS',
'CSS+Genshi Text': 'CSS',
} }
@ -42,7 +46,7 @@ def guess_language(file_name):
except: except:
pass pass
if lexer: if lexer:
return str(lexer.name) return translate_language(str(lexer.name))
else: else:
return None return None
@ -56,6 +60,12 @@ def guess_language_from_extension(extension):
return None return None
def translate_language(language):
if language in TRANSLATIONS:
language = TRANSLATIONS[language]
return language
def number_lines_in_file(file_name): def number_lines_in_file(file_name):
lines = 0 lines = 0
try: try: