§
    §â±b©  ã                   ó¶   — d Z ddlZddlZddlmZ  ej        ded¬¦  «         ej        dk    re	Z
 G d„ d	¦  «        Z G d
„ de¦  «        Z G d„ d¦  «        ZdS )u9  
Deprecated module to handle Exceptions across Python versions.

.. warning::
   This module is deprecated with the end of support for Python 2.7
   and will be removed in Docutils 0.21 or later.

   Replacements:
     | SafeString  -> str
     | ErrorString -> docutils.io.error_string()
     | ErrorOutput -> docutils.io.ErrorOutput

Error reporting should be safe from encoding/decoding errors.
However, implicit conversions of strings and exceptions like

>>> u'%s world: %s' % ('HÃ¤llo', Exception(u'HÃ¤llo'))

fail in some Python versions:

* In Python <= 2.6, ``unicode(<exception instance>)`` uses
  `__str__` and fails with non-ASCII chars in`unicode` arguments.
  (work around http://bugs.python.org/issue2517):

* In Python 2, unicode(<exception instance>) fails, with non-ASCII
  chars in arguments. (Use case: in some locales, the errstr
  argument of IOError contains non-ASCII chars.)

* In Python 2, str(<exception instance>) fails, with non-ASCII chars
  in `unicode` arguments.

The `SafeString`, `ErrorString` and `ErrorOutput` classes handle
common exceptions.
é    N)Ú_locale_encodingz�The `docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.
Details with help("docutils.utils.error_reporting").é   )Ú
stacklevel©é   r   c                   ó*   — e Zd ZdZ	 	 dd„Zd„ Zd„ ZdS )	Ú
SafeStringzG
    A wrapper providing robust conversion to `str` and `unicode`.
    NÚbackslashreplaceÚreplacec                 ór   — || _         |pt          |dd ¦  «        pt          pd| _        || _        || _        d S )NÚencodingÚascii)ÚdataÚgetattrÚlocale_encodingr   Úencoding_errorsÚdecoding_errors)Úselfr   r   r   r   s        ú@/usr/lib/python3/dist-packages/docutils/utils/error_reporting.pyÚ__init__zSafeString.__init__C   sL   € àˆŒ	Ø!ð 7¥W¨T°:¸tÑ%DÔ%Dð 7Ý+ð7Ø/6ð 	Œà.ˆÔØ.ˆÔÐÐó    c                 ó’  ‡ — 	 t          ‰ j        ¦  «        S # t          $ r¥ t          ‰ j        t          ¦  «        r/ˆ fd„‰ j        j        D ¦   «         }d                     |¦  «        cY S t          ‰ j        t          ¦  «        r@t          j	        dk    r	‰ j        cY S ‰ j         
                    ‰ j        ‰ j        ¦  «        cY S ‚ w xY w)Nc           	      ó`   •— g | ]*}t          t          |‰j        ‰j        ¦  «        ¦  «        ‘Œ+S © )Ústrr	   r   r   ©Ú.0Úargr   s     €r   ú
