MCPcopy
hub / github.com/ruc-datalab/DeepAnalyze / diff_and_collect

Method diff_and_collect

example/4c_competition/utils.py:320–360  ·  view source on GitHub ↗

Compute added/modified files, copy into generated/, and return artifact paths.

(self)

Source from the content-addressed store, hash-verified

318 return {}
319
320 def diff_and_collect(self) -> List[Path]:
321 """Compute added/modified files, copy into generated/, and return artifact paths."""
322 try:
323 after_state = {
324 p.resolve(): (p.stat().st_size, p.stat().st_mtime_ns)
325 for p in self.workspace_dir.rglob("*")
326 if p.is_file()
327 }
328 except Exception:
329 after_state = {}
330
331 added = [p for p in after_state.keys() if p not in self.before_state]
332 modified = [
333 p for p in after_state.keys()
334 if p in self.before_state and after_state[p] != self.before_state[p]
335 ]
336
337 artifact_paths: List[Path] = []
338 for p in added:
339 try:
340 if not str(p).startswith(str(self.generated_dir)):
341 dest = self.generated_dir / p.name
342 dest = uniquify_path(dest)
343 shutil.copy2(str(p), str(dest))
344 artifact_paths.append(dest.resolve())
345 else:
346 artifact_paths.append(p)
347 except Exception as e:
348 print(f"Error moving file {p}: {e}")
349
350 for p in modified:
351 try:
352 dest = self.generated_dir / f"{p.stem}_modified{p.suffix}"
353 dest = uniquify_path(dest)
354 shutil.copy2(str(p), str(dest))
355 artifact_paths.append(dest.resolve())
356 except Exception as e:
357 print(f"Error copying modified file {p}: {e}")
358
359 self.before_state = after_state
360 return artifact_paths
361
362
363def generate_report_from_messages(

Callers 2

chat_completionsFunction · 0.95

Calls 2

uniquify_pathFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected