o
    Ô­jù  ã                   @   sì   d Z g d¢ZddlZddlZddlmZ ddlZzddlZW n e	y+   ddlZY nw e
Ze
fZeZeZeZdd„ Zdd„ Zd	d
„ Zdd„ Zddd„Zdd„ ZdZdd„ Zdd„ Zdd„ Zdd„ ZG dd„ dƒZd dd„ZejZej Z!dS )!a³  
Python 3.X compatibility tools.

While this file was originally intended for Python 2 -> 3 transition,
it is now used to create a compatibility layer between different
minor versions of Python 3.

While the active version of numpy may not support a given version of python, we
allow downstream libraries to continue to use these shims for forward
compatibility with numpy while they transition their code to newer versions of
Python.
)ÚbytesÚasbytesÚ	isfileobjÚgetexceptionÚstrcharÚunicodeÚ	asunicodeÚasbytes_nestedÚasunicode_nestedÚasstrÚopen_latin1ÚlongÚ
basestringÚsixuÚinteger_typesÚis_pathlib_pathÚnpy_load_moduleÚPathÚpickleÚcontextlib_nullcontextÚ	os_fspathÚos_PathLikeé    N)r   c                 C   ó   t | tƒr
|  d¡S t| ƒS ©NÚlatin1©Ú
isinstancer   ÚdecodeÚstr©Ús© r!   úN/var/www/html/CropPilot/venv/lib/python3.10/site-packages/numpy/compat/py3k.pyr   "   ó   

r   c                 C   s   t | tƒr| S t| ƒ d¡S r   )r   r   r   Úencoder   r!   r!   r"   r   '   s   
r   c                 C   r   r   r   r   r!   r!   r"   r
   ,   r#   r
   c                 C   s>   t | tjtjtjfƒsdS z|  ¡  W dS  ty   Y dS w )NFT)r   ÚioÚFileIOÚBufferedReaderÚBufferedWriterÚfilenoÚOSError)Úfr!   r!   r"   r   1   s   ÿr   Úrc                 C   s   t | |dd�S )Nz
iso-8859-1)ÚmodeÚencoding)Úopen)Úfilenamer-   r!   r!   r"   r   <   s   r   c                 C   s   | S ©Nr!   r   r!   r!   r"   r   ?   ó   r   ÚUc                   C   s   t  ¡ d S )Né   )ÚsysÚexc_infor!   r!   r!   r"   r   D   s   r   c                 C   ó.   t | dƒrt| ttfƒsdd„ | D ƒS t| ƒS )NÚ__iter__c                 S   ó   g | ]}t |ƒ‘qS r!   )r   ©Ú.0Úyr!   r!   r"   Ú
<listcomp>I   ó    z"asbytes_nested.<locals>.<listcomp>)Úhasattrr   r   r   r   ©Úxr!   r!   r"   r   G   ó   r   c                 C   r7   )Nr8   c                 S   r9   r!   )r	   r:   r!   r!   r"   r=   O   r>   z$asunicode_nested.<locals>.<listcomp>)r?   r   r   r   r   r@   r!   r!   r"   r	   M   rB   r	   c                 C   s
   t | tƒS )z„
    Check whether obj is a `pathlib.Path` object.

    Prefer using ``isinstance(obj, os.PathLike)`` instead of this function.
    )r   r   )Úobjr!   r!   r"   r   S   s   
r   c                   @   s*   e Zd ZdZd	dd„Zdd„ Zdd„ ZdS )
r   a­  Context manager that does no additional processing.

    Used as a stand-in for a normal context manager, when a particular
    block of code is only sometimes used with a normal context manager:

    cm = optional_cm if condition else nullcontext()
    with cm:
        # Perform operation, using optional_cm if condition is True

    .. note::
        Prefer using `contextlib.nullcontext` instead of this context manager.
    Nc                 C   s
   || _ d S r1   ©Úenter_result)ÚselfrE   r!   r!   r"   Ú__init__j   s   
zcontextlib_nullcontext.__init__c                 C   s   | j S r1   rD   )rF   r!   r!   r"   Ú	__enter__m   s   z contextlib_nullcontext.__enter__c                 G   s   d S r1   r!   )rF   Úexcinfor!   r!   r"   Ú__exit__p   r2   zcontextlib_nullcontext.__exit__r1   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rG   rH   rJ   r!   r!   r!   r"   r   \   s
    
r   c                 C   s   ddl m} || |ƒ ¡ S )aÒ  
    Load a module. Uses ``load_module`` which will be deprecated in python
    3.12. An alternative that uses ``exec_module`` is in
    numpy.distutils.misc_util.exec_mod_from_location

    .. versionadded:: 1.11.2

    Parameters
    ----------
    name : str
        Full module name.
    fn : str
        Path to module file.
    info : tuple, optional
        Only here for backward compatibility with Python 2.*.

    Returns
    -------
    mod : module

    r   )ÚSourceFileLoader)Úimportlib.machineryrO   Úload_module)ÚnameÚfnÚinforO   r!   r!   r"   r   t   s   r   )r,   r1   )"rN   Ú__all__r5   ÚosÚpathlibr   r%   Úpickle5r   ÚImportErrorÚintr   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r	   r   r   r   Úfspathr   ÚPathLiker   r!   r!   r!   r"   Ú<module>   s>    ÿ
	

