Ejemplo n.º 1
0
    def ShouldDisplayFile(self, path):
        """Check if the given file should be displayed based on configuration
        @param path: file path
        @return: bool

        """
        showHidden = fbcfg.GetFBOption(fbcfg.FB_SHF_OPT, False)
        if not showHidden and ebmlib.IsHidden(path):
            return False
        name = os.path.basename(path)
        filters = fbcfg.GetFBOption(fbcfg.FB_FILTER_OPT,
                                    fbcfg.FB_DEFAULT_FILTERS)
        if filter(lambda x: fnmatch.fnmatchcase(name, x), filters):
            return False
        return True
Ejemplo n.º 2
0
    def OnPageChange(self, msg):
        """Synchronize selection with the notebook page changes
        @param msg: MessageObject
        @todo: check if message is from a page closing and avoid updates

        """
        if self.isClosing:
            self.isClosing = False
            return

        if not fbcfg.GetFBOption(fbcfg.FB_SYNC_OPT, True):
            return

        nbdata = msg.GetData()
        if not nbdata[0]:
            return

        pg_count = nbdata[0].GetPageCount()
        if nbdata[1] > pg_count or nbdata[1] < 0:
            # Page is out of range, something has changed since the
            # message was sent.
            return

        page = nbdata[0].GetPage(nbdata[1])
        if page:
            path = getattr(page, 'GetFileName', lambda: u"")()
            if len(path) and os.path.exists(path):
                # Delay selection for smoother operation when many
                # page change events are received in a short time.
                if self.syncTimer.IsRunning():
                    self.syncTimer.Stop()
                self._cpath = path
                self.syncTimer.Start(500, True)
Ejemplo n.º 3
0
    def FilterFileList(self, paths):
        """Filter a list of files returning only the ones that are valid to
        display in the tree. Optimized for large lists of paths.
        @param paths: list of paths
        @return: filtered list

        """
        showHidden = fbcfg.GetFBOption(fbcfg.FB_SHF_OPT, False)
        filters = fbcfg.GetFBOption(fbcfg.FB_FILTER_OPT,
                                    fbcfg.FB_DEFAULT_FILTERS)
        isHidden = ebmlib.IsHidden
        rval = list()
        rAdd = rval.append
        getBase = os.path.basename
        for path in paths:
            if not showHidden and isHidden(path):
                continue
            name = getBase(path)
            if filter(lambda x: fnmatch.fnmatchcase(name, x), filters):
                continue
            rAdd(path)
        return rval