示例#1
0
 def __init__(self, action_element, path_vars=None):
     """Initialize file search"""
     ActionProvider.__init__(self, action_element, path_vars)
     self.regex = action_element.getAttribute('regex')
     assert (isinstance(self.regex, (str, type(None))))
     self.nregex = action_element.getAttribute('nregex')
     assert (isinstance(self.nregex, (str, type(None))))
     self.wholeregex = action_element.getAttribute('wholeregex')
     assert (isinstance(self.wholeregex, (str, type(None))))
     self.nwholeregex = action_element.getAttribute('nwholeregex')
     assert (isinstance(self.nwholeregex, (str, type(None))))
     self.search = action_element.getAttribute('search')
     self.object_type = action_element.getAttribute('type')
     self._set_paths(action_element.getAttribute('path'), path_vars)
     self.ds = None
     if 'deep' == self.search:
         self.ds = (self.paths[0],
                    DeepScan.Search(
                        command=action_element.getAttribute('command'),
                        regex=self.regex,
                        nregex=self.nregex,
                        wholeregex=self.wholeregex,
                        nwholeregex=self.nwholeregex))
         if not len(self.paths) == 1:
             logger.warning(
                 # TRANSLATORS: Multi-value variables are explained in the online documentation.
                 # Basically, they are like an environment variable, but each multi-value variable
                 # can have multiple values. They're a way to make CleanerML files more concise.
                 _("Deep scan does not support multi-value variable."))
     if not any([
             self.object_type, self.regex, self.nregex, self.wholeregex,
             self.nwholeregex
     ]):
         # If the filter is not needed, bypass it for speed.
         self.get_paths = self._get_paths
示例#2
0
文件: Worker.py 项目: rados/bleachbit
    def run_deep_scan(self):
        """Run deep scans"""
        logger.debug(' deepscans=%s' % self.deepscans)
        # TRANSLATORS: The "deep scan" feature searches over broad
        # areas of the file system such as the user's whole home directory
        # or all the system executables.
        self.ui.update_progress_bar(_("Please wait.  Running deep scan."))
        yield True  # allow GTK to update the screen
        ds = DeepScan.DeepScan(self.deepscans)

        for cmd in ds.scan():
            if True == cmd:
                yield True
                continue
            for ret in self.execute(cmd, 'deepscan'):
                yield True
示例#3
0
    def run_deep_scan(self):
        """Run deep scans"""
        logger.debug(' deepscans=%s' % self.deepscans)
        # TRANSLATORS: The "deep scan" feature searches over broad
        # areas of the file system such as the user's whole home directory
        # or all the system executables.
        self.ui.update_progress_bar(_("Please wait.  Running deep scan."))
        yield True  # allow GTK to update the screen
        ds = DeepScan.DeepScan()
        for (path, dsdict) in self.deepscans.items():
            logger.debug('deepscan path=%s, dict=%s' % (path, dsdict))
            for dsdict2 in dsdict:
                ds.add_search(path, dsdict2['regex'])

        for path in ds.scan():
            if True == path:
                yield True
                continue
            # fixme: support non-delete commands
            from bleachbit import Command
            cmd = Command.Delete(path)
            for ret in self.execute(cmd, 'deepscan'):
                yield True