
    _ h>                         d Z ddlZddlZddlmZmZ ddlmZmZ ddl	m
Z
 ddlZddlmZ ddlmZ  G d d	      Zd
 Zefdee   dee   fdZy)z!Decorators for Shapely functions.    N)CallableIterable)	lru_cachewraps)unwrap)libUnsupportedGEOSVersionErrorc                       e Zd ZdZd Zd Zy)requires_geosz,Decorator to require a minimum GEOS version.c                     |j                  d      dk7  rt        d      t        d |j                  d      D              | _        y)z8Create a decorator that requires a minimum GEOS version..   z.Version must be <major>.<minor>.<patch> formatc              3   2   K   | ]  }t        |        y wN)int).0xs     n/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/shapely/decorators.py	<genexpr>z)requires_geos.__init__.<locals>.<genexpr>   s     @SV@s   N)count
ValueErrortuplesplitversion)selfr   s     r   __init__zrequires_geos.__init__   s:    =="MNN@W]]3-?@@    c                    t         j                  | j                  k\  }t        j                  j                  d      dk(  }|r|sS  dj                  j                  g| j                   |rt              fd       }nt              fd       }|j                  }|rU|j                  d      dz   }d}	 |||z      d	k(  r|d
z  }nn|j                  ddj                  d	|z        d
      |_	        |S )zReturn the wrapped function.SPHINX_DOC_BUILD1z%'{}' requires at least GEOS {}.{}.{}.c                       | i |S r    )argskwargsfuncs     r   wrappedz'requires_geos.__call__.<locals>.wrapped$   s    T,V,,r   c                      t              r   r	   )r$   r%   msgs     r   r'   z'requires_geos.__call__.<locals>.wrapped*   s    1#66r   z

r   r       z

{}.. note:: {}

)r   geos_versionr   osenvirongetformat__name__r   __doc__findreplace)	r   r&   is_compatibleis_doc_buildr'   docpositionindentr)   s	    `      @r   __call__zrequires_geos.__call__   s   ((DLL8zz~~&89S@K<5<<MM
 LL
 4[- -
 4[7 7 ooxx'!+HFx&()S0aKF	 
 "kk077fcJAGO r   N)r1   
__module____qualname__r2   r   r:   r#   r   r   r   r      s    6A%r   r   c                 .     t                fd       }|S )zEnable multithreading.

    To do this, the writable flags of object type ndarrays are set to False.

    NB: multithreading also requires the GIL to be released, which is done in
    the C extension (ufuncs.c).
    c            	      r   | D cg c]3  }t        |t        j                        s|j                  t        k(  s2|5 c}|j                         D cg c]8  \  }}|dvr/t        |t        j                        r|j                  t        k(  r|: c}}z   }|D cg c]  }|j                  j                   }}	 |D ]  }d|j                  _          | i |t        ||      D ]  \  }}||j                  _         S c c}w c c}}w c c}w # t        ||      D ]  \  }}||j                  _         w xY w)N>   outwhereF)	
isinstancenpndarraydtypeobjectitemsflags	writeablezip)	r$   r%   argname
array_argsarr	old_flagsold_flagr&   s	           r   r'   z'multithreading_enabled.<locals>.wrappedI   s)     
:c2::#>399PVCVC
 $\\^
c++3

+		V#	 


 5??SSYY((?	?	/! ,&+		#,((!$Z!; /X&.		#/

 @ "%Z!; /X&.		#/s'   C?C?C?=DD
:D 'D6)r   )r&   r'   s   ` r   multithreading_enabledrP   @   s"     4[/ /& Nr   should_be_kwargscategoryc                 $     dt         f fd}|S )aS  Show warning if positional arguments are used that should be keyword.

    Parameters
    ----------
    should_be_kwargs : Iterable[str]
        Names of parameters that should be passed as keyword arguments.
    category : type[Warning], optional (default: DeprecationWarning)
        Warning category to use for deprecation warnings.

    Returns
    -------
    callable
        Decorator function that adds positional argument deprecation warnings.

    Examples
    --------
    >>> from shapely.decorators import deprecate_positional
    >>> @deprecate_positional(['b', 'c'])
    ... def example(a, b, c=None):
    ...     return a, b, c
    ...
    >>> example(1, 2)  # doctest: +SKIP
    DeprecationWarning: positional argument `b` for `example` is deprecated. ...
    (1, 2, None)
    >>> example(1, b=2)  # No warnings
    (1, 2, None)
    r&   c                 v   	 t               j                  }|j                  d |j                   }t	        |      D ci c]  \  }}||
 }}}D cg c]  }||v r||   |f c}s S t              d   	t        d      dt        f fd       t               
 	fd       }|S c c}}w c c}w )Nr   
   n_argsc                 X   D cg c]  \  }}|| k  s| }}}t        |      dk(  rd|d    d}d}d}nRd}d}t        |      dk(  rd	j                  d
 |D              }n'dj                  d |d d D              }|d|d    dz  }d| d| dj                   d| d| dS c c}}w )Nr+   `r    issarer   z and c              3   (   K   | ]
  }d | d   ywrX   Nr#   r   us     r   r   zLdeprecate_positional.<locals>.decorator.<locals>.make_msg.<locals>.<genexpr>   s     +Cas!H+C   z, c              3   (   K   | ]
  }d | d   ywr^   r#   r_   s     r   r   zLdeprecate_positional.<locals>.decorator.<locals>.make_msg.<locals>.<genexpr>   s     (Ea1QCq(Era   z, and `zpositional argumentr*   z for `z` z( deprecated. Please use keyword argumentz	 instead.)lenjoinr1   )	rV   idxrK   usedargs_txtplrisaredeprecate_positionsr&   s	          r   make_msgz9deprecate_positional.<locals>.decorator.<locals>.make_msg   s    *=NYS$vDNDN4yA~tAwiq>t9>&||+Cd+CCH#yy(E49(EEH'$r(1 55H &cU!H:VDMM?"'A#iQ Os
   B&B&c                  t     | i |}t        |       }|kD  rt        j                   |      d       |S )Nr   )rR   
stacklevel)rd   warningswarn)r$   r%   resultnrR   r&   rl   	warn_froms       r   wrapperz8deprecate_positional.<locals>.decorator.<locals>.wrapper   s;    4*6*FD	A9}hqkHKMr   )	r   __code__co_varnamesco_argcount	enumerateminr   r   r   )r&   code	pos_namesrf   rK   name_to_idxrt   rk   rl   rs   rR   rQ   s   `      @@@r   	decoratorz'deprecate_positional.<locals>.decorator   s    d|$$ $$%7t'7'78	2;I2FGYS$tSyGG )
{" %
 #K +,Q/		2	S 	 
	* 
t	 
	 _ H
s   B0B6)r   )rQ   rR   r}   s   `` r   deprecate_positionalr~   `   s    @5 5n r   )r2   r-   ro   collections.abcr   r   	functoolsr   r   inspectr   numpyrB   shapelyr   shapely.errorsr
   r   rP   DeprecationWarningstrtypeWarningr~   r#   r   r   <module>r      sV    ' 	  . &    6. .bD 1WsmW7mWr   