o n¾nhWã@sPdZddlmZddlZdZddd d „Zdddd„Zdddd„Zdddd„Z dS)z,Functions for encoding and decoding strings.é)Ú annotationsNzutf-8ÚstrictÚvalueút.Optional[t.AnyStr]ÚerrorsÚstrÚreturnút.Optional[bytes]cCó|durdSt||ƒS)zgReturn the given value as bytes encoded using UTF-8 if not already bytes, or None if the value is None.N)Úto_bytes©rr©r úJ/usr/local/lib/python3.10/dist-packages/ansible_test/_internal/encoding.pyÚto_optional_bytes órút.Optional[str]cCr )zeReturn the given value as text decoded using UTF-8 if not already text, or None if the value is None.N)Úto_textr r r rÚto_optional_textrrút.AnyStrÚbytescCs4t|tƒr|St|tƒr| t|¡Stdt|ƒƒ‚)zIReturn the given value as bytes encoded using UTF-8 if not already bytes.úvalue is not bytes or text: %s)Ú isinstancerrÚencodeÚENCODINGÚ ExceptionÚtyper r r rr s   r cCs4t|tƒr | t|¡St|tƒr|Stdt|ƒƒ‚)zGReturn the given value as text decoded using UTF-8 if not already text.r)rrÚdecoderrrrr r r rrs   r)r)rrrrrr )rrrrrr)rrrrrr)rrrrrr) Ú__doc__Ú __future__rÚtypingÚtrrrr rr r r rÚs