Changeset - dec78aee1d53
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2012-11-13 23:49:04
marcin@python-works.com
small change to is_binary function logic so it always skips the unicode conversions to perform this simple check
1 file changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/vcs/nodes.py
Show inline comments
 
@@ -273,22 +273,26 @@ class FileNode(Node):
 
        if self.changeset:
 
            mode = self.changeset.get_file_mode(self.path)
 
        else:
 
            mode = self._mode
 
        return mode
 

	
 
    def _get_content(self):
 
        if self.changeset:
 
            content = self.changeset.get_file_content(self.path)
 
        else:
 
            content = self._content
 
        return content
 

	
 
    @property
 
    def content(self):
 
        """
 
        Returns lazily content of the FileNode. If possible, would try to
 
        decode content from UTF-8.
 
        """
 
        if self.changeset:
 
            content = self.changeset.get_file_content(self.path)
 
        else:
 
            content = self._content
 
        content = self._get_content()
 

	
 
        if bool(content and '\0' in content):
 
            return content
 
        return safe_unicode(content)
 

	
 
    @LazyProperty
 
@@ -403,13 +407,13 @@ class FileNode(Node):
 

	
 
    @property
 
    def is_binary(self):
 
        """
 
        Returns True if file has binary content.
 
        """
 
        _bin = '\0' in self.content
 
        _bin = '\0' in self._get_content()
 
        return _bin
 

	
 
    @LazyProperty
 
    def extension(self):
 
        """Returns filenode extension"""
 
        return self.name.split('.')[-1]
0 comments (0 inline, 0 general)