a
    =9`"                  	   @   s   d Z ddlZddlmZ ddlZdZedZdddd	ddd	dd
Zddddddddd
Z	ddddZ
G dd dedg dZdddZG dd dZeddddZe ZdS )a  
Backport of PEP 562.

https://pypi.org/search/?q=pep562

Licensed under MIT
Copyright (c) 2018 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
    N)
namedtuple)Pep562z(?x)
    (?P<major>\d+)(?:\.(?P<minor>\d+))?(?:\.(?P<micro>\d+))?
    (?:(?P<type>a|b|rc)(?P<pre>\d+))?
    (?:\.post(?P<post>\d+))?
    (?:\.dev(?P<dev>\d+))?
     abrc).devz
.dev-alphaz	.dev-beta.dev-candidatealphabeta	candidatefinalz2 - Pre-Alphaz	3 - Alphaz4 - Betaz5 - Production/Stabler
   r   r   )r   r   r   c                       sJ   e Zd ZdZd fdd	Zdd Zdd	 Zd
d Zdd Zdd Z	  Z
S )Versional  
    Get the version (PEP 440).

    A biased approach to the PEP 440 semantic version.

    Provides a tuple structure which is sorted for comparisons `v1 > v2` etc.
      (major, minor, micro, release type, pre-release build, post-release build, development release build)
    Release types are named in is such a way they are comparable with ease.
    Accessors to check if a development, pre-release, or post-release build. Also provides accessor to get
    development status for setup files.

    How it works (currently):

    - You must specify a release type as either `final`, `alpha`, `beta`, or `candidate`.
    - To define a development release, you can use either `.dev`, `.dev-alpha`, `.dev-beta`, or `.dev-candidate`.
      The dot is used to ensure all development specifiers are sorted before `alpha`.
      You can specify a `dev` number for development builds, but do not have to as implicit development releases
      are allowed.
    - You must specify a `pre` value greater than zero if using a prerelease as this project (not PEP 440) does not
      allow implicit prereleases.
    - You can optionally set `post` to a value greater than zero to make the build a post release. While post releases
      are technically allowed in prereleases, it is strongly discouraged, so we are rejecting them. It should be
      noted that we do not allow `post0` even though PEP 440 does not restrict this. This project specifically
      does not allow implicit post releases.
    - It should be noted that we do not support epochs `1!` or local versions `+some-custom.version-1`.

    Acceptable version releases:

    ```
    Version(1, 0, 0, "final")                    1.0
    Version(1, 2, 0, "final")                    1.2
    Version(1, 2, 3, "final")                    1.2.3
    Version(1, 2, 0, ".dev-alpha", pre=4)        1.2a4
    Version(1, 2, 0, ".dev-beta", pre=4)         1.2b4
    Version(1, 2, 0, ".dev-candidate", pre=4)    1.2rc4
    Version(1, 2, 0, "final", post=1)            1.2.post1
    Version(1, 2, 3, ".dev")                     1.2.3.dev0
    Version(1, 2, 3, ".dev", dev=1)              1.2.3.dev1
    ```

    r   r   c           	   
      s   |||||fD ]}t |tr$|dkstdq|tvrDtd|d|  k rXdk rn n.|dkrntdq|r|tdq|rtdnJ|d	k r|d
kr|dkrtdq|rtdn|rtdn|rtdt | |||||||S )zValidate version info.r   z6All version parts except 'release' should be integers.z!'{}' is not a valid release type.r	   r   z"Implicit pre-releases not allowed.z%Version is not a development release.z0Post-releases are not allowed with pre-releases.r
   r   z!Implicit pre-release not allowed.zVersion is not a pre-release.)
isinstanceint
ValueErrorREL_MAPformatsuper__new__)	clsmajorminormicroreleaseprepostdevvalue	__class__ .lib/python3.9/site-packages/markdown/pep562.pyr   j   s,    






zVersion.__new__c                 C   s
   | j dkS )zIs prerelease.r   )r   selfr!   r!   r"   _is_pre   s    zVersion._is_prec                 C   s   t | jdk S )zIs development.r
   )boolr   r#   r!   r!   r"   _is_dev   s    zVersion._is_devc                 C   s
   | j dkS )zIs post.r   )r   r#   r!   r!   r"   _is_post   s    zVersion._is_postc                 C   s
   t | j S )zGet development status string.)
DEV_STATUSr   r#   r!   r!   r"   _get_dev_status   s    zVersion._get_dev_statusc                 C   s   | j dkrd| j| j}nd| j| j| j }|  rP|dt| j | j7 }|  rh|d| j	7 }| 
 r|d| j7 }|S )z Get the canonical output string.r   z{}.{}z{}.{}.{}z{}{}z.post{}z.dev{})r   r   r   r   r%   r   r   r   r(   r   r'   r   )r$   verr!   r!   r"   _get_canonical   s    
zVersion._get_canonical)r   r   r   r   )__name__
__module____qualname____doc__r   r%   r'   r(   r*   r,   __classcell__r!   r!   r   r"   r   ?   s   *$r   )r   r   r   r   r   r   r   Fc           	      C   s   t | }t|d}|dr0t|dnd}|drLt|dnd}|drxt|d }t|d}nd}d}|dr|dnd}|drt|d}|rd	| nd
}nd}|drt|dnd}t|||||||S )z.Parse version into a comparable Version tuple.r   r   r   r   typer   r   r   z.dev-r   r   )RE_VERmatchr   groupPRE_REL_MAPr   )	r+   r   mr   r   r   r   r   r   r!   r!   r"   parse_version   s     


r8   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	r   a  
    Backport of PEP 562 <https://pypi.org/search/?q=pep562>.

    Wraps the module in a class that exposes the mechanics to override `__dir__` and `__getattr__`.
    The given module will be searched for overrides of `__dir__` and `__getattr__` and use them when needed.
    c                 C   s:   t j| | _t| jdd| _t| jdd| _| t j|< dS )z_Acquire `__getattr__` and `__dir__`, but only replace module for versions less than Python 3.7.__getattr__N__dir__)sysmodules_modulegetattr	_get_attr_get_dirr$   namer!   r!   r"   __init__   s    zPep562.__init__c                 C   s   | j r|   S t| jS )zPReturn the overridden `dir` if one was provided, else apply `dir` to the module.)r@   dirr=   r#   r!   r!   r"   r:      s    zPep562.__dir__c                 C   s<   zt | j|W S  ty6   | jr0| | Y S  Y n0 dS )zjAttempt to retrieve the attribute from the module, and if missing, use the overridden function if present.N)r>   r=   AttributeErrorr?   rA   r!   r!   r"   r9      s    zPep562.__getattr__N)r-   r.   r/   r0   rC   r:   r9   r!   r!   r!   r"   r      s   r      r   )F)r0   r;   collectionsr   re__all__compiler3   r   r)   r6   r   r8   r   Z__version_info__r,   __version__r!   r!   r!   r"   <module>   s>   
u
  