This repository provides User Manual for setting up a Docker environment tailored for testing DGTD code.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

33 lines
842 B

"""JSON serializer implementation wrapper."""
from __future__ import annotations
import json
from collections import UserString
from typing import Any, IO
class SphinxJSONEncoder(json.JSONEncoder):
"""JSONEncoder subclass that forces translation proxies."""
def default(self, obj: Any) -> str:
if isinstance(obj, UserString):
return str(obj)
return super().default(obj)
def dump(obj: Any, fp: IO, *args: Any, **kwds: Any) -> None:
kwds['cls'] = SphinxJSONEncoder
json.dump(obj, fp, *args, **kwds)
def dumps(obj: Any, *args: Any, **kwds: Any) -> str:
kwds['cls'] = SphinxJSONEncoder
return json.dumps(obj, *args, **kwds)
def load(*args: Any, **kwds: Any) -> Any:
return json.load(*args, **kwds)
def loads(*args: Any, **kwds: Any) -> Any:
return json.loads(*args, **kwds)