
    /
ip                        d dl mZ d dlmZmZ d dlmZmZ h dZdd
Z	ddZ
ddZddZe G d d                      ZddZdS )     )annotations)	dataclassfield)ListOptional>   {}()[]valuestr
field_namereturnNonec                    | D ]C}t          |          dk     st          |          dk    s	|t          v rt          | d          DdS )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)r   r   chs      C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\redis/driver_info.py_validate_no_invalid_charsr   	   se       r77T>>SWWt^^rW}}fff   0=     namec                x    ddl }t          | d           |                    d|           st          d          dS )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_-]*$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   )r   r   s     r   _validate_driver_namer!      sV     IIIt]33388)400 
G
 
 	

 
r   versionc                &    t          | d           d S )NzDriver version)r   )r"   s    r   _validate_driver_versionr$   /   s    w(899999r   driver_namedriver_versionc                    |  d| S )N_v )r%   r&   s     r   _format_driver_entryr*   3   s    --^---r   c                      e Zd ZU dZdZded<   dZded<    ee          Z	d	ed
<   d Z
edd            ZddZedd            ZdS )
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 (default: "redis-py")
    lib_version : str, optional
        The redis-py library version. If None, the version will be determined
        automatically from the installed package.

    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'
    redis-pyr   r   NOptional[str]lib_version)default_factory	List[str]	_upstreamc                B    | j         ddlm}  |            | _         dS dS )z'Initialize lib_version if not provided.Nr   get_lib_version)r/   redis.utilsr5   )selfr5   s     r   __post_init__zDriverInfo.__post_init__]   s;    #333333.00D $#r   r   c                *    t          | j                  S )zuReturn a copy of the upstream driver entries.

        Each entry is in the form ``"driver-name_vversion"``.
        )listr2   r7   s    r   upstream_driverszDriverInfo.upstream_driversd   s     DN###r   r%   r&   'DriverInfo'c                    |t          d          |t          d          t          |           t          |           t          ||          }| j                            d|           | S )zAdd an upstream driver to this instance and return self.

        The most recently added driver appears first in :pyattr:`formatted_name`.
        NzDriver name must not be NonezDriver version must not be Noner   )r   r!   r$   r*   r2   insert)r7   r%   r&   entrys       r   add_upstream_driverzDriverInfo.add_upstream_driverm   sv     ;<<<!>???k*** 000$[.AAa'''r   c                h    | j         s| j        S | j         dd                    | j                    dS )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)
        r
   ;r   )r2   r   joinr;   s    r   formatted_namezDriverInfo.formatted_name   s=     ~ 	9)99chht~669999r   )r   r1   )r%   r   r&   r   r   r=   )r   r   )__name__
__module____qualname____doc__r   __annotations__r/   r   r:   r2   r8   propertyr<   rA   rE   r)   r   r   r,   r,   7   s          @ D!%K%%%% 5666I66661 1 1 $ $ $ X$   * 
: 
: 
: X
: 
: 
:r   r,   driver_infoOptional[DriverInfo]lib_namer.   r/   c                `    | | S ddl m} ||nd}||n	 |            }t          ||          S )a  Resolve driver_info from parameters.

    If driver_info is provided, use it. Otherwise, create DriverInfo from
    lib_name and lib_version (using defaults if not provided).

    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
        The resolved DriverInfo instance
    Nr   r4   r-   )r   r/   )r6   r5   r,   )rL   rN   r/   r5   r   r"   s         r   resolve_driver_inforP      s[    0  ,++++++88D(4kk//:K:KG4W5555r   N)r   r   r   r   r   r   )r   r   r   r   )r"   r   r   r   )r%   r   r&   r   r   r   )rL   rM   rN   r.   r/   r.   r   r,   )
__future__r   dataclassesr   r   typingr   r   r   r   r!   r$   r*   r,   rP   r)   r   r   <module>rT      s    " " " " " " ( ( ( ( ( ( ( ( ! ! ! ! ! ! ! !
(
(
(   
 
 
 
.: : : :. . . . U: U: U: U: U: U: U: U:p 6  6  6  6  6  6r   