o
    µ+ke  ã                   @   s   d dl Z dd„ Zdd„ ZdS )é    Nc                 C   s¢   d}t  || t j¡}|du rtd|  ƒ‚| ¡ }t|d ƒt|d ƒt|d ƒg} |jdkrHdd	d
dœ|d  }t|d ƒ}| ||g7 } t| ƒS | dg7 } t| ƒS )u´  
    Simplistic parser for setuptools_scm versions.

    Supports final versions and alpha ('a'), beta ('b') and release candidate ('rc') versions.
    It does not try to parse anything else than that, even if there is more in the version string.

    Output is a version tuple containing integers. It ends with one or two elements that ensure that relational
    operators yield correct relations for alpha, beta and rc versions, too.
    For final versions the last element is a -1.
    For prerelease versions the last two elements are a smaller negative number and the number of e.g. the beta.

    This version format is part of the remote protocol, donâ€˜t change in breaking ways.
    z»
        (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)   # version, e.g. 1.2.33
        (?P<prerelease>(?P<ptype>a|b|rc)(?P<pnum>\d+))?  # optional prerelease, e.g. a1 or b2 or rc33
    NzInvalid version string %sÚmajorÚminorÚpatchZ
prereleaseéüÿÿÿéýÿÿÿéþÿÿÿ)ÚaÚbÚrcÚptypeZpnuméÿÿÿÿ)ÚreÚmatchÚVERBOSEÚ
ValueErrorÚ	groupdictÚintÚ	lastgroupÚtuple)ÚversionZ
version_reÚmÚgdÚp_typeZp_num© r   ú0usr/lib/python3.10/site-packages/borg/version.pyÚparse_version   s   "

ÿr   c                 C   sn   g }t | ƒ}	 t|ƒ}|dkr| t|ƒ¡ n|dkrn|d ddddœ|  tt|ƒƒ |d< nqd |¡S )	zGa reverse for parse_version (obviously without the dropped information)Tr   r   r
   r	   r   )r   r   r   Ú.)ÚiterÚnextÚappendÚstrÚjoin)r   ÚfÚitÚpartr   r   r   Úformat_version$   s   (ø
	r%   )r   r   r%   r   r   r   r   Ú<module>   s     