U
    mufu                     @   sz   d dl mZmZmZmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZ ddlmZ G dd	 d	eZG d
d dZdS )    )AnyIteratorOptionalSet   )parse_requirement)ParserSyntaxError)Marker_normalize_extra_values)SpecifierSet)canonicalize_namec                   @   s   e Zd ZdZdS )InvalidRequirementzJ
    An invalid requirement was found, users should refer to PEP 508.
    N)__name__
__module____qualname____doc__ r   r   :/tmp/pip-unpacked-wheel-nsq0ak9d/packaging/requirements.pyr      s   r   c                   @   sn   e Zd ZdZeddddZeee dddZed	d
dZed	ddZ	e
d	ddZeedddZdS )RequirementzParse a requirement.

    Parse a given requirement string into its parts, such as name, specifier,
    URL, and extras. Raises InvalidRequirement on a badly-formed requirement
    string.
    N)requirement_stringreturnc              
   C   s   zt |}W n0 tk
r< } ztt||W 5 d }~X Y nX |j| _|jpNd | _t|jp\g | _t|j	| _	d | _
|j
d k	rtt| _
t|j
| j
_d S N)_parse_requirementr   r   strnameurlsetextrasr   	specifiermarkerr	   __new__r
   _markers)selfr   parseder   r   r   __init__!   s     
zRequirement.__init__)r   r   c                 c   st   |V  | j r*dt| j }d| dV  | jr<t| jV  | jr\d| j V  | jr\dV  | jrpd| j V  d S )N,[]z@  z; )r   joinsortedr   r   r   r   )r"   r   Zformatted_extrasr   r   r   _iter_parts0   s    zRequirement._iter_parts)r   c                 C   s   d | | jS )N )r*   r,   r   r"   r   r   r   __str__B   s    zRequirement.__str__c                 C   s   d|  dS )Nz<Requirement('z')>r   r.   r   r   r   __repr__E   s    zRequirement.__repr__c                 C   s   t | jjf| t| jS r   )hash	__class__r   r,   r   r   r.   r   r   r   __hash__H   s    zRequirement.__hash__)otherr   c                 C   sR   t |tstS t| jt|jkoP| j|jkoP| j|jkoP| j|jkoP| j|jkS r   )	
isinstancer   NotImplementedr   r   r   r   r   r   )r"   r4   r   r   r   __eq__P   s    




zRequirement.__eq__)r   r   r   r   r   r%   r   r,   r/   r0   intr3   r   boolr7   r   r   r   r   r      s   r   N)typingr   r   r   r   _parserr   r   
_tokenizerr   markersr	   r
   
specifiersr   utilsr   
ValueErrorr   r   r   r   r   r   <module>   s   