MCPcopy Create free account
hub / github.com/idank/explainshell / apply_decisions

Function apply_decisions

explainshell/extraction/prefilter.py:205–264  ·  view source on GitHub ↗

Apply DB cleanup and per-file logging; bucket decisions for the caller.

(
    decisions: list[Decision],
    s: store.Store,
    *,
    filter_db: tuple[str, ...] = (),
)

Source from the content-addressed store, hash-verified

203
204
205def apply_decisions(
206 decisions: list[Decision],
207 s: store.Store,
208 *,
209 filter_db: tuple[str, ...] = (),
210) -> Classified:
211 """Apply DB cleanup and per-file logging; bucket decisions for the caller."""
212 out = Classified()
213 for d in decisions:
214 if isinstance(d, Work):
215 out.work_files.append(d.gz_path)
216 elif isinstance(d, SizeSkip):
217 cmp = ">" if d.direction == "max" else "<="
218 logger.debug(
219 "size-filter skip %s (%d %s %d)",
220 d.short_path,
221 d.size,
222 cmp,
223 d.threshold,
224 )
225 out.size_filtered += 1
226 out.prefilter_skipped += 1
227 elif isinstance(d, AlreadyStored):
228 logger.debug("skipping %s (already stored)", d.short_path)
229 out.already_stored += 1
230 out.prefilter_skipped += 1
231 elif isinstance(d, FilterSkip):
232 logger.debug(
233 "filter-skip %s (stored=%s/%s, filter=%s)",
234 d.short_path,
235 d.stored_extractor,
236 d.stored_model,
237 ", ".join(filter_db),
238 )
239 out.prefilter_skipped += 1
240 elif isinstance(d, Symlink):
241 if d.stale_in_db:
242 # CASCADE removes orphan mappings.
243 s.delete_manpage(d.short_path)
244 logger.info(
245 "removed stale manpage %s (now a symlink to %s)",
246 d.short_path,
247 d.canonical_source,
248 )
249 if d.canonical_in_inputs:
250 logger.info(
251 "skipping symlink %s -> %s (canonical file is in the input set)",
252 d.short_path,
253 d.canonical_source,
254 )
255 else:
256 logger.info(
257 "skipping symlink %s -> %s (pass the canonical file to extract it)",
258 d.short_path,
259 d.canonical_source,
260 )
261 out.symlinks.append((d.gz_path, d.short_path, d.canonical_source))
262 elif isinstance(d, ContentDup):

Calls 2

ClassifiedClass · 0.85
delete_manpageMethod · 0.45