Changeset - c5dd289ca96e
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 12 years ago 2013-05-19 20:55:40
marcin@python-works.com
lazy load pygments lib so we can use VCS without it installed
1 file changed with 1 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/vcs/nodes.py
Show inline comments
 
@@ -10,14 +10,12 @@
 
"""
 
import os
 
import stat
 
import posixpath
 
import mimetypes
 

	
 
from pygments import lexers
 

	
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 
from rhodecode.lib.vcs.exceptions import NodeError, RemovedFileNodeError
 
from rhodecode.lib.vcs.utils.lazy import LazyProperty
 
from rhodecode.lib.vcs.utils import safe_unicode
 

	
 

	
 
@@ -357,13 +355,13 @@ class FileNode(Node):
 
    @LazyProperty
 
    def lexer(self):
 
        """
 
        Returns pygment's lexer class. Would try to guess lexer taking file's
 
        content, name and mimetype.
 
        """
 

	
 
        from pygments import lexers
 
        try:
 
            lexer = lexers.guess_lexer_for_filename(self.name, self.content, stripnl=False)
 
        except lexers.ClassNotFound:
 
            lexer = lexers.TextLexer(stripnl=False)
 
        # returns first alias
 
        return lexer
0 comments (0 inline, 0 general)