
    ci                        U d dl mZ d dlZd dlZd dlmZ d dlmZ i Z	de
d<    G d de      Zej                   G d	 d
             ZddZy)    )annotationsN)ABCMeta)ConfigurationErrorzdict[str, StorageRegistry]SCHEMESc                  0     e Zd Z	 	 	 	 	 	 	 	 d fdZ xZS )StorageRegistryc                    |j                  dd       }t        | 	  | |||      }|r&t        |t              r|g}n|}|D ]  }|t
        |<    |S )NSTORAGE_SCHEME)getsuper__new__
isinstancestrr   )	mcsnamebasesdctstorage_schemeclsschemesscheme	__class__s	           Z/var/www/html/spbu.com/backend/venv/lib/python3.12/site-packages/limits/_storage_scheme.pyr   zStorageRegistry.__new__   s^     !148goc44.#.)*(!"% " 
    )r   r   r   ztuple[type, ...]r   zdict[str, str | list[str]]returnr   )__name__
__module____qualname__r   __classcell__)r   s   @r   r   r      s-    /6P	 r   r   c                  \    e Zd ZU ded<   ded<   ded<   ded<   ded<   d	ed
<   edd       Zy)StorageURIOptionsr   r   z
str | Noneusernamepasswordzlist[tuple[str, int]]	locationspathzdict[str, list[str]]queryc                    t        | j                  du xr9 | j                  du xr) | j                  xs | j                  xs | j
                         S )z
        whether this is just a scheme:// uri without any information
        that might be useful when constructing the actual storage
        instance
        N)boolr"   r#   r$   r%   r&   )selfs    r   emptyzStorageURIOptions.empty(   sQ     MMT! @%@^^>tyy>DJJ?
 	
r   N)r   r(   )r   r   r   __annotations__propertyr*    r   r   r!   r!      s7    K$$


 

r   r!   c           
        t         j                  j                  |       }|j                  j	                  d      dz   }g }	 |j                  |d  r|j                  |d  j                  d      D ]o  }t         j                  j                  d|j                                }|j                  |j                  }}||t        d|       |j                  ||f       q t        |j                  |j                  |j                  ||j                   t         j                  j#                  |j$                              S # t        $ r}t        d|        |d }~ww xY w)N@   ,zfake://z!Missing host or port in location zUnable to parse storage uri )urllibparseurlparsenetlocfindsplitstriphostnameportr   append
ValueErrorr!   r   r"   r#   r%   parse_qsr&   )	uriparsedsepr$   locsubr9   r:   errs	            r   parse_storage_urirD   6   s9   \\""3'F
--

S
!A
%CI	P==}}ST*005ll++gciik],CD!$sxx$#t|,/PQTPU-VWW  (D!12 6 fll+   P #?u!EFCOPs   BD? ?	EEE)r>   r   r   r!   )
__future__r   dataclassesurllib.parser2   abcr   limits.errorsr   r   r+   r   	dataclassr!   rD   r-   r   r   <module>rK      sO    "    ,&(	# (g & 
 
 
,r   