� c��j� � � � d Z ddlZddlZ ddl� g d�ZdZdxZ Z dxZZd Z d Zej dk( re xZZe ZnexZZeZe ZeZe ZeZ G d� d e� Z G d� d� Z G d� de� Z G d� de� Z G d� de� Z G d� de� Z G d� de� Z G d� de� Z G d� d� Z! G d� d� Z"d2d!�Z#d3d"�Z$d#� Z%d$� Z&d%� Z'd&� Z(d'� Z)d(� Z*d4d)�Z+d4d*�Z,d+� Z-d,� Z. e/d � Z0 e/d-� Z1 e/d.� Z2 e/d/� Z3 e/d0� Z4 e/d1� Z5dZ7e7rddl8Z8yy# e$ rZ edez � �dZ[ww xY w# e6$ r dZ0dZ1dZ2dZ3dZ4dZ5Y �5w xY w)5z� codecs -- Python Codec Registry, API and helpers. Written by Marc-Andre Lemburg ([email protected]). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. � N)�*z%Failed to load the builtin codecs: %s),�register�lookup�open�EncodedFile�BOM�BOM_BE�BOM_LE�BOM32_BE�BOM32_LE�BOM64_BE�BOM64_LE�BOM_UTF8� BOM_UTF16�BOM_UTF16_LE�BOM_UTF16_BE� BOM_UTF32�BOM_UTF32_LE�BOM_UTF32_BE� CodecInfo�Codec�IncrementalEncoder�IncrementalDecoder�StreamReader�StreamWriter�StreamReaderWriter� StreamRecoder� getencoder� getdecoder�getincrementalencoder�getincrementaldecoder� getreader� getwriter�encode�decode� iterencode� iterdecode� strict_errors� ignore_errors�replace_errors�xmlcharrefreplace_errors�backslashreplace_errors�namereplace_errors�register_error�lookup_errors s ��s ��s �� s ���littlec �, � e Zd ZdZdZ ddd�d�Zd� Zy)r z0Codec details when looking up the codec registryTN)�_is_text_encodingc � � t j | ||||f� } || _ || _ || _ || _ || _ || _ || _ |�|| _ | S �N) �tuple�__new__�namer$ r% �incrementalencoder�incrementaldecoder�streamwriter�streamreaderr2 ) �clsr$ r% r; r: r8 r9 r7 r2 �selfs �/usr/lib64/python3.12/codecs.pyr6 zCodecInfo.__new__^ se � � �}�}�S�6�6�<��"N�O���� �������"4���"4���(���(����(�%6�D�"��� c � � d| j j | j j | j t | � fz S )Nz%<%s.%s object for encoding %s at %#x>)� __class__� __module__�__qualname__r7 �id�r= s r> �__repr__zCodecInfo.__repr__m s: � �6����*�*�D�N�N�,G�,G����B�t�H�&�&� &r? )NNNNN)�__name__rB rC �__doc__r2 r6 rF � r? r> r r S s% � �:� ��EI�?C� �!� �&r? r c � � e Zd ZdZdd�Zdd�Zy)r a9 Defines the interface for stateless encoders/decoders. The .encode()/.decode() methods may use different error handling schemes by providing the errors argument. These string values are predefined: 'strict' - raise a ValueError error (or a subclass) 'ignore' - ignore the character and continue with the next 'replace' - replace with a suitable replacement character; Python will use the official U+FFFD REPLACEMENT CHARACTER for the builtin Unicode codecs on decoding and '?' on encoding. 'surrogateescape' - replace with private code points U+DCnn. 'xmlcharrefreplace' - Replace with the appropriate XML character reference (only for encoding). 'backslashreplace' - Replace with backslashed escape sequences. 'namereplace' - Replace with \N{...} escape sequences (only for encoding). The set of allowed values can be extended via register_error. c � � t �)a# Encodes the object input and returns a tuple (output object, length consumed). errors defines the error handling to apply. It defaults to 'strict' handling. The method may not store state in the Codec instance. Use StreamWriter for codecs which have to keep state in order to make encoding efficient. The encoder must be able to handle zero length input and return an empty object of the output object type in this situation. ��NotImplementedError�r= �input�errorss r> r$ zCodec.encode� s � �" "�!r? c � � t �)a� Decodes the object input and returns a tuple (output object, length consumed). input must be an object which provides the bf_getreadbuf buffer slot. Python strings, buffer objects and memory mapped files are examples of objects providing this slot. errors defines the error handling to apply. It defaults to 'strict' handling. The method may not store state in the Codec instance. Use StreamReader for codecs which have to keep state in order to make decoding efficient. The decoder must be able to handle zero length input and return an empty object of the output object type in this situation. rL rN s r> r% zCodec.decode� s � �* "�!r? N��strict)rG rB rC rH r$ r% rI r? r> r r r s � ��,"�&"r? r c �2 � e Zd ZdZdd�Zd d�Zd� Zd� Zd� Zy) r z� An IncrementalEncoder encodes an input in multiple steps. The input can be passed piece by piece to the encode() method. The IncrementalEncoder remembers the state of the encoding process between calls to encode(). c � � || _ d| _ y)z� Creates an IncrementalEncoder instance. The IncrementalEncoder may use different error handling schemes by providing the errors keyword argument. See the module docstring for a list of possible values. � N)rP �buffer�r= rP s r> �__init__zIncrementalEncoder.__init__� s � � �����r? c � � t �)zA Encodes input and returns the resulting object. rL �r= rO �finals r> r$ zIncrementalEncoder.encode� � � � "�!r? c � � y)z: Resets the encoder to the initial state. NrI rE s r> �resetzIncrementalEncoder.reset� � � r? c � � y)z: Return the current state of the encoder. r rI rE s r> �getstatezIncrementalEncoder.getstate� s � � r? c � � y)zl Set the current state of the encoder. state must have been returned by getstate(). NrI �r= �states r> �setstatezIncrementalEncoder.setstate� r` r? NrR �F) rG rB rC rH rY r$ r_ rb rf rI r? r> r r � s � �� �"�� �r? r c �8 � e Zd ZdZd d�Zd� Zd d�Zd� Zd� Zd� Z y)�BufferedIncrementalEncoderz� This subclass of IncrementalEncoder can be used as the baseclass for an incremental encoder if the encoder must keep some of the output in a buffer between calls to encode(). c �> � t j | |� d| _ y �NrV )r rY rW rX s r> rY z#BufferedIncrementalEncoder.__init__� s � ��#�#�D�&�1���r? c � � t �r4 rL �r= rO rP r\ s r> �_buffer_encodez)BufferedIncrementalEncoder._buffer_encode� � � � "�!r? c �x � | j |z }| j || j |� \ }}||d | _ |S r4 )rW rn rP �r= rO r\ �data�result�consumeds r> r$ z!BufferedIncrementalEncoder.encode� �? � ��{�{�U�"��!�0�0��t�{�{�E�J�����8�9�o���� r? c �<