
    ng\j                        S SK Jr  S SKJrJr  S SKJrJr  S SKJ	r	  1 Skr
SS jrSS jrSS jrSS	 jr\ " S
 S5      5       r\	\	\	4       SS jjrg)    )annotations)	dataclassfield)ListOptional)SENTINEL>   ()[]{}c                    U  H9  n[        U5      S:  d  [        U5      S:  d  U[        ;   d  M-  [        U S35      e   g)zEnsure 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      L/home/edenadmin/noVNC/venv/lib/python3.13/site-packages/redis/driver_info.py_validate_no_invalid_charsr      sA     r7T>SWt^rW},ef      c                h    SSK n[        U S5        UR                  SU 5      (       d  [        S5      eg)aW  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_-]*$zUpstream 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      s;     t]388)400G
 	
 1r   c                    [        U S5        g )NzDriver version)r   )versions    r   _validate_driver_versionr"   1   s    w(89r   c                    U  SU 3$ )N_v )driver_namedriver_versions     r   _format_driver_entryr(   5   s    ]"^,--r   c                      \ rS rSr% Sr\rS\S'   \rS\S'   \	" \
S9rS\S'   S	 r\SS
 j5       r      SS jr\SS j5       rSrg)
DriverInfo9   a  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                    U R                   [        L a  SU l         U R                  [        L a  SSKJn  U" 5       U l        gg)z7Initialize default metadata if not explicitly provided.zredis-pyr   )get_lib_versionN)r   r   r-   redis.utilsr2   )selfr2   s     r   __post_init__DriverInfo.__post_init__`   s6    99 "DIx'3.0D (r   c                ,    [        U R                  5      $ )zeReturn a copy of the upstream driver entries.

Each entry is in the form ``"driver-name_vversion"``.
)listr0   )r4   s    r   upstream_driversDriverInfo.upstream_driversi   s     DNN##r   c                    Uc  [        S5      eUc  [        S5      e[        U5        [        U5        [        X5      nU R                  R                  SU5        U $ )zAdd 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(   r0   insert)r4   r&   r'   entrys       r   add_upstream_driverDriverInfo.add_upstream_driverr   s[     ;<<!>??k* 0$[Aa'r   c                    U R                   n[        U[        5      (       a  U(       d  gU R                  (       d  U$ U SSR	                  U R                  5       S3$ )zReturn 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strr0   join)r4   r   s     r   formatted_nameDriverInfo.formatted_name   sL     yy$$$D~~Kq$..12!44r   )r-   r   N)returnr/   )r&   rC   r'   rC   rG   z'DriverInfo')rG   zOptional[str])__name__
__module____qualname____firstlineno____doc__r   r   __annotations__r-   r   r8   r0   r5   propertyr9   r>   rE   __static_attributes__r%   r   r   r*   r*   9   sy    B $,D
 +*2K'2 6Iy61 $ $03	* 5 5r   r*   c                ~    U [         L a  Uc  Uc  g[        XS9$ U b  [        U [        5      (       a  U $ [        S5      e)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*   rB   	TypeError)driver_infolib_namer-   s      r   resolve_driver_inforT      sI    0 h 3xAAjjAA
G
HHr   N)r   rC   r   rC   rG   None)r   rC   rG   rU   )r!   rC   rG   rU   )r&   rC   r'   rC   rG   rC   )rR   zOptional[DriverInfo] | objectrS   r,   r-   r,   rG   zOptional[DriverInfo])
__future__r   dataclassesr   r   typingr   r   r3   r   r   r   r   r"   r(   r*   rT   r%   r   r   <module>rY      s    " ( !  
(
.:. [5 [5 [5~ 2:'/*2 I. I$ I ( I 	 Ir   