jfdZddlZddlZddlmZejdedejdkre Z Gdd Z Gd d e Z Gd d Z dS)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()`` uses `__str__` and fails with non-ASCII chars in`unicode` arguments. (work around http://bugs.python.org/issue2517): * In Python 2, unicode() 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() fails, with non-ASCII chars in `unicode` arguments. The `SafeString`, `ErrorString` and `ErrorOutput` classes handle common exceptions. N)_locale_encodingzThe `docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later. Details with help("docutils.utils.error_reporting").) stacklevelrc*eZdZdZ ddZdZdZdS) SafeStringzG A wrapper providing robust conversion to `str` and `unicode`. Nbackslashreplacereplacecr||_|pt|ddptpd|_||_||_dS)Nencodingascii)datagetattrlocale_encodingr encoding_errorsdecoding_errors)selfrr rrs ~/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/docutils/utils/error_reporting.py__init__zSafeString.__init__CsL !7WT:t%D%D7+7/6 ..c tjS#t$rtjtr/fdjjD}d|cYStjtr@tj dkr jcYSj j j cYSwxYw)Nc `g|]*}tt|jj+S)strr r r.0argrs r z&SafeString.__str__..PsK333JsDM'+';==>>333r, r) rrUnicodeEncodeError isinstance Exceptionargsjoinunicodesys version_infoencoder r)rr$s` r__str__zSafeString.__str__Ks ty>> !!   $)Y// '3333#'9>333yy&&&$)W-- B#f,,9$$$9++DM,0,@BBBBB  sAC*1C%CCc  tj}tjtr|dd}|S#t $r}tjtradjjdtjjj j dtjj j j dcYd}~Stjtr2fdjj D}d|cYd}~St|tr%tjj j cYd}~Sd}~wwxYw) 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 bg|]+}tt|jj,S))r)r&r r rrs rrz*SafeString.__unicode__..vsX333  $'484H!J!J!JKK333rr )r&rr"EnvironmentErrorr UnicodeErrorerrnor strerrorr rfilenamer#r$r%UnicodeDecodeError)ruerrorr$s` r __unicode__zSafeString.__unicode__\s  ""A$)%566 -IIfe,,H   $)%566 6 6IOOOty14=#35555ty14=#35555 6666666 $)Y// (3333$(9>333zz$''''''''%!344 Oty$-9MNNNNNNNN ! s>AA EA5E EAEE4EEEE)Nr r )__name__ __module__ __qualname____doc__rr*r6rrrr r >sY=O!*////"!!!!!rr c,eZdZdZfdZfdZxZS) ErrorStringz3 Safely report exception type and message. cz|jjjdtt|SNz: )r __class__r7superr<r*rr?s rr*zErrorString.__str__s:9.777 d33;;===? ?rcz|jjjdtt|Sr>)rr?r7r@r<r6rAs rr6zErrorString.__unicode__s< I/888!+t44@@BBBD Dr)r7r8r9r:r*r6 __classcell__)r?s@rr<r<sd?????DDDDDDDDDrr<c,eZdZdZ ddZdZdZdS) ErrorOutputz Wrapper class for file-like error streams with failsafe de- and encoding of `str`, `bytes`, `unicode` and `Exception` instances. Nr r c~| tj}nt|sd}not|trt |d}nIt|t r4t |tjd}||_ |pt|ddptpd|_ ||_ ||_ dS)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. NFwr r)r'stderrr"ropenr&r)getfilesystemencodingstreamrrr rr)rrKr rrs rrzErrorOutput.__init__s >ZFF KFF  $ $ K&#&&FF  ( ( K&--(A(C(CDDcJJF +!7WVZ%F%F7+7/6 ,.%.%%rc |jdurdSt|tr.tt ||j|j|j} |j|dS#t$r<|j| |j|jYdSt$rt|tr;|j| |j|jYdS|jtj tjfvr"|jj|YdS|jt||j|jYdSwxYw)z Write `data` to self.stream. Ignore, if self.stream is False. `data` can be a `string`, `unicode`, or `Exception` instance. FN)rKr"r#r&r r rrwriter!r) TypeErrorr'rHstdoutbuffer)rrs rrMzErrorOutput.writes ;%   F dI & & =:dDM&*&:&*&:<<==D A K  d # # # # #! P P P K  dkk$-9MNN O O O O O O A A A$((  !!$++dm.2.B#D#DEEE{sz3:666 "((...... !!'$ *.*>#@#@AAAAAA As&A,,AF1AF >F 3FFc|jtjtjfvrdS |jdS#t $rYdSwxYw)z Close the error-output stream. Ignored if the stream is` sys.stderr` or `sys.stdout` or has no close() method. N)rKr'rOrHcloseAttributeError)rs rrRzErrorOutput.closes` ;3:sz2 2 2 F  K           DD s> A  A )NNr r )r7r8r9r:rrMrRrrrrErEs_ .2!3!*!&!&!&!&FAAA6     rrE)r:r'warnings docutils.iorrwarnDeprecationWarningr(rr&r r<rErrrrXs   D ;;;;;;  E!Q0000 vG????????D D D D D D* D D DQQQQQQQQQQr