/ lib / packaging / specifiers.pyc
specifiers.pyc
  1  o

  2  %��c��	@s2dZddlZddlZddlZddlmZmZmZmZm	Z	m
  3  Z
  4  mZmZddl
mZddlmZeeefZeeegefZdedefd	d
  5  �ZGdd�de�ZGd
d�dejd�ZGdd�de�Ze�d�Zdedeefdd�Zdedefdd�Zdeedeedeeeeeffdd�ZGdd�de�Z dS)z�
  6  .. testsetup::
  7  
  8      from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
  9      from packaging.version import Version
 10  �N)�Callable�Iterable�Iterator�List�Optional�Set�Tuple�Union�)�canonicalize_version)�Version�version�returncCst|t�s	t|�}|S�N)�
 11  isinstancer)r
�r��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\packaging\specifiers.py�_coerce_versions
 12  rc@seZdZdZdS)�InvalidSpecifiera
 13      Raised when attempting to create a :class:`Specifier` with a specifier
 14      string that is invalid.
 15  
 16      >>> Specifier("lolwat")
 17      Traceback (most recent call last):
 18          ...
 19      packaging.specifiers.InvalidSpecifier: Invalid specifier: 'lolwat'
 20      N)�__name__�
 21  __module__�__qualname__�__doc__rrrrrsrc	@s�eZdZejdefdd��Zejdefdd��Zejde	de
 22  fdd��Zeejde
e
 23  fd	d
 24  ���Zejde
 25  ddfd
d
 26  ��Zejddede
e
 27  de
 28  fdd��Zej	ddeede
e
 29  deefdd��ZdS)�
