o
    VhJ.                     @  sn   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ er&d dl	m
Z
 G dd deZG d	d
 d
ZdS )    )annotations)TYPE_CHECKING)parse_constraint)ConflictCauseError)PythonCauseError)Incompatibilityc                   @  s.   e Zd ZdddZeddd	Zdd
dZdS )SolveFailureErrorincompatibilityr   returnNonec                 C  s
   || _ d S N)_incompatibility)selfr	    r   k/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/mixology/failure.py__init__   s   
zSolveFailureError.__init__strc                 C  s   t | S r   )r   r   r   r   r   message   s   zSolveFailureError.messagec                 C  s   t | j S r   )_Writerr   writer   r   r   r   __str__   s   zSolveFailureError.__str__Nr	   r   r
   r   r
   r   )__name__
__module____qualname__r   propertyr   r   r   r   r   r   r      s
    
r   c                   @  sZ   e Zd ZdddZddd	Z	
dd ddZ	
dd!ddZd"ddZd#ddZd$ddZ	dS )%r   rootr   r
   r   c                 C  s(   || _ i | _g | _i | _| | j  d S r   )_root_derivations_lines_line_numbers_count_derivations)r   r   r   r   r   r      s
   z_Writer.__init__r   c                 C  s  g }g }d}| j jD ][}t|jtret|jj}t|jj}|d|j	d j
j d|| d |sA|d|jj d d}t|jj}t|jj}|d	|j	d j
j d
|jj d||  q
|rm|d t| j jtr{| | j  n| | j d| j  d | jsdntdt| j d  d}d}| jD ]3}	|	d }
|
s|s|d d}qd}|	d }|d urd| d||
 }
nd| |
 }
||
 q|rddd dD }d}|r|dd| 7 }|d}|d| d| d d|S )NFzFor <fg=default;options=bold>r   zj</>, a possible solution would be to set the `<fg=default;options=bold>python</>` property to <fg=yellow>"z"</>z.The current project's supported Python range (zJ) is not compatible with some of the required packages Python requirement:Tz  - z requires Python z+, so it will not be installable for Python  Because z, version solving failed.(z) ) ,c                 s  s    | ]	}d | dV  qdS )zG
    <fg=blue>https://python-poetry.org/docs/dependency-specification/#z</>Nr   ).0sectionr   r   r   	<genexpr>l   s
    

z _Writer.write.<locals>.<genexpr>)zpython-restricted-dependencieszusing-environment-markerszThe Python requirement can be specified via the `<fg=default;options=bold>python</>` or `<fg=default;options=bold>markers</>` propertiesz

    
zf
  <fg=blue;options=bold>* </><fg=default;options=bold>Check your dependencies Python requirement</>: )r   external_incompatibilities
isinstancecauser   r   root_python_versionpython_versionappendterms
dependencyname	intersect
differencer   _visit_writer"   lenlistvaluesr!   ljustjoinstrip)r   bufferversion_solutions$required_python_version_notificationr	   root_constraint
constraintpaddinglast_was_emptyliner   numberlinksdescriptionr   r   r   r   $   s   



	

z_Writer.writeFr	   r   numberedboolc                 C  sD   |rt | jd }|| j|< | j||f d S | j|d f d S N   )r<   r"   r!   r4   )r   r	   r   rM   rJ   r   r   r   r;      s
   
z_Writer._write
conclusionc              
   C  s  |p| j | dk}|s|| jkrdnd}t|}|j}t|ts"J t|jjtrt|jjtr| j	|j}| j	|j}|d urb|d urb|j
|j||}	| j|d|	 d| d|d d S |d usj|d ur|d urw|j}
|j}|}n|d ur|j}
|j}|}| | | j|| d|
d	| d
| d|d d S | |jj}| |jj}|s|r|r|jn|j}|r|jn|j}| | | | | j|d| d|d d S | j|jdd | jd | |j | j|| d|jd	| j|j  d
| |d d S t|jjtst|jjtrt|jjtr!|jn|j}t|jjtr/|jn|j}| j	|}|d urU|
|d |}	| j|d|	 d| d|d d S | |r|j}t|tsfJ t|jjtru|j}|j}n|j}|j}| | |
|d d }	| j|| d|	 d| d|d d S | | | j|| d|d| d|d d S |j
|jd d }	| j|d|	 d| d|d d S )NrP   zSo,Andr%   z, .)rM   z	 because z (z), zThus, T)rQ   )r$   N)r    r   r   r1   r0   r   conflictotherr"   getand_to_stringr;   r:   _is_single_liner!   r4   _is_collapsible)r   r	   rQ   rM   conjunctionincompatibility_stringr1   conflict_line
other_linereason	with_linewithout_linerI   single_line_conflictsingle_line_otherfirstsecondderivedextderived_linederived_causecollapsed_derivedcollapsed_extr   r   r   r:      s   

















z_Writer._visitc                 C  s   | j | dkr	dS |j}t|tsJ t|jjtr#t|jjtr#dS t|jjts3t|jjts3dS t|jjtr=|jn|j}|| jvS )NrP   F)r    r1   r0   r   rT   rU   r"   )r   r	   r1   complexr   r   r   rY     s"   
z_Writer._is_collapsibler1   r   c                 C  s    t |jjt ot |jjt S r   )r0   rT   r1   r   rU   )r   r1   r   r   r   rX   %  s
   z_Writer._is_single_linec                 C  sZ   || j v r| j |  d7  < d S d| j |< |j}t|tr+| |j | |j d S d S rO   )r    r1   r0   r   r#   rT   rU   )r   r	   r1   r   r   r   r#   *  s   


z_Writer._count_derivationsN)r   r   r
   r   r   )F)r	   r   r   r   rM   rN   r
   r   )r	   r   rQ   rN   r
   r   )r	   r   r
   rN   )r1   r   r
   rN   r   )
r   r   r   r   r   r;   r:   rY   rX   r#   r   r   r   r   r      s    

b
~
r   N)
__future__r   typingr   poetry.core.constraints.versionr   %poetry.mixology.incompatibility_causer   r   poetry.mixology.incompatibilityr   	Exceptionr   r   r   r   r   r   <module>   s    