
    lh                     R   d Z ddlZ	 ddlZn# e$ r Y nw xY wddlZddlZddlZddlZdZej	        dk    Z
e
rej        neZe
reneZe
reneZe
reneZddZddZe
rd Znd	 Ze
reneZe
rej        nej        ej        fZd
 Z	 ej        ZdS # e$ r ej        d             ZY dS w xY w)z:mod:`wand.compat` --- Compatibility layer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module provides several subtle things to support
multiple Python versions (2.7, 3.3+) and VM implementations
(CPython, PyPy).

    N)PY3abcbinarybinary_typeencode_filename
file_typesnestedstring_typetext	text_typeto_bytesxrange)   c                 
   t          | t                    r|                                 S t          | t                    r| S |r#t	          d                    ||                     t	          dt          |           z             )aJ  Makes ``string`` to :class:`str` in Python 2.
    Makes ``string`` to :class:`bytes` in Python 3.

    :param string: a string to cast it to :data:`binary_type`
    :type string: :class:`bytes`, :class:`str`, :class:`unicode`
    :param var: an optional variable name to be used for error message
    :type var: :class:`str`

    z{0} must be a string, not {1!r}zexpected a string, not )
isinstancer   encoder   	TypeErrorformatrepr)stringvars     N/var/www/html/research.buxo.ca/env/lib/python3.11/site-packages/wand/compat.pyr   r   -   s}     &)$$ }}	FK	(	( 
 O9@@fMMNNN
-V<
=
==    {0}c                 P    |                     |                                           S )ax  Short-cut method to allow mixed value types to be converted to bytes.

    :param value: Value to be cast to bytes
    :type value: :class:`basestring`, :class:`int`, :class:`float`
    :param string_pattern: String format to allow printf style control of
                           bytes output.
    :type string_pattern: :class:`basestring`

    .. versionadded:: 0.6.4
    )r   r   )valuestring_patterns     r   r   r   @   s$       ''..000r   c                 Z    t          | t                    r|                     d          S | S )Nzutf-8)r   bytesdecoder   s    r   r   r   O   s+    fe$$ 	*==)))r   c                     | S )zMakes ``string`` to :class:`str` in Python 3.
        Does nothing in Python 2.

        :param string: a string to cast it to :data:`text_type`
        :type string: :class:`bytes`, :class:`str`, :class:`unicode`

         r!   s    r   r   r   T   s	     r   c                     t          | d          r|                                 } t          | t                    r&|                     t          j                              S | S )zIf ``filename`` is a :data:`text_type`, encode it to
    :data:`binary_type` according to filesystem's default encoding.

    .. versionchanged:: 0.5.3
       Added support for PEP-519 https://github.com/emcconville/wand/pull/339
    
__fspath__)hasattrr%   r   r   r   sysgetfilesystemencoding)filenames    r   r   r   h   sY     x&& )&&(((I&& <s8::;;;Or   c               '     K   g }g }d}	 | D ]B}|j         }|j        }|                     |                       |                    |           C|V  n#  t          j                    }Y nxY w|r9|                                }	  || rd}n#  t          j                    }Y nxY w|9|dk    r& |d         |d                   }|d         |_        |d S # |r9|                                }	  || rd}n#  t          j                    }Y nxY w|9|dk    r& |d         |d                   }|d         |_        |w xY w)N)NNNr         )__exit__	__enter__appendr'   exc_infopop__traceback__)managersexitsvarsexcmgrexitenteres           r   r	   r	   z   s      	 # #|EEGG$$$T""""JJJJ	!,..CCC )yy{{)tSz 10),..CCC  ) (((CF3q6NN"#A$	 )(  )yy{{)tSz 10),..CCC  ) (((CF3q6NN"#A$sB   A	A C A+)C B B$E /C76E 7D4E )N)r   )__doc__collectionscollections.abcImportError
contextlibior'   types__all__version_infor   r   r   strr   
basestringr
   unicoder   r   r   r   ranger   	RawIOBaseFileTyper   r   r	   AttributeErrorcontextmanagerr#   r   r   <module>rL      s       	 	 	 	D	     				 



 ! 
$ -koo+ #ee (ccj #CCG	> > > >&1 1 1 1     
   	!6
 !DR\\r|U^&D
  FFF        s    B B&%B&