a
    ‹©lc  ã                   @   s:   d Z ddlZddlZddlZddd„Zd	dd„Zeƒ ZdS )
z+
Utilities for dealing with text encodings
é    Nc                 C   s   t | dƒr| js|S | jS dS )a)  Return the given stream's encoding or a default.

    There are cases where ``sys.std*`` might not actually be a stream, so
    check for the encoding attribute prior to returning it, and return
    a default if it doesn't exist or evaluates as False. ``default``
    is None if not provided.
    ÚencodingN)Úhasattrr   )ÚstreamÚdefault© r   úR/var/www/html/django/DPS/env/lib/python3.9/site-packages/IPython/utils/encoding.pyÚget_stream_enc   s    r   Tc                 C   sf   d}| rt tjƒ}|r|dkr>zt ¡ }W n ty<   Y n0 |pHt ¡ }|dkrbt dt	¡ dS |S )aÛ  Return IPython's guess for the default encoding for bytes as text.

    If prefer_stream is True (default), asks for stdin.encoding first,
    to match the calling Terminal, but that is often None for subprocesses.

    Then fall back on locale.getpreferredencoding(),
    which should be a sensible platform default (that respects LANG environment),
    and finally to sys.getdefaultencoding() which is the most conservative option,
    and usually UTF8 as of Python 3.
    NÚasciiÚcp0zˆInvalid code page cp0 detected - using cp1252 instead.If cp1252 is incorrect please ensure a valid code page is defined for the process.Úcp1252)
r   ÚsysÚstdinÚlocaleÚgetpreferredencodingÚ	ExceptionÚgetdefaultencodingÚwarningsÚwarnÚRuntimeWarning)Zprefer_streamÚencr   r   r   r   &   s     
ýr   )N)T)Ú__doc__r   r   r   r   r   ÚDEFAULT_ENCODINGr   r   r   r   Ú<module>   s   

!