
    h                        % S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
Jr  \rS\S'   S	rSqSS
 jrSS jrSS jrSS jrSS jrSS jrg)a  Module for checking and comparing albumentations package versions.

This module provides utilities for version checking and comparison, including
the ability to fetch the latest version from PyPI and compare it with the currently
installed version. It helps users stay informed about available updates and
encourages keeping the library up-to-date with the latest features and bug fixes.
    )annotationsN)OpenerDirector)warn)__version__strr      c                     [         cX  [        R                  R                  [        R                  R	                  5       [        R                  R                  5       5      q [         $ )a)  Get or create a URL opener for making HTTP requests.

This function implements a singleton pattern for the opener to avoid
recreating it on each request. It lazily instantiates a URL opener
with HTTP and HTTPS handlers.

Returns:
    OpenerDirector: URL opener instance for making HTTP requests.

)openerurllibrequestbuild_openerHTTPHandlerHTTPSHandler     V/var/www/fran/franai/venv/lib/python3.13/site-packages/albumentations/check_version.py
get_openerr      s>     ~,,V^^-G-G-I6>>KfKfKhiMr   c                 v   [        5       n Sn U R                  USS9 nUR                  [        :X  aI  UR	                  5       nUR                  5       R                  S5      nUR                  U5      sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 3SS9   SnAgSnAff = f)	a  Fetch version information from PyPI for albumentations package.

This function retrieves JSON data from PyPI containing information about
the latest available version of albumentations. It handles network errors
gracefully and returns an empty string if the request fails.

Returns:
    str: JSON string containing version information if successful,
         empty string otherwise.

z)https://pypi.org/pypi/albumentations/json   )timeoutzutf-8NzError fetching version info 
stacklevel )
r   openstatusSUCCESS_HTML_CODEreadinfoget_content_charsetdecode	Exceptionr   )r
   urlresponsedataencodinges         r   fetch_version_infor'   +   s     \F
5C?[[a[(H"33}}#==?>>wG{{8,	 )(3 )  )(   ?+A3/A>?s;   B AB2	B =B 
BB B 
B8!B33B8c                    U (       a9   [         R                  " U 5      nUR                  S0 5      R                  SS5      $ g! [         R                   a     gf = f)z,Parses the version from the given JSON data.r   versionr   )jsonloadsgetJSONDecodeError)r$   	json_datas     r   parse_versionr/   D   sU    	

4(I==,00B??  ## 		s   7A AAc                   [        X5       H|  u  p#X#:w  d  M  [        U[        5      (       a  [        U[        5      (       a  X#:  s  $ [        U[        5      (       a  [        U[        5      (       a  X#:  s  $ [        U[        5      s  $    [	        U 5      [	        U5      :  a  [        U [	        U5         [        5      $ [	        U5      [	        U 5      :  a  [        U[	        U 5         [        5      $ g)zCompare two version tuples.
Returns True if v1 > v2, False otherwise.

Special rules:
1. Release version > pre-release version (e.g., (1, 4) > (1, 4, 'beta'))
2. Numeric parts are compared numerically
3. String parts are compared lexicographically
F)zip
isinstanceintr   len)v1v2p1p2s       r   compare_versionsr9   Q   s     b+8"c""z"c':':w"c""z"c':':wb#&&  2wR"SW+s++
2wR"SW+s++r   c                ,   / nU R                  S5       Hs  n[        R                  " SU5      nU HS  nUR                  5       (       a  UR	                  [        U5      5        M4  UR	                  UR                  5       5        MU     Mu     [        U5      $ )zConvert version string to tuple of (int | str) parts following PEP 440 conventions.

Examples:
    "1.4.24" -> (1, 4, 24)
    "1.4beta" -> (1, 4, "beta")
    "1.4.beta2" -> (1, 4, "beta", 2)
    "1.4.alpha2" -> (1, 4, "alpha", 2)

.z([0-9]+|[a-zA-Z]+))splitrefindallisdigitappendr3   lowertuple)version_strpartspartsegmentssegments        r   parse_version_partsrH   p   st     E!!#&::3T:G  S\*W]]_-	   ' <r   c                 "    [        5       n [        U 5      nU(       aH  [        U5      n[        [        5      n[	        X#5      (       a  [        SU< S[        < S3[        SS9  ggg! [         a  n[        SU S3[        SS9   SnAgSnAff = f)	a  Check if a newer version of albumentations is available on PyPI.

This function compares the current installed version with the latest version
available on PyPI. If a newer version is found, it issues a warning to the user
with upgrade instructions. All exceptions are caught to ensure this check
doesn't affect normal package operation.

The check can be disabled by setting the environment variable
NO_ALBUMENTATIONS_UPDATE to 1.
z.A new version of Albumentations is available: z (you have z). Upgrade using: pip install -U albumentations. To disable automatic update checks, set the environment variable NO_ALBUMENTATIONS_UPDATE to 1.r   r   z*Failed to check for updates due to error: za. To disable automatic update checks, set the environment variable NO_ALBUMENTATIONS_UPDATE to 1.N)r'   r/   rH   current_versionr9   r   UserWarningr!   )r$   latest_versionlatest_partscurrent_partsr&   s        r   check_for_updatesrO      s    
!#&t,.~>L/@M<<D^DVVabqat uv v    =   
8 <n n		

s   A"A' '
B1B		B)returnr   )rP   r   )r$   r   rP   r   )r5   tuple[int | str, ...]r6   rQ   rP   bool)rC   r   rP   rQ   )rP   None)__doc__
__future__r   r*   r=   urllib.requestr   r   warningsr   albumentationsr   rJ   __annotations__r   r
   r   r'   r/   r9   rH   rO   r   r   r   <module>rZ      sT    #  	  )  9"S " 	"2
>.
r   