Ë
    Þš§j¶  ã                   ó,   — d dl Z ddlmZ  G d„ d«      Zy)é    Né   )ÚERROR_CLASSES_MAPc                   óF   — e Zd ZdZd	d„Zdedeeef   defd„Zdedefd„Zy)
ÚErrorClassesReaderz9A reader to load error information from error_classes.py.ÚreturnNc                 ó   — t         | _        y )N)r   Úerror_info_map)Úselfs    úiC:\Users\Luka\AppData\Local\Temp\pip-target-o84fipzb\lib\python\duckdb/experimental/spark/errors/utils.pyÚ__init__zErrorClassesReader.__init__   s
   € Ü/ˆÕó    Úerror_classÚmessage_parametersc                 ó  — | j                  |«      }t        j                  d|«      }t        |«      t        |«      k(  sJ d|› d|› �«       ‚t        j                  dd«      } |j                  |«      j                  di |¤ŽS )z[Returns the completed error message by applying message parameters to the message template.z<([a-zA-Z0-9_-]+)>z3Undefined error message parameter for error class: z. Parameters: z<>z{}© )Úget_message_templateÚreÚfindallÚsetÚstrÚ	maketransÚ	translateÚformat)r
   r   r   Úmessage_templateÚ message_parameters_from_templateÚtables         r   Úget_error_messagez$ErrorClassesReader.get_error_message   sŽ   € à×4Ñ4°[ÓAÐä+-¯:©:Ð6JÐL\Ó+]Ð(ÜÐ3Ó4¼Ð<NÓ8OÒOð 	
ØAÀ+ÀÈnÐ]oÐ\pÐqó	
ÐOô —‘˜d DÓ)ˆà7Ð×)Ñ)¨%Ó0×7Ñ7ÑMÐ:LÑMÐMr   c                 ór  — |j                  d«      }t        |«      }|dv sJ ‚|d   }|| j                  v r| j                  |   }nd|› d�}t        |«      ‚dj	                  |d   «      }|dk(  }|s|}	|	S |d	   }
|d
   }|
|v r||
   }nd|
› d�}t        |«      ‚dj	                  |d   «      }|dz   |z   }	|	S )a–  Returns the message template for corresponding error class from error_classes.py.

        For example,
        when given `error_class` is "EXAMPLE_ERROR_CLASS",
        and corresponding error class in error_classes.py looks like the below:

        .. code-block:: python

            "EXAMPLE_ERROR_CLASS" : {
              "message" : [
                "Problem <A> because of <B>."
              ]
            }

        In this case, this function returns:
        "Problem <A> because of <B>."

        For sub error class, when given `error_class` is "EXAMPLE_ERROR_CLASS.SUB_ERROR_CLASS",
        and corresponding error class in error_classes.py looks like the below:

        .. code-block:: python

            "EXAMPLE_ERROR_CLASS" : {
              "message" : [
                "Problem <A> because of <B>."
              ],
              "sub_class" : {
                "SUB_ERROR_CLASS" : {
                  "message" : [
                    "Do <C> to fix the problem."
                  ]
                }
              }
            }

        In this case, this function returns:
        "Problem <A> because <B>. Do <C> to fix the problem."
        Ú.)r   é   r   zCannot find main error class 'Ú'Ú
Úmessager    r   Ú	sub_classzCannot find sub error class 'Ú )ÚsplitÚlenr	   Ú
ValueErrorÚjoin)r
   r   Úerror_classesÚlen_error_classesÚmain_error_classÚmain_error_class_info_mapÚmsgÚmain_message_templateÚhas_sub_classr   Úsub_error_classÚ"main_error_class_subclass_info_mapÚsub_error_class_info_mapÚsub_message_templates                 r   r   z'ErrorClassesReader.get_message_template)   s  € ðN $×)Ñ)¨#Ó.ˆÜ Ó.ÐØ  FÑ*Ð*Ð*ð )¨Ñ+ÐØ˜t×2Ñ2Ñ2Ø(,×(;Ñ(;Ð<LÑ(MÑ%à2Ð3CÐ2DÀAÐFˆCÜ˜S“/Ð!à $§	¡	Ð*CÀIÑ*NÓ OÐà)¨QÑ.ˆáØ4Ðð  Ðð ,¨AÑ.ˆOØ1JÈ;Ñ1WÐ.ØÐ"DÑDØ+MÈoÑ+^Ñ(à5°oÐ5FÀaÐH�Ü  “oÐ%à#'§9¡9Ð-EÀiÑ-PÓ#QÐ Ø4°sÑ:Ð=QÑQÐàÐr   )r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Údictr   r   r   r   r   r   r      sH   „ ÙCó0ð
N¨Sð 
NÀdÈ3ÐPSÈ8Ánð 
NÐY\ó 
NðF °ð F ¸ô F r   r   )r   r*   r   r   r   r   r   Ú<module>r:      s   ðó$ 
å ,÷X ò X r   