(self, o)
| 1335 | |
| 1336 | class 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 | |
| 1358 | def basic_json_data(manifest, *, cache=None, extra=None): |
no test coverage detected