MCPcopy
hub / github.com/borgbackup/borg / BorgJsonEncoder

Class BorgJsonEncoder

src/borg/helpers/parseformat.py:1336–1355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1334
1335
1336class BorgJsonEncoder(json.JSONEncoder):
1337 def default(self, o):
1338 from ..legacyrepository import LegacyRepository
1339 from ..repository import Repository
1340 from ..legacyremote import LegacyRemoteRepository
1341 from ..remote import RemoteRepository
1342 from ..archive import Archive
1343 from ..cache import AdHocWithFilesCache
1344
1345 if isinstance(o, (LegacyRepository, LegacyRemoteRepository)) or isinstance(o, (Repository, RemoteRepository)):
1346 return {"id": bin_to_hex(o.id), "location": o._location.canonical_path()}
1347 if isinstance(o, Archive):
1348 return o.info()
1349 if isinstance(o, (AdHocWithFilesCache,)):
1350 return {"path": o.path}
1351 if isinstance(o, Path):
1352 return str(o)
1353 if callable(getattr(o, "to_json", None)):
1354 return o.to_json()
1355 return super().default(o)
1356
1357
1358def basic_json_data(manifest, *, cache=None, extra=None):

Callers 1

basic_json_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected