project_config.serializers.python module

Object serializing for Python scripts namespaces.

project_config.serializers.python._pyobject_to_string(value: Any) str[source]
project_config.serializers.python.dumps(obj: Any) str[source]

Converts a namespace to a Python script.

Parameters:

obj (dict) – Namespace to convert.

Returns:

Python script.

Return type:

str

project_config.serializers.python.loads(string: str, namespace: Namespace = {}) Namespace[source]

Execute a Python file and exposes their namespace as a dictionary.

The logic is based in Sphinx’s configuration file loader: https://github.com/sphinx-doc/sphinx/blob/4d7558e9/sphinx/config.py#L332

Parameters:
  • string (str) – Python script.

  • namespace (dict) – Namespace to update.

Returns:

Global namespace of the Python script as an object.

Return type:

dict