<listcomp>z&SafeString.__str__.<locals>.<listcomp>P   sK   ø€ ð 3ð 3ð 3àõ �J s¨D¬MØ'+Ô';ñ=ô =ñ >ô >ð 3ð 3ð 3r   ú, r   )r   r   ÚUnicodeEncodeErrorÚ
isinstanceÚ	ExceptionÚargsÚjoinÚunicodeÚsysÚversion_infoÚencoder   r   )r   r$   s   ` r   Ú__str__zSafeString.__str__K   sð   ø€ ð	Ý�t”y‘>”>Ð!øÝ!ð 	ð 	ð 	Ý˜$œ)¥YÑ/Ô/ð 'ð3ð 3ð 3ð 3à#'¤9¤>ð3ñ 3ô 3�ð —y’y ‘”Ð&Ð&Ð&Ý˜$œ)¥WÑ-Ô-ð BÝÔ# fÒ,Ð,Øœ9Ð$Ð$Ð$àœ9×+Ò+¨D¬MØ,0Ô,@ñBô Bð Bð Bð Bàð	øøøs   ƒ —ACÁ*1CÂ%CÃCc                 ó¼  ‡ — 	 t          ‰ j        ¦  «        }t          ‰ j        t          ¦  «        r|                     dd¦  «        }|S # t
          $ �r}t          ‰ j        t          ¦  «        rad‰ j        j        ›dt          ‰ j        j        ‰ j	        ‰ j
        ¦  «        ›dt          ‰ j        j        ‰ j	        ‰ j
        ¦  «        ›d�cY d}~S t          ‰ j        t          ¦  «        r2ˆ fd„‰ j        j        D ¦   «         }d                     |¦  «        cY d}~S t          |t          ¦  «        r%t          ‰ j        ‰ j	        ‰ j
        ¦  «        cY d}~S ‚ d}~ww xY w)	af  
        Return unicode representation of `self.data`.

        Try ``unicode(self.data)``, catch `UnicodeError` and

        * if `self.data` is an Exception instance, work around
          http://bugs.python.org/issue2517 with an emulation of
          Exception.__unicode__,

        * else decode with `self.encoding` and `self.decoding_errors`.
        z: u'z: 'z[Errno z] ú'Nc           	      ób   •— g | ]+}t          t          |‰j        ‰j        ¬ ¦  «        ¦  «        ‘Œ,S ))r   )r&   r	   r   r   r   s     €r   r   z*SafeString.__unicode__.<locals>.<listcomp>v   sX   ø€ ð 3ð 3ð 3ð  õ  ¥
Ø$'¨¬Ø48Ô4Hð!Jñ !Jô !Jñ Kô Kð 3ð 3ð 3r   r    )r&   r   r"   ÚEnvironmentErrorr   ÚUnicodeErrorÚerrnor	   Ústrerrorr   r   Úfilenamer#   r$   r%   ÚUnicodeDecodeError)r   ÚuÚerrorr$   s   `   r   Ú__unicode__zSafeString.__unicode__\   s¡  ø€ ð	Ý˜œ	Ñ"Ô"ˆAÝ˜$œ)Õ%5Ñ6Ô6ð -Ø—I’I˜f eÑ,Ô,�ØˆHøÝð 	ñ 	ð 	Ý˜$œ)Õ%5Ñ6Ô6ð 6ð 6à”I”O�O�OÝ˜tœyÔ1°4´=Ø#Ô3ñ5ô 5ð 5ð 5å˜tœyÔ1°4´=Ø#Ô3ñ5ô 5ð 5ð 5ð	6ð 6ð 6ð 6ð 6ð 6ð 6õ ˜$œ)¥YÑ/Ô/ð (ð3ð 3ð 3ð 3ð $(¤9¤>ð3ñ 3ô 3�ð —z’z $Ñ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ý˜%Õ!3Ñ4Ô4ð OÝ˜tœy¨$¬-¸Ô9MÑNÔNÐNÐNÐNÐNÐNÐNØøøøøð!	øøøs>   ƒAA	 Á	EÁA5EÃ	EÃAEÄEÄ4EÅEÅEÅE)Nr
   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r*   r6   r   r   r   r	   r	   >   sY   € € € € € ðð ð =OØ!*ð/ð /ð /ð /ðð ð ð"!ð !ð !ð !ð !r   r	   c                   ó,   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zˆ xZS )ÚErrorStringz3
    Safely report exception type and message.
    c                 óz   •— | j         j        j        ›dt          t          | ¦  «                             ¦   «         ›�S ©Nz: )r   Ú	__class__r7   Úsuperr<   r*   ©r   r?   s    €r   r*   zErrorString.__str__„   s:   ø€ Øœ9Ô.Ô7Ð7Ð7Ý ¥¨dÑ3Ô3×;Ò;Ñ=Ô=Ð=ð?ð 	?r   c                 óz   •— | j         j        j        ›dt          t          | ¦  «                             ¦   «         ›�S r>   )r   r?   r7   r@   r<   r6   rA   s    €r   r6   zErrorString.__unicode__ˆ   s<   ø€ Ø œIÔ/Ô8Ð8Ð8Ý!¥+¨tÑ4Ô4×@Ò@ÑBÔBÐBðDð 	Dr   )r7   r8   r9   r:   r*   r6   Ú__classcell__)r?   s   @r   r<   r<   €   sd   ø€ € € € € ðð ð?ð ?ð ?ð ?ð ?ðDð Dð Dð Dð Dð Dð Dð Dð Dr   r<   c                   ó,   — e Zd ZdZ	 	 	 dd„Zd„ Zd„ ZdS )	ÚErrorOutputz’
    Wrapper class for file-like error streams with
    failsafe de- and encoding of `str`, `bytes`, `unicode` and
    `Exception` instances.
    Nr
   r   c                 ó~  — |€t           j        }nt|sd}not          |t          ¦  «        rt	          |d¦  «        }nIt          |t
          ¦  «        r4t	          |                     t          j        ¦   «         ¦  «        d¦  «        }|| _        	 |pt          |dd¦  «        pt          pd| _        	 || _        	 || _        dS )a‘  
        :Parameters:
            - `stream`: a file-like object,
                        a string (path to a file),
                        `None` (write to `sys.stderr`, default), or
                        evaluating to `False` (write() requests are ignored).
            - `encoding`: `stream` text encoding. Guessed if None.
            - `encoding_errors`: how to treat encoding errors.
        NFÚwr   r   )r'   Ústderrr"   r   Úopenr&   r)   ÚgetfilesystemencodingÚstreamr   r   r   r   r   )r   rK   r   r   r   s        r   r   zErrorOutput.__init__”   sÐ   € ð ˆ>Ý”ZˆFˆFØð 	KØˆFˆFå˜¥Ñ$Ô$ð 	KÝ˜& #Ñ&Ô&ˆFˆFÝ˜¥Ñ(Ô(ð 	KÝ˜&Ÿ-š-­Ô(AÑ(CÔ(CÑDÔDÀcÑJÔJˆFàˆŒØ+à!ð 7¥W¨V°ZÀÑ%FÔ%Fð 7Ý+ð7Ø/6ð 	Œà,à.ˆÔØ%à.ˆÔØ%Ð%r   c                 ó
  — | j         du rdS t          |t          ¦  «        r.t          t	          || j        | j        | j        ¦  «        ¦  «        }	 | j                              |¦  «         dS # t          $ r< | j                              | 
                    | j        | j        ¦  «        ¦  «         Y dS t          $ rÈ t          |t          ¦  «        r;| j                              | 
                    | j        | j        ¦  «        ¦  «         Y dS | j         t          j        t          j        fv r"| j         j                             |¦  «         Y dS | j                              t          || j        | j        ¦  «        ¦  «         Y dS w xY w)z–
        Write `data` to self.stream. Ignore, if self.stream is False.

        `data` can be a `string`, `unicode`, or `Exception` instance.
        FN)rK   r"   r#   r&   r	   r   r   r   Úwriter!   r)   Ú	TypeErrorr'   rH   ÚstdoutÚbuffer)r   r   s     r   rM   zErrorOutput.write·   s°  € ð Œ;˜%ÐÐØˆFÝ�d�IÑ&Ô&ð 	=Ý�: d¨D¬MØ&*Ô&:Ø&*Ô&:ñ<ô <ñ =ô =ˆDð	AØŒK×Ò˜dÑ#Ô#Ð#Ð#Ð#øÝ!ð 	Pð 	Pð 	PØŒK×Ò˜dŸkšk¨$¬-¸Ô9MÑNÔNÑOÔOÐOÐOÐOÐOÝð 		Að 		Að 		AÝ˜$¥Ñ(Ô(ð Ø”×!Ò! $§+¢+¨d¬mØ.2Ô.Bñ#Dô #Dñ Eô Eð Eà��ØŒ{�sœz­3¬:Ð6Ð6Ð6Ø”Ô"×(Ò(¨Ñ.Ô.Ð.Ð.Ð.Ð.à”×!Ò!¥'¨$°´Ø*.Ô*>ñ#@ô #@ñ Aô Að Að Að Að Að		Aøøøs&   ÁA, Á,AFÂ1AFÄ
>FÅ3FÆFc                 óž   — | j         t          j        t          j        fv rdS 	 | j                              ¦   «          dS # t
          $ r Y dS w xY w)z‘
        Close the error-output stream.

        Ignored if the stream is` sys.stderr` or `sys.stdout` or has no
        close() method.
        N)rK   r'   rO   rH   ÚcloseÚAttributeError)r   s    r   rR   zErrorOutput.closeÒ   s`   € ð Œ;�3œ:¥s¤zÐ2Ð2Ð2ØˆFð	ØŒK×ÒÑÔÐÐÐøÝð 	ð 	ð 	ØˆDˆDð	øøøs   £> ¾
AÁA)NNr
   r   )r7   r8   r9   r:   r   rM   rR   r   r   r   rE   rE   �   s_   € € € € € ðð ð .2Ø!3Ø!*ð!&ð !&ð !&ð !&ðFAð Að Að6ð ð ð ð r   rE   )r:   r'   ÚwarningsÚdocutils.ior   r   ÚwarnÚDeprecationWarningr(   r   r&   r	   r<   rE   r   r   r   ú<module>rX      s
  ðð ð  ðD €
€
€
Ø €€€à ;Ð ;Ð ;Ð ;Ð ;Ð ;à €„ð Eð !¨Qð0ñ 0ô 0ð 0ð Ô�vÒÐØ€Gð?ð ?ð ?ð ?ð ?ñ ?ô ?ð ?ðD
Dð 
Dð 
Dð 
Dð 
D�*ñ 
Dô 
Dð 
DðQð Qð Qð Qð Qñ Qô Qð Qð Qð Qr   