BaseSpecifierrcC�dS)z�
 30          Returns the str representation of this Specifier-like object. This
 31          should be representative of the Specifier itself.
 32          Nr��selfrrr�__str__*�zBaseSpecifier.__str__cCr)zF
 33          Returns a hash value for this Specifier-like object.
 34          Nrrrrr�__hash__1rzBaseSpecifier.__hash__�othercCr)z�
 35          Returns a boolean representing whether or not the two Specifier-like
 36          objects are equal.
 37  
 38          :param other: The other object to check against.
 39          Nr�rr rrr�__eq__7rzBaseSpecifier.__eq__cCr)z�Whether or not pre-releases as a whole are allowed.
 40  
 41          This can be set to either ``True`` or ``False`` to explicitly enable or disable
 42          prereleases or it can be set to ``None`` (the default) to use default semantics.
 43          Nrrrrr�prereleases@rzBaseSpecifier.prereleases�valueNcCr)zQSetter for :attr:`prereleases`.
 44  
 45          :param value: The value to set.
 46          Nr�rr$rrrr#Ir�itemr#cCr)zR
 47          Determines if the given item is contained within this specifier.
 48          Nr)rr&r#rrr�containsPrzBaseSpecifier.contains�iterablecCr)z�
 49          Takes an iterable of items and filters them so that only items which
 50          are contained within this specifier are allowed in it.
 51          Nr)rr(r#rrr�filterVrzBaseSpecifier.filterr)rrr�abc�abstractmethod�strr�intr�object�boolr"�propertyrr#�setterr'r�UnparsedVersionrr)rrrrr)s.����r)�	metaclassc	@s.eZdZdZdZdZe�deedejej	B�Z
 52  dddd	d
 53  ddd
d�ZdFdede
eddfdd�Zedefdd��Zejdeddfdd��Zedefdd��Zedefdd��Zdefdd�Zdefd d!�Zedeeeffd"d#��Zdefd$d%�Zd&edefd'd(�Zd)edefd*d+�Zd,ededefd-d.�Z d,ededefd/d0�Z!d,ededefd1d2�Z"d,ededefd3d4�Z#d,ededefd5d6�Z$d,ed7edefd8d9�Z%d,ed7edefd:d;�Z&d,ededefd<d=�Z'd>e(eefdefd?d@�Z)	dGd>e*de
edefdAdB�Z+	dGdCe,e*de
ede-e*fdDdE�Z.dS)H�	Specifiera?This class abstracts handling of version specifiers.
 54  
 55      .. tip::
 56  
 57          It is generally not required to instantiate this manually. You should instead
 58          prefer to work with :class:`SpecifierSet` instead, which can parse
 59          comma-separated version specifiers (which is what package metadata contains).
 60      z8
 61          (?P<operator>(~=|==|!=|<=|>=|<|>|===))
 62          a�
 63          (?P<version>
 64              (?:
 65                  # The identity operators allow for an escape hatch that will
 66                  # do an exact string match of the version you wish to install.
 67                  # This will not be parsed by PEP 440 and we cannot determine
 68                  # any semantic meaning from it. This operator is discouraged
 69                  # but included entirely as an escape hatch.
 70                  (?<====)  # Only match for the identity operator
 71                  \s*
 72                  [^\s;)]*  # The arbitrary version can be just about anything,
 73                            # we match everything except for whitespace, a
 74                            # semi-colon for marker support, and a closing paren
 75                            # since versions can be enclosed in them.
 76              )
 77              |
 78              (?:
 79                  # The (non)equality operators allow for wild card and local
 80                  # versions to be specified so we have to define these two
 81                  # operators separately to enable that.
 82                  (?<===|!=)            # Only match for equals and not equals
 83  
 84                  \s*
 85                  v?
 86                  (?:[0-9]+!)?          # epoch
 87                  [0-9]+(?:\.[0-9]+)*   # release
 88  
 89                  # You cannot use a wild card and a pre-release, post-release, a dev or
 90                  # local version together so group them with a | and make them optional.
 91                  (?:
 92                      \.\*  # Wild card syntax of .*
 93                      |
 94                      (?:                                  # pre release
 95                          [-_\.]?
 96                          (a|b|c|rc|alpha|beta|pre|preview)
 97                          [-_\.]?
 98                          [0-9]*
 99                      )?
100                      (?:                                  # post release
101                          (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
102                      )?
103                      (?:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
104                      (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local
105                  )?
106              )
107              |
108              (?:
109                  # The compatible operator requires at least two digits in the
110                  # release segment.
111                  (?<=~=)               # Only match for the compatible operator
112  
113                  \s*
114                  v?
115                  (?:[0-9]+!)?          # epoch
116                  [0-9]+(?:\.[0-9]+)+   # release  (We have a + instead of a *)
117                  (?:                   # pre release
118                      [-_\.]?
119                      (a|b|c|rc|alpha|beta|pre|preview)
120                      [-_\.]?
121                      [0-9]*
122                  )?
123                  (?:                                   # post release
124                      (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
125                  )?
126                  (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
127              )
128              |
129              (?:
130                  # All other operators only allow a sub set of what the
131                  # (non)equality operators do. Specifically they do not allow
132                  # local versions to be specified nor do they allow the prefix
133                  # matching wild cards.
134                  (?<!==|!=|~=)         # We have special cases for these
135                                        # operators so we want to make sure they
136                                        # don't match here.
137  
138                  \s*
139                  v?
140                  (?:[0-9]+!)?          # epoch
141                  [0-9]+(?:\.[0-9]+)*   # release
142                  (?:                   # pre release
143                      [-_\.]?
144                      (a|b|c|rc|alpha|beta|pre|preview)
145                      [-_\.]?
146                      [0-9]*
147                  )?
148                  (?:                                   # post release
149                      (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
150                  )?
151                  (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
152              )
153          )
154          z^\s*z\s*$�
155  compatible�equal�	not_equal�less_than_equal�greater_than_equal�	less_than�greater_than�	arbitrary)�~=�==z!=�<=�>=�<�>�===�N�specr#rcCsH|j�|�}|std|�d���|�d���|�d���f|_||_dS)a�Initialize a Specifier instance.
156  
157          :param spec:
158              The string representation of a specifier which will be parsed and
159              normalized before use.
160          :param prereleases:
161              This tells the specifier if it should accept prerelease versions if
162              applicable or not. The default of ``None`` will autodetect it from the
163              given specifiers.
164          :raises InvalidSpecifier:
165              If the given specifier is invalid (i.e. bad syntax).
166          zInvalid specifier: '�'�operatorr
N)�_regex�searchr�group�strip�_spec�_prereleases)rrEr#�matchrrr�__init__�s
�
167  zSpecifier.__init__cCsR|jdur|jS|j\}}|dvr'|dkr |�d�r |dd�}t|�jr'dSdS)N)r>r@r?r=rCr>�.*�����TF)rMrL�endswithr�
is_prerelease)rrGr
rrrr#�s
168  
169  
170  zSpecifier.prereleasesr$cC�
171  ||_dSr�rMr%rrrr#�
172  cC�
173  |jdS)z`The operator of this specifier.
174  
175          >>> Specifier("==1.2.3").operator
176          '=='
177          r�rLrrrrrG�
178  zSpecifier.operatorcCrW)zaThe version of this specifier.
179  
180          >>> Specifier("==1.2.3").version
181          '1.2.3'
182          r
183  rXrrrrr
rYzSpecifier.versioncCs8|jdurd|j��nd}d|jj�dt|��|�d�S)aTA representation of the Specifier that shows all internal state.
184  
185          >>> Specifier('>=1.0.0')
186          <Specifier('>=1.0.0')>
187          >>> Specifier('>=1.0.0', prereleases=False)
188          <Specifier('>=1.0.0', prereleases=False)>
189          >>> Specifier('>=1.0.0', prereleases=True)
190          <Specifier('>=1.0.0', prereleases=True)>
191          N�, prereleases=rDrA�(�)>)rMr#�	__class__rr,�r�prerrr�__repr__"s
192  
193  ��zSpecifier.__repr__cCsdj|j�S)z�A string representation of the Specifier that can be round-tripped.
194  
195          >>> str(Specifier('>=1.0.0'))
196          '>=1.0.0'
197          >>> str(Specifier('>=1.0.0', prereleases=False))
198          '>=1.0.0'
199          z{}{})�formatrLrrrrr4szSpecifier.__str__cCs*t|jd|jddkd�}|jd|fS)Nr
200  rr=��strip_trailing_zero)rrL)rZcanonical_versionrrr�_canonical_spec>s
201  �zSpecifier._canonical_speccC�
202  t|j�Sr)�hashrdrrrrrF�
203  zSpecifier.__hash__r cCsPt|t�rz	|�t|��}WntytYSwt||j�s"tS|j|jkS)a>Whether or not the two Specifier-like objects are equal.
204  
205          :param other: The other object to check against.
206  
207          The value of :attr:`prereleases` is ignored.
208  
209          >>> Specifier("==1.2.3") == Specifier("== 1.2.3.0")
210          True
211          >>> (Specifier("==1.2.3", prereleases=False) ==
212          ...  Specifier("==1.2.3", prereleases=True))
213          True
214          >>> Specifier("==1.2.3") == "==1.2.3"
215          True
216          >>> Specifier("==1.2.3") == Specifier("==1.2.4")
217          False
218          >>> Specifier("==1.2.3") == Specifier("~=1.2.3")
219          False
220          )rr,r]r�NotImplementedrdr!rrrr"Is
221  �zSpecifier.__eq__�opcCst|d|j|���}|S)N�	_compare_)�getattr�
222  _operators)rri�operator_callablerrr�
_get_operatorfs�zSpecifier._get_operator�prospectivecCsJd�tt�tt|���dd��}|d7}|�d�||�o$|�d�||�S)N�.�����rPr@r>)�join�list�	itertools�	takewhile�_is_not_suffix�_version_splitrn)rrorE�prefixrrr�_compare_compatiblels
223  ��zSpecifier._compare_compatiblecCs~|�d�r/t|j�}t|dd�dd�}t|�}t|�}t||�\}}|dt|��}	|	|kSt|�}
224  |
225  js;t|j�}||
226  kS)NrPrQFrb)rRr�publicrw�_pad_version�lenr�local)rrorEZnormalized_prospectiveZnormalized_spec�
227  split_spec�split_prospective�padded_prospective�_�shortened_prospective�spec_versionrrr�_compare_equal�s
228  
229  
230  zSpecifier._compare_equalcCs|�||�Sr)r��rrorErrr�_compare_not_equal�szSpecifier._compare_not_equalcCst|j�t|�kSr�rrzr�rrr�_compare_less_than_equal��z"Specifier._compare_less_than_equalcCst|j�t|�kSrr�r�rrr�_compare_greater_than_equal�r�z%Specifier._compare_greater_than_equal�spec_strcCs<t|�}||ks
231  dS|js|jrt|j�t|j�krdSdS�NFT)rrS�base_version�rror�rErrr�_compare_less_than�szSpecifier._compare_less_thancCs^t|�}||ks
232  dS|js|jrt|j�t|j�krdS|jdur-t|j�t|j�kr-dSdSr�)r�is_postreleaser�r}r�rrr�_compare_greater_than�s
233  zSpecifier._compare_greater_thancCst|���t|���kSr)r,�lowerr�rrr�_compare_arbitrary�szSpecifier._compare_arbitraryr&cC�
234  |�|�S)a;Return whether or not the item is contained in this specifier.
235  
236          :param item: The item to check for.
237  
238          This is used for the ``in`` operator and behaves the same as
239          :meth:`contains` with no ``prereleases`` argument passed.
240  
241          >>> "1.2.3" in Specifier(">=1.2.3")
242          True
243          >>> Version("1.2.3") in Specifier(">=1.2.3")
244          True
245          >>> "1.0.0" in Specifier(">=1.2.3")
246          False
247          >>> "1.3.0a1" in Specifier(">=1.2.3")
248          False
249          >>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
250          True
251          �r'�rr&rrr�__contains__��
252  zSpecifier.__contains__cCs<|dur|j}t|�}|jr|sdS|�|j�}|||j�S)alReturn whether or not the item is contained in this specifier.
253  
254          :param item:
255              The item to check for, which can be a version string or a
256              :class:`Version` instance.
257          :param prereleases:
258              Whether or not to match prereleases with this Specifier. If set to
259              ``None`` (the default), it uses :attr:`prereleases` to determine
260              whether or not prereleases are allowed.
261  
262          >>> Specifier(">=1.2.3").contains("1.2.3")
263          True
264          >>> Specifier(">=1.2.3").contains(Version("1.2.3"))
265          True
266          >>> Specifier(">=1.2.3").contains("1.0.0")
267          False
268          >>> Specifier(">=1.2.3").contains("1.3.0a1")
269          False
270          >>> Specifier(">=1.2.3", prereleases=True).contains("1.3.0a1")
271          True
272          >>> Specifier(">=1.2.3").contains("1.3.0a1", prereleases=True)
273          True
274          NF)r#rrSrnrGr
)rr&r#�normalized_itemrmrrrr'	s
275  zSpecifier.containsr(ccs��d}g}d|dur|ndi}|D]"}t|�}|j|fi|��r3|jr.|s.|js.|�|�qd}|Vq|s@|rB|D]	}|Vq:dSdSdS)aOFilter items in the given iterable, that match the specifier.
276  
277          :param iterable:
278              An iterable that can contain version strings and :class:`Version` instances.
279              The items in the iterable will be filtered according to the specifier.
280          :param prereleases:
281              Whether or not to allow prereleases in the returned iterator. If set to
282              ``None`` (the default), it will be intelligently decide whether to allow
283              prereleases or not (based on the :attr:`prereleases` attribute, and
284              whether the only versions matching are prereleases).
285  
286          This method is smarter than just ``filter(Specifier().contains, [...])``
287          because it implements the rule from :pep:`440` that a prerelease item
288          SHOULD be accepted if no other versions match the given specifier.
289  
290          >>> list(Specifier(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
291          ['1.3']
292          >>> list(Specifier(">=1.2.3").filter(["1.2", "1.2.3", "1.3", Version("1.4")]))
293          ['1.2.3', '1.3', <Version('1.4')>]
294          >>> list(Specifier(">=1.2.3").filter(["1.2", "1.5a1"]))
295          ['1.5a1']
296          >>> list(Specifier(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
297          ['1.3', '1.5a1']
298          >>> list(Specifier(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
299          ['1.3', '1.5a1']
300          Fr#NT)rr'rSr#�append)rr(r#�yielded�found_prereleases�kwr
�parsed_versionrrrr)7s*�����zSpecifier.filter�rDNr)/rrrrZ_operator_regex_str�_version_regex_str�re�compile�VERBOSE�
301  IGNORECASErHrlr,rr/rOr0r#r1rGr
r`rrrdr-rr.r"�CallableOperatorrnrryr�r�r�r�r�r�r�r	r�r2r'rrr)rrrrr4`st	^
302  ��
303  '���
304  �/����r4z^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}|�d�D]}t�|�}|r|�|���q|�|�q|S)Nrp)�split�
_prefix_regexrI�extend�groupsr�)r
�resultr&rNrrrrwxs
305  rw�segmentcst�fdd�dD��S)Nc3s�|]}��|�VqdSr)�
306  startswith)�.0rx�r�rr�	<genexpr>�s�
307  
308  �z!_is_not_suffix.<locals>.<genexpr>)�dev�a�b�rc�post)�anyr�rr�rrv�s
309  �rv�left�rightc
310  Cs�gg}}|�tt�dd�|���|�tt�dd�|���|�|t|d�d��|�|t|d�d��|�ddgtdt|d�t|d���|�ddgtdt|d�t|d���ttj|��ttj|��fS)NcS�|��Sr��isdigit��xrrr�<lambda>��z_pad_version.<locals>.<lambda>cSr�rr�r�rrrr��r�rr
311  �0)r�rsrtrur|�insert�max�chain)r�r��
312  left_split�right_splitrrrr{�s
313  ,,r{c	@s2eZdZdZ	d%dedeeddfdd�Zedeefd	d
314  ��Z	e	j
315  deddfdd
316  ��Z	defd
d�Zdefdd�Zde
fdd�Zdedefddfdd�Zdedefdd�Zde
fdd�Zdeefdd�Zdedefdd�Z		d&dedeedeedefd d!�Z	d'd"eedeedeefd#d$�ZdS)(�SpecifierSetz�This class abstracts handling of a set of version specifiers.
317  
318      It can be passed a single specifier (``>=3.0``), a comma-separated list of
319      specifiers (``>=3.0,!=3.1``), or no specifier at all.
320      rDN�
321  specifiersr#rcCsFdd�|�d�D�}t�}|D]	}|�t|��qt|�|_||_dS)aNInitialize a SpecifierSet instance.
322  
323          :param specifiers:
324              The string representation of a specifier or a comma-separated list of
325              specifiers which will be parsed and normalized before use.
326          :param prereleases:
327              This tells the SpecifierSet if it should accept prerelease versions if
328              applicable or not. The default of ``None`` will autodetect it from the
329              given specifiers.
330  
331          :raises InvalidSpecifier:
332              If the given ``specifiers`` are not parseable than this exception will be
333              raised.
334          cSsg|]
335  }|��r|���qSr)rK�r��srrr�
336  <listcomp>�sz)SpecifierSet.__init__.<locals>.<listcomp>�,N)r��set�addr4�	frozenset�_specsrM)rr�r#�split_specifiers�parsed�	specifierrrrrO�s
337  
338  zSpecifierSet.__init__cCs.|jdur|jS|js
dStdd�|jD��S)Ncss�|]}|jVqdSr�r#r�rrrr��s�z+SpecifierSet.prereleases.<locals>.<genexpr>)rMr�r�rrrrr#�s
339  
340  zSpecifierSet.prereleasesr$cCrTrrUr%rrrr#�rVcCs.|jdurd|j��nd}dt|��|�d�S)aA representation of the specifier set that shows all internal state.
341  
342          Note that the ordering of the individual specifiers within the set may not
343          match the input string.
344  
345          >>> SpecifierSet('>=1.0.0,!=2.0.0')
346          <SpecifierSet('!=2.0.0,>=1.0.0')>
347          >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=False)
348          <SpecifierSet('!=2.0.0,>=1.0.0', prereleases=False)>
349          >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=True)
350          <SpecifierSet('!=2.0.0,>=1.0.0', prereleases=True)>
351          NrZrDz<SpecifierSet(r\)rMr#r,r^rrrr`�s
352  
353  ��zSpecifierSet.__repr__cCsd�tdd�|jD���S)anA string representation of the specifier set that can be round-tripped.
354  
355          Note that the ordering of the individual specifiers within the set may not
356          match the input string.
357  
358          >>> str(SpecifierSet(">=1.0.0,!=1.0.1"))
359          '!=1.0.1,>=1.0.0'
360          >>> str(SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False))
361          '!=1.0.1,>=1.0.0'
362          r�css�|]}t|�VqdSr)r,r�rrrr��s�z'SpecifierSet.__str__.<locals>.<genexpr>)rr�sortedr�rrrrr�szSpecifierSet.__str__cCrer)rfr�rrrrr�rgzSpecifierSet.__hash__r cCs�t|t�r
363  t|�}nt|t�stSt�}t|j|jB�|_|jdur-|jdur-|j|_|S|jdur=|jdur=|j|_|S|j|jkrI|j|_|Std��)a�Return a SpecifierSet which is a combination of the two sets.
364  
365          :param other: The other object to combine with.
366  
367          >>> SpecifierSet(">=1.0.0,!=1.0.1") & '<=2.0.0,!=2.0.1'
368          <SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
369          >>> SpecifierSet(">=1.0.0,!=1.0.1") & SpecifierSet('<=2.0.0,!=2.0.1')
370          <SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
371          NzFCannot combine SpecifierSets with True and False prerelease overrides.)rr,r�rhr�r�rM�
372  ValueError)rr r�rrr�__and__�s$
373  
374  
375  
376  �	���zSpecifierSet.__and__cCs6t|ttf�rtt|��}nt|t�stS|j|jkS)a�Whether or not the two SpecifierSet-like objects are equal.
377  
378          :param other: The other object to check against.
379  
380          The value of :attr:`prereleases` is ignored.
381  
382          >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.1")
383          True
384          >>> (SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False) ==
385          ...  SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True))
386          True
387          >>> SpecifierSet(">=1.0.0,!=1.0.1") == ">=1.0.0,!=1.0.1"
388          True
389          >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0")
390          False
391          >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.2")
392          False
393          )rr,r4r�rhr�r!rrrr"s
394  
395  zSpecifierSet.__eq__cCre)z7Returns the number of specifiers in this specifier set.)r|r�rrrr�__len__9rVzSpecifierSet.__len__cCre)z�
396          Returns an iterator over all the underlying :class:`Specifier` instances
397          in this specifier set.
398  
399          >>> sorted(SpecifierSet(">=1.0.0,!=1.0.1"), key=str)
400          [<Specifier('!=1.0.1')>, <Specifier('>=1.0.0')>]
401          )�iterr�rrrr�__iter__=s
402  zSpecifierSet.__iter__r&cCr�)arReturn whether or not the item is contained in this specifier.
403  
404          :param item: The item to check for.
405  
406          This is used for the ``in`` operator and behaves the same as
407          :meth:`contains` with no ``prereleases`` argument passed.
408  
409          >>> "1.2.3" in SpecifierSet(">=1.0.0,!=1.0.1")
410          True
411          >>> Version("1.2.3") in SpecifierSet(">=1.0.0,!=1.0.1")
412          True
413          >>> "1.0.1" in SpecifierSet(">=1.0.0,!=1.0.1")
414          False
415          >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1")
416          False
417          >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
418          True
419          r�r�rrrr�Gr�zSpecifierSet.__contains__�	installedcs\t�t�s	t����dur|j��s�jrdS|r!�jr!t�j��t��fdd�|jD��S)a�Return whether or not the item is contained in this SpecifierSet.
420  
421          :param item:
422              The item to check for, which can be a version string or a
423              :class:`Version` instance.
424          :param prereleases:
425              Whether or not to match prereleases with this SpecifierSet. If set to
426              ``None`` (the default), it uses :attr:`prereleases` to determine
427              whether or not prereleases are allowed.
428  
429          >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.2.3")
430          True
431          >>> SpecifierSet(">=1.0.0,!=1.0.1").contains(Version("1.2.3"))
432          True
433          >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.0.1")
434          False
435          >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1")
436          False
437          >>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True).contains("1.3.0a1")
438          True
439          >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True)
440          True
441          NFc3s�|]
442  }|j��d�VqdS)r�Nr�r��r&r#rrr��s�z(SpecifierSet.contains.<locals>.<genexpr>)rrr#rSr��allr�)rr&r#r�rr�rr'\s
443  
444  
445  
446  zSpecifierSet.containsr(cCs�|dur|j}|jr|jD]}|j|t|�d�}q
t|�Sg}g}|D]}t|�}|jr6|s6|s5|�|�q#|�|�q#|sH|rH|durHt|�St|�S)a.Filter items in the given iterable, that match the specifiers in this set.
447  
448          :param iterable:
449              An iterable that can contain version strings and :class:`Version` instances.
450              The items in the iterable will be filtered according to the specifier.
451          :param prereleases:
452              Whether or not to allow prereleases in the returned iterator. If set to
453              ``None`` (the default), it will be intelligently decide whether to allow
454              prereleases or not (based on the :attr:`prereleases` attribute, and
455              whether the only versions matching are prereleases).
456  
457          This method is smarter than just ``filter(SpecifierSet(...).contains, [...])``
458          because it implements the rule from :pep:`440` that a prerelease item
459          SHOULD be accepted if no other versions match the given specifier.
460  
461          >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
462          ['1.3']
463          >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", Version("1.4")]))
464          ['1.3', <Version('1.4')>]
465          >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.5a1"]))
466          []
467          >>> list(SpecifierSet(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
468          ['1.3', '1.5a1']
469          >>> list(SpecifierSet(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
470          ['1.3', '1.5a1']
471  
472          An "empty" SpecifierSet will filter items based on the presence of prerelease
473          versions in the set.
474  
475          >>> list(SpecifierSet("").filter(["1.3", "1.5a1"]))
476          ['1.3']
477          >>> list(SpecifierSet("").filter(["1.5a1"]))
478          ['1.5a1']
479          >>> list(SpecifierSet("", prereleases=True).filter(["1.3", "1.5a1"]))
480          ['1.3', '1.5a1']
481          >>> list(SpecifierSet("").filter(["1.3", "1.5a1"], prereleases=True))
482          ['1.3', '1.5a1']
483          Nr�)r#r�r)r/r�rrSr�)rr(r#rE�filteredr�r&r�rrrr)�s$,
484  
485  
486  �zSpecifierSet.filterr�)NNr)rrrrr,rr/rOr0r#r1r`rr-rr	r�r.r"r�rr4r�r2r�r'rr)rrrrr��sR���
487  �#
 
488  ����
489  �:����r�)!rr*rtr��typingrrrrrrrr	�utilsrr
rr,r2r/r�rr�r�ABCMetarr4r�r�rwrvr{r�rrrr�<module>s,(7
490  .