MCPcopy
hub / github.com/MinishLab/semble / _run_clear

Function _run_clear

src/semble/cli.py:137–163  ·  view source on GitHub ↗

Run the `clear` subcommand.

(clear_type: _CLEAR_CHOICE)

Source from the content-addressed store, hash-verified

135
136
137def _run_clear(clear_type: _CLEAR_CHOICE) -> None:
138 """Run the `clear` subcommand."""
139 cache_folder = resolve_cache_folder()
140 if clear_type == "index" or clear_type == "all":
141 indexes = []
142 for path in cache_folder.glob("*/index"):
143 if not _SHA_256_REGEX.match(path.parent.name):
144 continue
145 if PersistencePath.from_path(path).non_existing():
146 continue
147 indexes.append(path)
148
149 if not indexes:
150 print(f"No indexes found to clear in `{cache_folder}`")
151 else:
152 for path in indexes:
153 index_folder = path.parent
154 rmtree(index_folder)
155 print(f"Cleared index at `{index_folder}`")
156
157 if clear_type == "savings" or clear_type == "all":
158 path = cache_folder / "savings.jsonl"
159 if not path.exists():
160 print(f"No savings file found at `{path}`")
161 else:
162 path.unlink()
163 print(f"Cleared savings at `{path}`")
164
165
166def _cli_main() -> None:

Callers 4

test_run_clear_indexFunction · 0.90
test_run_clear_savingsFunction · 0.90
test_run_clear_allFunction · 0.90
_cli_mainFunction · 0.85

Calls 3

resolve_cache_folderFunction · 0.90
non_existingMethod · 0.80
from_pathMethod · 0.45

Tested by 3

test_run_clear_indexFunction · 0.72
test_run_clear_savingsFunction · 0.72
test_run_clear_allFunction · 0.72