27 lines
872 B
Python
27 lines
872 B
Python
import json
|
|
import sys
|
|
|
|
from loop_claude.claude_code.formats import mark_trusted, trust_records
|
|
from loop_claude.file_writes import replace_json
|
|
from loop_claude.outcome import Failure
|
|
|
|
|
|
def trust(config, roots):
|
|
try:
|
|
with open(config, encoding="utf-8") as handle:
|
|
data = json.load(handle)
|
|
except (OSError, ValueError) as failure:
|
|
print(f"could not read {config}: {getattr(failure, 'strerror', failure)}", file=sys.stderr)
|
|
return
|
|
projects = trust_records(data)
|
|
if isinstance(projects, Failure):
|
|
print(f"could not read {config}: {projects.reason}", file=sys.stderr)
|
|
return
|
|
untrusted = mark_trusted(projects, roots)
|
|
if not untrusted:
|
|
return
|
|
if failure := replace_json(config, data, indent=2):
|
|
print(f"could not write {config}: {failure.reason}", file=sys.stderr)
|
|
return
|
|
print("trusted for the interrupt: " + ", ".join(untrusted), file=sys.stderr)
|