Ë
    3ýj  ã                  ó    — d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	 h d£Z
dd„Zdd„Zdd„Zdd	„Ze G d
„ d«      «       Ze	e	e	f	 	 	 	 	 	 	 dd„Zy)é    )Úannotations)Ú	dataclassÚfield)ÚListÚOptional)ÚSENTINEL>   ú(ú)ú[ú]ú{ú}c                óv   — | D ]4  }t        |«      dk  st        |«      dkD  s	|t        v sŒ(t        |› d�«      ‚ y)zÐEnsure value contains only printable ASCII without spaces or braces.

    This mirrors the constraints enforced by other Redis clients for values that
    will appear in CLIENT LIST / CLIENT INFO output.
    é!   é~   zG must not contain spaces, newlines, non-printable characters, or bracesN)ÚordÚ_BRACESÚ
ValueError)ÚvalueÚ
field_nameÚchs      úK/root/telegram-saas/.venv/lib/python3.12/site-packages/redis/driver_info.pyÚ_validate_no_invalid_charsr      sF   € ð ò ˆäˆr‹7�TŠ>œS ›W tš^¨r´Wª}ÜØ�,ÐeÐfóð ñó    c                ó^   — ddl }t        | d«       |j                  d| «      st        d«      ‚y)ao  Validate an upstream driver name.

    The name should look like a typical Python distribution or package name,
    following a simplified form of PEP 503 normalisation rules:

    * start with a lowercase ASCII letter
    * contain only lowercase letters, digits, hyphens and underscores

    Examples of valid names: ``"django-redis"``, ``"celery"``, ``"rq"``.
    r   NzDriver namez^[a-z][a-z0-9_-]*$zµUpstream driver name must use a Python package-style name: start with a lowercase letter and contain only lowercase letters, digits, hyphens, and underscores (e.g., 'django-redis').)Úrer   Úmatchr   )Únamer   s     r   Ú_validate_driver_namer      s8   € ó ä˜t ]Ô3Ø�8‰8Ð)¨4Ô0ÜðGó
