o
    Vh                     @  sZ   d dl mZ d dlZd dlmZ d dlmZ er$d dlmZ d dl	m
Z
 G dd dZdS )	    )annotationsN)TYPE_CHECKING)SetRelation)VersionConstraint)
Dependencyc                   @  s   e Zd ZdZd(dd	Zed)d
dZed*ddZed+ddZd,ddZ	d-ddZ
d.ddZd/ddZd/ddZd0ddZd1d!d"Zd2d#d$Zd2d%d&Zd'S )3Termz
    A statement about a package which is true or false for a given selection of
    package versions.

    See https://github.com/dart-lang/pub/tree/master/doc/solver.md#term.
    
dependencyr   is_positiveboolreturnNonec                 C  s8   || _ || _tjd d| j| _tjd d| j| _d S )N)maxsize)_dependency	_positive	functools	lru_cache	_relationrelation
_intersect	intersect)selfr   r	    r   h/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/mixology/term.py__init__   s   zTerm.__init__c                 C  s   t | j|   S N)r   r   r	   r   r   r   r   inverse   s   zTerm.inversec                 C     | j S r   )r   r   r   r   r   r   !   s   zTerm.dependencyr   c                 C  s   | j jS r   )r   
constraintr   r   r   r   r   %   s   zTerm.constraintc                 C  r   r   )r   r   r   r   r   r	   )   s   zTerm.is_positiveotherc                 C  s    | j j|j jko| |tjkS )z>
        Returns whether this term satisfies another.
        )r   complete_namer   r   SUBSETr   r   r   r   r   	satisfies,   s   zTerm.satisfiesstrc                 C  s   | j j|j jkrt| d| j j |j}| rQ|  r<| |j s'tjS || jr0tj	S | j
|s9tjS tjS | |j sEtjS | j|rNtjS tjS |  r{| |j s^tj	S |
| jsgtj	S || jrx| j j|j jkrxtjS tjS | |j stjS | j|rtj	S tjS )zq
        Returns the relationship between the package versions
        allowed by this term and another.
         should refer to )r   r    
ValueErrorr   r	   _compatible_dependencyr   DISJOINT
allows_allr!   
allows_anyOVERLAPPINGtransitive_marker)r   r   other_constraintr   r   r   r   5   sD   
zTerm._relationTerm | Nonec                 C  s   | j j|j jkrt| d| j j | |j rY|  | kr=|  r'| n|}|  r/|n| }| |j|jd|S |  rM| | j|jd|S | | j	|jd|S |  | kri|  rg| S |S dS )zk
        Returns a Term that represents the packages
        allowed by both this term and another
        r%   TFN)
r   r    r&   r'   r	   _non_empty_termr   
differencer   union)r   r   positivenegativer   r   r   r   y   s&   zTerm._intersectc                 C  s   |  |jS )zk
        Returns a Term that represents packages
        allowed by this term and not by the other
        )r   r   r"   r   r   r   r0      s   zTerm.differencec                 C  s:   | j jp|jp|| j p| j j|jko| j  | kS r   )r   is_rootis_same_package_asr    is_direct_originr"   r   r   r   r'      s   
zTerm._compatible_dependencyr   c                 C  s`   |  rd S | j s|j r|jn| j}||}|r+| r+| jj|jj|_t||S r   )is_emptyr   r6   with_constraintr	   r,   r1   r   )r   r   r	   r   r   new_depr   r   r   r/      s   

zTerm._non_empty_termc                 C  s   |   sdnd}| | j S )Nznot  )r	   r   )r   prefixr   r   r   __str__   s   zTerm.__str__c                 C  s   d| dS )Nz<Term >r   r   r   r   r   __repr__   s   zTerm.__repr__N)r   r   r	   r
   r   r   )r   r   )r   r   )r   r   )r   r
   )r   r   r   r
   )r   r   r   r$   )r   r   r   r.   )r   r   r   r
   )r   r   r	   r
   r   r   r   r.   )r   r$   )__name__
__module____qualname____doc__r   propertyr   r   r   r	   r#   r   r   r0   r'   r/   r<   r>   r   r   r   r   r      s$    



	
D
 


r   )
__future__r   r   typingr   poetry.mixology.set_relationr   poetry.core.constraints.versionr   poetry.core.packages.dependencyr   r   r   r   r   r   <module>   s    