nti.externalization.representation: Reading and writing objects to strings

External representation support.

The provided implementations of IExternalObjectIO live here. We provide and register two, one for JSON and one for YAML.

to_external_representation(obj, ext_format='json', name=NotGiven) → str[source]

Transforms (and returns) the obj into its external (string) representation.

Uses nti.externalization.to_external_object(), passing in the name.

Parameters:ext_format (str) – One of EXT_REPR_JSON or EXT_REPR_YAML, or the name of some other utility that implements IExternalObjectRepresenter
to_json_representation(obj)[source]

A convenience function that calls to_external_representation() with EXT_REPR_JSON.

WithRepr(default=<function _default_repr>)[source]

A class decorator factory to give a __repr__ to the object. Useful for persistent objects.

Parameters:default – A callable to be used for the default value.