
    8Cf                     <   d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZ d dlmZ ej$                  dk  reeef   Znd d	l	mZ eeed
   ed   ed   f   Zej,                  dk(  Z ej0                         dk(  ZdZ	 d dlZdZej$                  dk  r G d dee      Znd dlmZ  G d de      Zedefd       Zd Z d&dZ!d&dZ" G d de      Z#ejH                  d    jK                  d      xr d ejH                  v Z&e&rEd dl'Z'de
ejP                     fd!Z)e'jT                  Z+ e,e jZ                  e'j\                  g      Z/d% Z5yer e!        er e"        d d"l0m1Z2 d d#l3m4Z) d'd$Z+ e,e jZ                  g      Z/d% Z5y# e$ r Y w xY w)(    N)contextmanager)Enum)	AwaitableUnion)CIMultiDict)Default)error_logger)      )Literalfork
forkserverspawnntPyPyFT)r
      r   c                       e Zd Zy)StrEnumN)__name__
__module____qualname__     L/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/sanic/compat.pyr   r   (   s    r   r   )r   c                   J     e Zd ZdZd Zdedef fdZdefdZ	de
fdZ xZS )UpperStrEnumz6Base class for string enums that are case insensitive.c                 "    | j                         S N)upper)namestartcountlast_valuess       r   _generate_next_value_z"UpperStrEnum._generate_next_value_2   s    zz|r   valuereturnc                 T    t        |      j                         }t        |   |      S r   )strr   super__eq__)selfr%   	__class__s     r   r*   zUpperStrEnum.__eq__5   s$    E
  "w~e$$r   c                 ,    t        | j                        S r   )hashr%   r+   s    r   __hash__zUpperStrEnum.__hash__9   s    DJJr   c                     | j                   S r   )r%   r/   s    r   __str__zUpperStrEnum.__str__<   s    zzr   )r   r   r   __doc__r$   objectboolr*   intr0   r(   r2   __classcell__)r,   s   @r   r   r   /   s6    @%F %t % #   r   r   methodc              #   T   K   ddl m} |j                  }| |_        d  ||_        y w)Nr   )Sanic)sanicr:   start_method)r8   r:   origs      r   use_contextr>   @   s'     DE	Es   &(c                  z    dd l } | j                  j                  }|j                  |j	                  d      d       y )Nr   i   )ctypeswindllkernel32SetConsoleModeGetStdHandle)rA   kernels     r   enable_windows_color_supportrG   J   s/    ]]##F
&--c2A6r   r&   c                      t        t        d      rt        j                  d       yt        j
                  d   } t        j                  j                  | _        y)z
    The PyPy os module is missing the 'readlink' function, which causes issues
    withaiofiles. This workaround replaces the missing 'readlink' function
    with 'os.path.realpath', which serves the same purpose.
    readlinkz^PyPy: Skipping patching of the os module as it appears the 'readlink' function has been added.Nos)	hasattrrJ   r	   warningsysmodulespathrealpathrI   )modules    r   pypy_os_module_patchrR   Q   sE     r:2	
 	[[Fgg&&FOr   c                      ddl m}  | j                  j                         }|dk7  r7| j                  j	                  d       | j                  j                  d       yy)a  
    A patch function for PyPy on Windows that sets the console code page to
    UTF-8 encodingto allow for proper handling of non-ASCII characters. This
    function uses ctypes to call the Windows API functions SetConsoleCP and
    SetConsoleOutputCP to set the code page.
    r   )rB   i  N)rA   rB   rC   GetConsoleOutputCPSetConsoleCPSetConsoleOutputCP)rB   codes     r   !pypy_windows_set_console_cp_patchrX   b   sI     224Du}$$U+**51 r   c                   ,    e Zd ZdZdedefdZdefdZy)Headera  Container used for both request and response headers.
    It is a subclass of  [CIMultiDict](https://multidict.readthedocs.io/en/stable/multidict.html#cimultidictproxy)

    It allows for multiple values for a single key in keeping with the HTTP
    spec. Also, all keys are *case in-sensitive*.

    Please checkout [the MultiDict documentation](https://multidict.readthedocs.io/en/stable/multidict.html#multidict)
    for more details about how to use the object. In general, it should work
    very similar to a regular dictionary.
    keyr&   c                     |j                  d      r| j                  |      S |j                  d      j                  dd      }dj	                  | j                  |g             S )N_-,)
startswith__getattribute__rstripreplacejoingetallr+   r[   s     r   __getattr__zHeader.__getattr__}   sS    >>#((--jjo%%c3/xxC,--r   c                 &    | j                  |g       S )z*Convenience method mapped to ``getall()``.)re   rf   s     r   get_allzHeader.get_all   s    {{3##r   N)r   r   r   r3   r(   rg   ri   r   r   r   rZ   rZ   q   s&    	.s .s .$3 $r   rZ   	hypercorntrioc                 H    t        j                  |       j                         S r   )rk   Pathstat)rO   s    r   
stat_asyncro      s    yy##%%r   )open)rn   c                 $   K   t        | |fi |S wr   )aio_open)filemodekwargss      r   
open_asyncrv      s     d-f--s   c                     fd}fd}dt        j                   t         j                  |       | j                  |       y )Nc                    K   s7| j                   j                  ryt        j                  d       d{    s7| j	                          y7 w)z3Asyncio wakeups to allow receiving SIGINT in PythonNg?)stateis_stoppingasynciosleepstop)appdies    r   stay_activez1ctrlc_workaround_for_windows.<locals>.stay_active   sC     yy$$ --$$$  	
 %s   2AAAAc                 $    rt        d      dy )NzNon-graceful Ctrl+CT)KeyboardInterrupt)sigframer   s     r   ctrlc_handlerz3ctrlc_workaround_for_windows.<locals>.ctrlc_handler   s    #$9::r   F)signalSIGINTadd_task)r~   r   r   r   s      @r   ctrlc_workaround_for_windowsr      s2    
 C
MM&--/LLr   )r&   N)r)6r{   rJ   platformr   rM   
contextlibr   enumr   typingr   r   	multidictr   sanic.helpersr   	sanic.logr	   version_infor(   StartMethodr   r    OS_IS_WINDOWSpython_implementationPYPY_IMPLEMENTATIONUVLOOP_INSTALLEDuvloopImportErrorr   r   r>   rG   rR   rX   rZ   argvendswithuse_triork   stat_resultro   	open_filerv   tupleCancelledError	CancelledCancelledErrorsaiofilesrp   rr   aiofiles.osrn   r   r   r   r   <module>r      s    	   
 %  # ! ! " f%K',"79IIK 44h446&@  	
 j #t  7 "   7'"2$[ $. 88A;,C3881C&Ibnn5 & JW33T^^DEO" -/).. W3345OA  		s   F FF