project_config.serializers package

Object serializers.

exception project_config.serializers.SerializerError(message: str)[source]

Bases: ProjectConfigException

Error happened serializing content as JSON.

project_config.serializers._file_can_not_be_serialized_as_object_error(url: str, error_message: str) str[source]
project_config.serializers._get_serializer_function(url: str, prefer_serializer: str | None = None, loader_function_name: str = 'loads') SerializerFunction[source]
project_config.serializers._identify_serializer(filename: str) str[source]
project_config.serializers.deserialize_for_url(url: str, content: Any, prefer_serializer: Optional[str] = None) Any[source]

Deserialize content for URL.

Parameters:
  • url (str) – URL to deserialize content for.

  • content (Any) – Content to deserialize.

  • prefer_serializer (str) – Preferred serializer.

Returns:

Deserialized content.

Return type:

str

project_config.serializers.guess_preferred_serializer(url: str) tuple[str, str][source]

Guess preferred serializer for URL.

Parameters:

url (str) – URL to guess serializer for.

Returns:

Filename and serializer.

Return type:

tuple

project_config.serializers.guess_serializer_for_path(path: str) tuple[Any, Any][source]

Guess serializer for a path.

Parameters:

path (str) – Path to guess serializer for.

project_config.serializers.serialize_for_url(url: str, string: str, prefer_serializer: Optional[str] = None) Any[source]

Serializes to JSON a string according to the given URI.

Parameters:
  • url (str) – URI of the file, used to detect the type of the file, either using the extension or through identify.

  • string (str) – File content to serialize.

  • prefer_serializer (str) – Preferred serializer.

Returns:

Result of the object serialization.

Return type:

dict

Subpackages

Submodules