Perform requested searches and yield each match
(self)
| 101 | self.searches = searches |
| 102 | |
| 103 | def scan(self): |
| 104 | """Perform requested searches and yield each match""" |
| 105 | logging.getLogger(__name__).debug( |
| 106 | 'DeepScan.scan: searches=%s', str(self.searches)) |
| 107 | yield_time = time.time() |
| 108 | |
| 109 | for (top, searches) in self.searches.items(): |
| 110 | compiled_searches = [CompiledSearch(s) for s in searches] |
| 111 | for (dirpath, _dirnames, filenames) in normalized_walk(top): |
| 112 | for c in compiled_searches: |
| 113 | # fixme, don't match filename twice |
| 114 | for filename in filenames: |
| 115 | full_name = c.match(dirpath, filename) |
| 116 | if full_name is not None: |
| 117 | # fixme: support other commands |
| 118 | if c.command == 'delete': |
| 119 | yield Command.Delete(full_name) |
| 120 | elif c.command == 'shred': |
| 121 | yield Command.Shred(full_name) |
| 122 | |
| 123 | if time.time() - yield_time > 0.25: |
| 124 | # allow GTK+ to process the idle loop |
| 125 | yield True |
| 126 | yield_time = time.time() |