MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / scan

Method scan

bleachbit/DeepScan.py:103–126  ·  view source on GitHub ↗

Perform requested searches and yield each match

(self)

Source from the content-addressed store, hash-verified

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()

Callers 3

_test_encodingMethod · 0.95
test_DeepScanMethod · 0.95
run_deep_scanMethod · 0.95

Calls 3

CompiledSearchClass · 0.85
normalized_walkFunction · 0.85
matchMethod · 0.80

Tested by 2

_test_encodingMethod · 0.76
test_DeepScanMethod · 0.76