changeset 6566:f9b67a894e21

pygmentsutils: don't fail if an extension doesn't speficy EXTRA_LEXERS
author Andrew Shadura <andrew@shadura.me>
date Tue, 04 Apr 2017 16:54:35 +0200
parents 42bbccdec0a0
children 3c469080bb2a
files kallithea/lib/pygmentsutils.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/pygmentsutils.py	Tue Apr 04 15:22:48 2017 +0200
+++ b/kallithea/lib/pygmentsutils.py	Tue Apr 04 16:54:35 2017 +0200
@@ -86,7 +86,7 @@
     if there's no custom lexer defined
     """
     import kallithea
-    #check if we didn't define this extension as other lexer
-    if kallithea.EXTENSIONS and extension in kallithea.EXTENSIONS.EXTRA_LEXERS:
-        _lexer_name = kallithea.EXTENSIONS.EXTRA_LEXERS[extension]
-        return lexers.get_lexer_by_name(_lexer_name)
+    lexer_name = getattr(kallithea.EXTENSIONS, 'EXTRA_LEXERS', {}).get(extension)
+    if lexer_name is None:
+        return None
+    return lexers.get_lexer_by_name(lexer_name)