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
EXTENSIONS = {
'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:
pass
if lexer:
return str(lexer.name)
return translate_language(str(lexer.name))
else:
return None
@ -56,6 +60,12 @@ def guess_language_from_extension(extension):
return None
def translate_language(language):
if language in TRANSLATIONS:
language = TRANSLATIONS[language]
return language
def number_lines_in_file(file_name):
lines = 0
try: