o
    i                     @  s   d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
mZmZ eeZG dd dZG dd	 d	eZdddZ	ddddZdddZdS )    )annotations)	getLogger)
Collection)InvalidRequirementRequirement)DistributionPackageNotFoundErrorversionc                   @  s^   e Zd ZU dZdZded< dZded< dZded< dZded< 				ddd	d
Z	dd Z
dS )DependencyConflicta  Represents a dependency conflict in OpenTelemetry instrumentation.

    This class is used to track conflicts between required dependencies and the
    actual installed packages. It supports two scenarios:

    1. Standard conflicts where all dependencies are required
    2. Either/or conflicts where only one of a set of dependencies is required

    Attributes:
        required: The required dependency specification that conflicts with what's installed.
        found: The actual dependency that was found installed (if any).
        required_any: Collection of dependency specifications where any one would satisfy
            the requirement (for either/or scenarios).
        found_any: Collection of actual dependencies found for either/or scenarios.
    N
str | NonerequiredfoundCollection[str]required_any	found_anyc                 C  s   || _ || _|| _|| _d S N)r   r   r   r   )selfr   r   r   r    r   p/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/opentelemetry/instrumentation/dependencies.py__init__6   s   
zDependencyConflict.__init__c                 C  s>   | j s| js	| jrd| j d| j dS d| j  d| j dS )Nz5DependencyConflict: requested any of the following: "z" but found: ""z DependencyConflict: requested: ")r   r   r   r   r   r   r   r   __str__C   s   zDependencyConflict.__str__)NNNN)r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r   __annotations__r   r   r   r   r   r   r   r   r   r
      s   
 r
   c                   @  s(   e Zd ZU ded< dddZdd ZdS )	DependencyConflictErrorr
   conflictc                 C  s
   || _ d S r   )r   )r   r   r   r   r   r   L      
z DependencyConflictError.__init__c                 C  s
   t | jS r   )strr   r   r   r   r   r   O   r    zDependencyConflictError.__str__N)r   r
   )r   r   r   r   r   r   r   r   r   r   r   I   s   
 
r   distr   returnDependencyConflict | Nonec           
      C  s   g }g }d}d}||i}d}||i}| j rC| j D ]*}||vrq||vr(||vr(qt|}	|	j|r7||	 |	j|rB||	 qt||S )Nextrainstrumentszinstruments-any)requiresr   markerevaluateappendget_dependency_conflicts)
r"   instrumentation_depsinstrumentation_any_depsr%   r&   instruments_markerinstruments_anyinstruments_any_markerdepreqr   r   r   get_dist_dependency_conflictsS   s,   


r3   NdepsCollection[str | Requirement]deps_any$Collection[str | Requirement] | Nonec                 C  s   | D ]Z}t |tr|}n&zt|}W n ty1 } ztd|| t|W  Y d }~  S d }~ww zt|j}W n tyH   t| Y   S w |j	
|s\t||j d|   S q|rct|S d S )N<error parsing dependency, reporting as a conflict: "%s" - %s )
isinstancer   r   loggerwarningr
   r	   namer   	specifiercontains_get_dependency_conflicts_any)r4   r6   r1   r2   excdist_versionr   r   r   r+   n   s2   
r+   c                 C  s   | sd S d}g }g }| D ]d}t |tr|}n&zt|}W n ty; } ztd|| t|W  Y d }~  S d }~ww zt|j}W n tyS   |	t
| Y qw |j|r^d} n|	t
| |	|j d|  q|ryt||dS d S )NTr8   Fr9   )r   r   )r:   r   r   r;   r<   r
   r	   r=   r   r*   r!   r>   r?   )r6   is_dependency_conflictr   r   r1   r2   rA   rB   r   r   r   r@      sH   
r@   )r"   r   r#   r$   r   )r4   r5   r6   r7   r#   r$   )r6   r5   r#   r$   )
__future__r   loggingr   typingr   packaging.requirementsr   r   &opentelemetry.util._importlib_metadatar   r   r	   r   r;   r
   	Exceptionr   r3   r+   r@   r   r   r   r   <module>   s   *

 $