ignore any errors when detecting language type with pygments
This commit is contained in:
parent
fdbd0fa941
commit
98b9056c77
1 changed files with 1 additions and 2 deletions
|
@ -18,7 +18,6 @@ if sys.version_info[0] == 2:
|
||||||
else:
|
else:
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'packages', 'pygments3'))
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'packages', 'pygments3'))
|
||||||
from pygments.lexers import guess_lexer_for_filename
|
from pygments.lexers import guess_lexer_for_filename
|
||||||
from pygments.util import ClassNotFound
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -29,7 +28,7 @@ def guess_language(file_name):
|
||||||
try:
|
try:
|
||||||
with open(file_name) as f:
|
with open(file_name) as f:
|
||||||
lexer = guess_lexer_for_filename(file_name, f.read(512000))
|
lexer = guess_lexer_for_filename(file_name, f.read(512000))
|
||||||
except (ClassNotFound, IOError):
|
except:
|
||||||
pass
|
pass
|
||||||
if lexer:
|
if lexer:
|
||||||
return str(lexer.name)
|
return str(lexer.name)
|
||||||
|
|
Loading…
Reference in a new issue