log tracebacks in debug mode when unable to detect language
This commit is contained in:
parent
6379953b24
commit
723dd42fa9
1 changed files with 13 additions and 12 deletions
|
@ -117,13 +117,13 @@ def guess_lexer_using_filename(file_name, text):
|
|||
try:
|
||||
lexer = custom_pygments_guess_lexer_for_filename(file_name, text)
|
||||
except:
|
||||
pass
|
||||
log.traceback(logging.DEBUG)
|
||||
|
||||
if lexer is not None:
|
||||
try:
|
||||
accuracy = lexer.analyse_text(text)
|
||||
except:
|
||||
pass
|
||||
log.traceback(logging.DEBUG)
|
||||
|
||||
return lexer, accuracy
|
||||
|
||||
|
@ -140,19 +140,19 @@ def guess_lexer_using_modeline(text):
|
|||
try:
|
||||
file_type = get_filetype_from_buffer(text)
|
||||
except: # pragma: nocover
|
||||
pass
|
||||
log.traceback(logging.DEBUG)
|
||||
|
||||
if file_type is not None:
|
||||
try:
|
||||
lexer = get_lexer_by_name(file_type)
|
||||
except ClassNotFound:
|
||||
pass
|
||||
log.traceback(logging.DEBUG)
|
||||
|
||||
if lexer is not None:
|
||||
try:
|
||||
accuracy = lexer.analyse_text(text)
|
||||
except: # pragma: nocover
|
||||
pass
|
||||
log.traceback(logging.DEBUG)
|
||||
|
||||
return lexer, accuracy
|
||||
|
||||
|
@ -240,13 +240,14 @@ def get_language_from_json(language, key):
|
|||
'languages',
|
||||
'{0}.json').format(key.lower())
|
||||
|
||||
if os.path.exists(file_name):
|
||||
try:
|
||||
with open(file_name, 'r', encoding='utf-8') as fh:
|
||||
languages = json.loads(fh.read())
|
||||
if languages.get(language.lower()):
|
||||
return languages[language.lower()]
|
||||
except:
|
||||
pass
|
||||
log.traceback(logging.DEBUG)
|
||||
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in a new issue