
    wi                        d dl Z d dlmZmZmZ d dlmZ d dlmZ d dl	m
Z
  e j        d          Z G d de          Z G d	 d
e          Z G d de          ZdedefdZdedefdZdededededeeef         f
dZdS )    N)AnyDictTuple)	highlight)Python3TracebackLexer)TerminalFormatterz%\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])c                       e Zd ZdZdS )
StopWorkerz! Exception used to kill a worker N__name__
__module____qualname____doc__     g/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/mpire/exception.pyr
   r
      s        ++Dr   r
   c                       e Zd ZdZdS )InterruptWorkerz& Exception used to interrupt a worker Nr   r   r   r   r   r      s        00Dr   r   c                       e Zd ZdZdS )CannotPickleExceptionErrorzF Exception used when Pickle has trouble pickling the actual Exception Nr   r   r   r   r   r      s        PPDr   r   traceback_strreturnc                 T    t          | t                      t                                S )z
    Highlight a traceback string in a terminal-friendly way

    :param traceback_str: The traceback string to highlight
    :return: The highlighted traceback string
    )r   r   r   r   s    r   highlight_tracebackr      s$     ]$9$;$;=N=P=PQQQr   c                 8    t                               d|           S )z
    Remove the highlighting from a traceback string

    Taken from https://stackoverflow.com/a/14693789/4486236.

    :param traceback_str: The traceback string to remove the highlighting from
    :return: The traceback string without highlighting
     )ANSI_ESCAPEsubr   s    r   remove_highlightingr    $   s     ??2}---r   err_typeerr_args	err_statec                     |                      |           }||_        |j                            |           t	          t          |                    }||fS )aN  
    Populate an exception with the given arguments

    :param err_type: The type of the exception
    :param err_args: The arguments of the exception
    :param err_state: The state of the exception
    :param traceback_str: The traceback string of the exception
    :return: A tuple of the exception and the original exception
    )__new__args__dict__update	Exceptionr   )r!   r"   r#   r   errtraceback_errs         r   populate_exceptionr,   0   sU     

8
$
$CCHL	"""1-@@AAMr   )retypingr   r   r   pygmentsr   pygments.lexersr   pygments.formattersr   compiler   r)   r
   r   r   strr   r    typer,   r   r   r   <module>r5      s   				 # # # # # # # # # #       1 1 1 1 1 1 1 1 1 1 1 1bjABB	 	 	 	 	 	 	 	
	 	 	 	 	i 	 	 	
	 	 	 	 	 	 	 	
Rs Rs R R R R	.s 	.s 	. 	. 	. 	.   &).3Iy4H.I     r   