Exemplo n.º 1
0
    def testGetFileExtension(self):
        """Test getting a files extension"""
        ext = ebmlib.GetFileExtension(u'hello.txt')
        self.assertTrue(ext == u'txt')

        ext = ebmlib.GetFileExtension(u'hello.py')
        self.assertTrue(ext == u'py')

        ext = ebmlib.GetFileExtension(u'hello.txt.tmp')
        self.assertTrue(ext == u'tmp')
Exemplo n.º 2
0
    def IsKnownBinType(self, path):
        """Is a known binary file type
        @param path: file path / name

        """
        ext = ebmlib.GetFileExtension(path)
        if ext in ('exe', 'dll', 'so'):  # TODO better mapping
            self._ftype = FBMimeMgr.IMG_BIN
        else:
            return False
        return True
 def DoGetFileImage(self, path):
     """Get the image for the given item"""
     iconmgr = ProjectUtil.FileIcons
     if not os.access(path, os.R_OK):
         return iconmgr.IMG_NO_ACCESS
     elif os.path.isdir(path):
         if os.path.exists(os.path.join(path, "__init__.py")):
             return iconmgr.IMG_PACKAGE
         return iconmgr.IMG_FOLDER
     lpath = path.lower()
     fext = ebmlib.GetFileExtension(lpath)
     if fext in ('py', 'pyw'):
         return iconmgr.IMG_PYTHON
     elif fext in ('png', 'gif', 'ico', 'jpg', 'jpeg', 'bmp', 'icns'):
         return iconmgr.IMG_IMAGE
     else:
         return iconmgr.IMG_FILE
Exemplo n.º 4
0
    def IsKnownTextFile(self, path):
        """Is a known text file type
        @param path: file path / name

        """
        tpath = os.path.basename(path)
        ext = ebmlib.GetFileExtension(tpath)
        etype = syntax.GetIdFromExt(ext)
        tmap = { synglob.ID_LANG_PYTHON : FBMimeMgr.IMG_PYTHON,
                 synglob.ID_LANG_BOO : FBMimeMgr.IMG_BOO,
                 synglob.ID_LANG_CSS : FBMimeMgr.IMG_CSS,
                 synglob.ID_LANG_HTML : FBMimeMgr.IMG_HTML,
                 synglob.ID_LANG_JAVA : FBMimeMgr.IMG_JAVA,
                 synglob.ID_LANG_PHP : FBMimeMgr.IMG_PHP,
                 synglob.ID_LANG_RUBY : FBMimeMgr.IMG_RUBY,
                 synglob.ID_LANG_BASH : FBMimeMgr.IMG_SHELL }
        self._ftype = tmap.get(etype, FBMimeMgr.IMG_FILE)
        return self._ftype != FBMimeMgr.IMG_FILE