ð 	
ð 1r   c                ó   — t        | d«       y )NzDriver version)r   )Úversions    r   Ú_validate_driver_versionr"   1   s   € Ü˜wÐ(8Õ9r   c                ó   — | › d|› �S )NÚ_v© )Údriver_nameÚdriver_versions     r   Ú_format_driver_entryr(   5   s   € Øˆ]˜"˜^Ð,Ð-Ð-r   c                  óˆ   — e Zd ZU dZeZded<   eZded<    ee	¬«      Z
ded<   d„ Zedd	„«       Z	 	 	 	 	 	 dd
„Zedd„«       Zy)Ú
DriverInfoa  Driver information used to build the CLIENT SETINFO LIB-NAME and LIB-VER values.

    This class consolidates all driver metadata (redis-py version and upstream drivers)
    into a single object that is propagated through connection pools and connections.

    The formatted name follows the pattern::

        name(driver1_vVersion1;driver2_vVersion2)

    Parameters
    ----------
    name : str, optional
        The base library name. If omitted, defaults to "redis-py". If None,
        LIB-NAME will not be sent.
    lib_version : str, optional
        The redis-py library version. If omitted, the version will be determined
        automatically from the installed package. If None, LIB-VER will not be sent.

    Examples
    --------
    >>> info = DriverInfo()
    >>> info.formatted_name
    'redis-py'

    >>> info = DriverInfo().add_upstream_driver("django-redis", "5.4.0")
    >>> info.formatted_name
    'redis-py(django-redis_v5.4.0)'

    >>> info = DriverInfo(lib_version="5.0.0")
    >>> info.lib_version
    '5.0.0'
    úOptional[str] | objectr   Úlib_version)Údefault_factoryú	List[str]Ú	_upstreamc                ó€   — | j                   t        u rd| _         | j                  t        u rddlm}  |«       | _        yy)z7Initialize default metadata if not explicitly provided.zredis-pyr   )Úget_lib_versionN)r   r   r,   Úredis.utilsr1   )Úselfr1   s     r   Ú__post_init__zDriverInfo.__post_init__`   s6   € à�9‰9œÑ Ø"ˆDŒIØ×ÑœxÑ'Ý3á.Ó0ˆDÕð (r   c                ó,   — t        | j                  «      S )zuReturn a copy of the upstream driver entries.

        Each entry is in the form ``"driver-name_vversion"``.
        )Úlistr/   )r3   s    r   Úupstream_driverszDriverInfo.upstream_driversi   s   € ô �D—N‘NÓ#Ð#r   c                ó¶   — |€t        d«      ‚|€t        d«      ‚t        |«       t        |«       t        ||«      }| j                  j                  d|«       | S )z”Add an upstream driver to this instance and return self.

        The most recently added driver appears first in :pyattr:`formatted_name`.
        zDriver name must not be NonezDriver version must not be Noner   )r   r   r"   r(   r/   Úinsert)r3   r&   r'   Úentrys       r   Úadd_upstream_driverzDriverInfo.add_upstream_driverr   s]   € ð ÐÜÐ;Ó<Ð<ØÐ!ÜÐ>Ó?Ð?ä˜kÔ*Ü  Ô0ä$ [°.ÓAˆà�‰×Ñ˜a Ô'Øˆr   c                óž   — | j                   }t        |t        «      r|sy| j                  s|S |› ddj	                  | j                  «      › d�S )z¹Return the base name with upstream drivers encoded, if any.

        With no upstream drivers, this is just :pyattr:`name`. Otherwise::

            name(driver1_vX;driver2_vY)
        Nr	   ú;r
   )r   Ú
isinstanceÚstrr/   Újoin)r3   r   s     r   Úformatted_namezDriverInfo.formatted_name‡   sI   € ð �y‰yˆÜ˜$¤Ô$©DØØ�~Š~ØˆKØ��q˜Ÿ™ $§.¡.Ó1Ð2°!Ð4Ð4r   N)Úreturnr.   )r&   r?   r'   r?   rB   z'DriverInfo')rB   zOptional[str])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r,   r   r6   r/   r4   Úpropertyr7   r;   rA   r%   r   r   r*   r*   9   sy   … ñðB $,€DÐ
 Ó+Ø*2€KÐ'Ó2Ù °Ô6€IˆyÓ6ò1ð ò$ó ð$ðØðØ03ðà	óð* ò5ó ñ5r   r*   c                ót   — | t         u r|€|€yt        ||¬«      S | �t        | t        «      r| S t        d«      ‚)a%  Resolve driver_info from parameters.

    If driver_info is provided, use it. Otherwise, create DriverInfo from
    lib_name and lib_version (using defaults only for sentinel values).

    Parameters
    ----------
    driver_info : DriverInfo, optional
        The DriverInfo instance to use
    lib_name : str, optional
        The library name (default: "redis-py")
    lib_version : str, optional
        The library version (default: auto-detected)

    Returns
    -------
    DriverInfo, optional
        The resolved DriverInfo instance
    N)r   r,   z1driver_info must be a DriverInfo instance or None)r   r*   r>   Ú	TypeError)Údriver_infoÚlib_namer,   s      r   Úresolve_driver_inforM   ˜   sH   € ð0 ”hÑØÐ Ð 3ØÜ˜x°[ÔAÐAàÐœj¨´jÔAØÐä
ÐGÓ
HÐHr   N)r   r?   r   r?   rB   ÚNone)r   r?   rB   rN   )r!   r?   rB   rN   )r&   r?   r'   r?   rB   r?   )rK   zOptional[DriverInfo] | objectrL   r+   r,   r+   rB   zOptional[DriverInfo])Ú
__future__r   Údataclassesr   r   Útypingr   r   r2   r   r   r   r   r"   r(   r*   rM   r%   r   r   ú<module>rR      s€   ðÝ "ç (ß !å  â
(€óó
ó.:ó.ð ÷[5ð [5ó ð[5ð~ 2:Ø'/Ø*2ð IØ.ð Ià$ð Ið (ð Ið ô	 Ir   