Encode a cache entry value for inclusion in the JSON diff. Fixed format binary entries are base64-encoded, JSON entries are re-serialized as JSON strings.
(s: str, obj: object)
| 141 | |
| 142 | |
| 143 | def encode_for_diff(s: str, obj: object) -> str: |
| 144 | """Encode a cache entry value for inclusion in the JSON diff. |
| 145 | |
| 146 | Fixed format binary entries are base64-encoded, JSON entries are |
| 147 | re-serialized as JSON strings. |
| 148 | """ |
| 149 | if isinstance(obj, bytes): |
| 150 | return base64.b64encode(obj).decode() |
| 151 | return json_dumps(obj).decode() |
| 152 | |
| 153 | |
| 154 | def main() -> None: |
no test coverage detected
searching dependent graphs…