
    \e                     F    d Z ddlZddlZddlZddlmZ ddZd Zd Z	d Z
y)	z?
Helpers for comparing version strings.

.. versionadded:: 1.6
    N)_c                     t         j                  j                  |       }t         j                  j                  |      }|r|j                  |j                  k7  ry||k\  S )ap  Determine whether `requested_version` is satisfied by
    `current_version`; in other words, `current_version` is >=
    `requested_version`.

    :param requested_version: version to check for compatibility
    :param current_version: version to check against
    :param same_major: if True, the major version must be identical between
        `requested_version` and `current_version`. This is used when a
        major-version difference indicates incompatibility between the two
        versions. Since this is the common-case in practice, the default is
        True.
    :returns: True if compatible, False if not
    F)	packagingversionVersionmajor)requested_versioncurrent_version
same_major	requestedcurrents        9/usr/lib/python3/dist-packages/oslo_utils/versionutils.pyis_compatibler      sR     !!))*;<I''8G??gmm+i    c                     	 t        | t              rt        |       } t        | t              rt	        j
                  d |       S y# t        $ r}t        d      | z  }t        |      |d}~ww xY w)zConvert a version to an integer.

    *version* must be a string with dots or a tuple of integers.

    .. versionadded:: 2.0
    c                     | dz  |z   S )N   )xys     r   <lambda>z(convert_version_to_int.<locals>.<lambda>A   s    !d(a r   zVersion %s is invalid.N)	
isinstancestrconvert_version_to_tupletuple	functoolsreduce	Exceptionr   
ValueError)r   exmsgs      r   convert_version_to_intr"   6   sj    &gs#.w7Ggu%##$?II & &()G3o2%&s   AA 	A-A((A-c                     g }d}| dk7  r1| | |z  |z  z
  }|j                  dt        |             | |z  } | dk7  r1dj                  t        t        |            S )zPConvert a version integer to a string with dots.

    .. versionadded:: 2.0
    r   r   .)insertr   joinmap)version_intversion_numbersfactorversion_numbers       r   convert_version_to_strr,   G   sk    
 OF

$v(=(FGq#n"56!V+ 

 88C_-..r   c                 r    t        j                  dd|       } t        d | j                  d      D              S )zNConvert a version string with dots to a tuple.

    .. versionadded:: 2.0
    z(\d+)(a|alpha|b|beta|rc)\d+$z\1c              3   2   K   | ]  }t        |        y w)N)int).0parts     r   	<genexpr>z+convert_version_to_tuple.<locals>.<genexpr>\   s     >tT>s   r$   )resubr   split)version_strs    r   r   r   V   s3    
 &&8%MK>{'8'8'=>>>r   )T)__doc__r   r3   packaging.versionr   oslo_utils._i18nr   r   r"   r,   r   r   r   r   <module>r:      s,      	   0&"/?r   