Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/future/utils/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@s�dZddlZddlZddlmZdZd�Zd�Zejrae Z
d�ZneZ
e Zd�Z
d efd
��YZd�Zd�Zd
�Zd�ZdZed�Zed�Zeje�jZd�Zedkr�ndS(s�
This is Victor Stinner's pure-Python implementation of PEP 383: the
"surrogateescape" error
handler of Python 3.
Source: misc/python/surrogateescape.py in https://bitbucket.org/haypo/misc
i����N(tutilstsurrogateescapecCstjr
|S|jd�SdS(Ntunicode_escape(RtPY3tdecode(ttext((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pytus cCstjr|jd�S|SdS(Ntlatin1(RRtencode(tdata((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pytbs
cCs
t|f�S(N(tbytes(tcode((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pyt<lambda>#scCs�|j|j|j!}yFt|t�r7t|�}n$t|t�rUt|�}n|�Wntk
ru|�nX||jfS(s�
Pure Python implementation of the PEP 383: the
"surrogateescape" error
handler of Python 3. Undecodable bytes will be replaced by a Unicode
character U+DCxx on decoding, and these are translated into the
original bytes on encoding.
( tobjecttstarttendt
isinstancetUnicodeDecodeErrortreplace_surrogate_decodetUnicodeEncodeErrortreplace_surrogate_encodetNotASurrogateError(texctmystringtdecoded((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pytsurrogateescape_handler(s
RcBseZRS((t__name__t
__module__(((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pyRCscCs�g}x�|D]�}t|�}d|ko6dknsDt�nd|ko[dknrz|jt|d��q
|dkr�|jt|d��q
t�q
Wt�j|�S(s�
Returns a (unicode) string, not the more logical bytes, because the
codecs
register_error functionality expects this.
i�i��i�i�(tordRtappendt_unichrtstrtjoin(RRtchR((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pyRGs
cCs�g}x�|D]�}t|t�r+|}nt|�}d|koNdknrm|jtd|��q
|dkr�|jt|��q
t�q
Wt�j|�S(s$
Returns a (unicode) string
i�i�i�i(RtintRRRRR
R!(tmybytesRR"R((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pyRds
c Cs�tdkr�g}x�t|�D]�\}}t|�}|dkrRt|�}nKd|koidknr�t|d�}ntt|||dd��|j|�qWt�j|�Stdkr�g}x�t|�D]�\}}t|�}d |kod
knrld|ko(dknrMt|d�}|j|�q�tt|||dd��q�|jd�}|j|�q�Wt�j|�S|jtt �SdS(Ntasciii�i��i��i�isordinal
not in range(128)sutf-8i�i��ssurrogates not allowed(
tFS_ENCODINGt enumerateRt bytes_chrRRRR!Rt FS_ERRORS(tfntencodedtindexR"Rtch_utf8((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pytencodefilename}s8
cCs|jtt�S(N(RR&R)(R*((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pytdecodefilename�sR%s[abc�]s[abc\udcff]cCsFtjr
dSytjt�Wn!tk
rAtjtt�nXdS(sH
Registers the surrogateescape error handler on Python 2 (only)
N(RRtcodecstlookup_errorR)tLookupErrortregister_errorR(((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pytregister_surrogateescape�s
t__main__(t__doc__R0tsystfutureRR)RR
RtchrRR(tunichrRt ExceptionRRRR.R/R&R*R+tlookuptnameR4R(((s@/usr/lib/python2.7/site-packages/future/utils/surrogateescape.pyt<module>s0 '