/snap/core18/2979/usr/lib/python3.6/__pycache__
NameSizeModeActions
abc.cpython-36.pyc75150644editdlrm
aifc.cpython-36.pyc259430644editdlrm
antigravity.cpython-36.pyc7790644editdlrm
argparse.cpython-36.pyc604560644editdlrm
ast.cpython-36.pyc117040644editdlrm
asynchat.cpython-36.pyc68150644editdlrm
asyncore.cpython-36.pyc158380644editdlrm
base64.cpython-36.pyc170590644editdlrm
bdb.cpython-36.pyc170330644editdlrm
binhex.cpython-36.pyc120860644editdlrm
bisect.cpython-36.pyc26760644editdlrm
bz2.cpython-36.pyc112820644editdlrm
calendar.cpython-36.pyc258820644editdlrm
cgi.cpython-36.pyc284160644editdlrm
cgitb.cpython-36.pyc100800644editdlrm
chunk.cpython-36.pyc49000644editdlrm
cmd.cpython-36.pyc125750644editdlrm
code.cpython-36.pyc98360644editdlrm
codecs.cpython-36.pyc339000644editdlrm
codeop.cpython-36.pyc62700644editdlrm
colorsys.cpython-36.pyc33110644editdlrm
compileall.cpython-36.pyc82780644editdlrm
configparser.cpython-36.pyc452440644editdlrm
contextlib.cpython-36.pyc111580644editdlrm
copy.cpython-36.pyc70790644editdlrm
copyreg.cpython-36.pyc42440644editdlrm
cProfile.cpython-36.pyc42940644editdlrm
crypt.cpython-36.pyc22420644editdlrm
csv.cpython-36.pyc118550644editdlrm
datetime.cpython-36.pyc545110644editdlrm
decimal.cpython-36.pyc3510644editdlrm
difflib.cpython-36.pyc596420644editdlrm
dis.cpython-36.pyc141810644editdlrm
doctest.cpython-36.pyc755890644editdlrm
dummy_threading.cpython-36.pyc11020644editdlrm
enum.cpython-36.pyc234530644editdlrm
filecmp.cpython-36.pyc83050644editdlrm
fileinput.cpython-36.pyc131520644editdlrm
fnmatch.cpython-36.pyc28740644editdlrm
formatter.cpython-36.pyc175790644editdlrm
fractions.cpython-36.pyc184260644editdlrm
ftplib.cpython-36.pyc283570644editdlrm
functools.cpython-36.pyc240620644editdlrm
genericpath.cpython-36.pyc37260644editdlrm
getopt.cpython-36.pyc62170644editdlrm
getpass.cpython-36.pyc41770644editdlrm
gettext.cpython-36.pyc143060644editdlrm
glob.cpython-36.pyc42590644editdlrm
gzip.cpython-36.pyc162260644editdlrm
hashlib.cpython-36.pyc66920644editdlrm
heapq.cpython-36.pyc142920644editdlrm
hmac.cpython-36.pyc48360644editdlrm
imaplib.cpython-36.pyc421380644editdlrm
imghdr.cpython-36.pyc41500644editdlrm
imp.cpython-36.pyc96960644editdlrm
inspect.cpython-36.pyc797390644editdlrm
io.cpython-36.pyc33870644editdlrm
ipaddress.cpython-36.pyc623860644editdlrm
keyword.cpython-36.pyc17650644editdlrm
linecache.cpython-36.pyc37780644editdlrm
locale.cpython-36.pyc340300644editdlrm
lzma.cpython-36.pyc119920644editdlrm
macpath.cpython-36.pyc56410644editdlrm
macurl2path.cpython-36.pyc18670644editdlrm
mailbox.cpython-36.pyc637520644editdlrm
mailcap.cpython-36.pyc72090644editdlrm
mimetypes.cpython-36.pyc155530644editdlrm
modulefinder.cpython-36.pyc153660644editdlrm
netrc.cpython-36.pyc38360644editdlrm
nntplib.cpython-36.pyc337800644editdlrm
ntpath.cpython-36.pyc131900644editdlrm
nturl2path.cpython-36.pyc14990644editdlrm
numbers.cpython-36.pyc121420644editdlrm
opcode.cpython-36.pyc54130644editdlrm
operator.cpython-36.pyc139130644editdlrm
optparse.cpython-36.pyc480540644editdlrm
os.cpython-36.pyc296280644editdlrm
pathlib.cpython-36.pyc420070644editdlrm
pdb.cpython-36.pyc460940644editdlrm
pickle.cpython-36.pyc426910644editdlrm
pickletools.cpython-36.pyc660200644editdlrm
pipes.cpython-36.pyc78080644editdlrm
pkgutil.cpython-36.pyc162610644editdlrm
platform.cpython-36.pyc291970644editdlrm
plistlib.cpython-36.pyc280550644editdlrm
poplib.cpython-36.pyc133290644editdlrm
posixpath.cpython-36.pyc104560644editdlrm
pprint.cpython-36.pyc158240644editdlrm
profile.cpython-36.pyc139010644editdlrm
pstats.cpython-36.pyc218570644editdlrm
pty.cpython-36.pyc38610644editdlrm
pyclbr.cpython-36.pyc83650644editdlrm
pydoc.cpython-36.pyc837750644editdlrm
py_compile.cpython-36.pyc65440644editdlrm
queue.cpython-36.pyc87550644editdlrm
quopri.cpython-36.pyc57730644editdlrm
random.cpython-36.pyc193300644editdlrm
re.cpython-36.pyc140580644editdlrm
reprlib.cpython-36.pyc54000644editdlrm
rlcompleter.cpython-36.pyc57800644editdlrm
runpy.cpython-36.pyc79820644editdlrm
sched.cpython-36.pyc65640644editdlrm
secrets.cpython-36.pyc21620644editdlrm
selectors.cpython-36.pyc176970644editdlrm
shelve.cpython-36.pyc94580644editdlrm
shlex.cpython-36.pyc69700644editdlrm
shutil.cpython-36.pyc307040644editdlrm
signal.cpython-36.pyc25150644editdlrm
site.cpython-36.pyc165600644editdlrm
sitecustomize.cpython-36.pyc2120644editdlrm
smtpd.cpython-36.pyc266830644editdlrm
smtplib.cpython-36.pyc353400644editdlrm
sndhdr.cpython-36.pyc69130644editdlrm
socket.cpython-36.pyc220130644editdlrm
socketserver.cpython-36.pyc242500644editdlrm
sre_compile.cpython-36.pyc102780644editdlrm
sre_constants.cpython-36.pyc59720644editdlrm
sre_parse.cpython-36.pyc203580644editdlrm
ssl.cpython-36.pyc369390644editdlrm
stat.cpython-36.pyc38510644editdlrm
statistics.cpython-36.pyc181740644editdlrm
string.cpython-36.pyc79640644editdlrm
stringprep.cpython-36.pyc100300644editdlrm
struct.cpython-36.pyc3120644editdlrm
subprocess.cpython-36.pyc354850644editdlrm
sunau.cpython-36.pyc169380644editdlrm
symbol.cpython-36.pyc25170644editdlrm
symtable.cpython-36.pyc104280644editdlrm
sysconfig.cpython-36.pyc159160644editdlrm
tabnanny.cpython-36.pyc69750644editdlrm
tarfile.cpython-36.pyc630850644editdlrm
telnetlib.cpython-36.pyc180970644editdlrm
tempfile.cpython-36.pyc253090644editdlrm
textwrap.cpython-36.pyc136840644editdlrm
this.cpython-36.pyc12650644editdlrm
threading.cpython-36.pyc372340644editdlrm
timeit.cpython-36.pyc116030644editdlrm
token.cpython-36.pyc33200644editdlrm
tokenize.cpython-36.pyc186470644editdlrm
trace.cpython-36.pyc194950644editdlrm
traceback.cpython-36.pyc196460644editdlrm
tracemalloc.cpython-36.pyc172290644editdlrm
tty.cpython-36.pyc10720644editdlrm
turtle.cpython-36.pyc1317510644editdlrm
types.cpython-36.pyc82010644editdlrm
typing.cpython-36.pyc733060644editdlrm
uu.cpython-36.pyc34980644editdlrm
uuid.cpython-36.pyc209180644editdlrm
warnings.cpython-36.pyc132580644editdlrm
wave.cpython-36.pyc178850644editdlrm
weakref.cpython-36.pyc191430644editdlrm
webbrowser.cpython-36.pyc157970644editdlrm
xdrlib.cpython-36.pyc83020644editdlrm
zipapp.cpython-36.pyc55340644editdlrm
zipfile.cpython-36.pyc497280644editdlrm
_bootlocale.cpython-36.pyc9800644editdlrm
_collections_abc.cpython-36.pyc287970644editdlrm
_compat_pickle.cpython-36.pyc65660644editdlrm
_compression.cpython-36.pyc41040644editdlrm
_dummy_thread.cpython-36.pyc48510644editdlrm
_markupbase.cpython-36.pyc79910644editdlrm
_osx_support.cpython-36.pyc96840644editdlrm
_pydecimal.cpython-36.pyc1634020644editdlrm
_pyio.cpython-36.pyc713860644editdlrm
_sitebuiltins.cpython-36.pyc34350644editdlrm
_strptime.cpython-36.pyc159630644editdlrm
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc187790644editdlrm
_threading_local.cpython-36.pyc64250644editdlrm
_weakrefset.cpython-36.pyc78280644editdlrm
__future__.cpython-36.pyc41670644editdlrm
__phello__.foo.cpython-36.pyc1190644editdlrm
Edit: /snap/core18/2979/usr/lib/python3.6/__pycache__/codecs.cpython-36.pyc (33900B)
3 Nqi:@sdZddlZddlZy ddlTWn.ek rNZzedeWYddZ[XnXddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0g,Zd1Zd2Z Z d3Z Z d4Z d5Zejd6kre ZZe Zn e ZZeZe Ze Ze ZeZGd7ddeZGd8ddZGd9ddeZGd:d;d;eZGdd>eZGd?ddeZGd@ddeZ GdAddZ!GdBddZ"d\dFdZ#d]dGdZ$dHdZ%dId Z&dJd!Z'dKd"Z(dLd#Z)dMd$Z*d^dNd'Z+d_dOd(Z,dPdQZ-dRdSZ.y4e/dDZ0e/dTZ1e/dUZ2e/dVZ3e/dWZ4e/dXZ5Wn.e6k r`dZ0dZ1dZ2dZ3dZ4dZ5YnXdZ7e7rtddl8Z8e9dYkre$ej:dZd[e_:e$ej;d[dZe_;dS)`z codecs -- Python Codec Registry, API and helpers. Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. N)*z%Failed to load the builtin codecs: %sregisterlookupopen EncodedFileBOMBOM_BEBOM_LEBOM32_BEBOM32_LEBOM64_BEBOM64_LEBOM_UTF8 BOM_UTF16 BOM_UTF16_LE BOM_UTF16_BE BOM_UTF32 BOM_UTF32_LE BOM_UTF32_BE CodecInfoCodecIncrementalEncoderIncrementalDecoder StreamReader StreamWriterStreamReaderWriter StreamRecoder getencoder getdecodergetincrementalencodergetincrementaldecoder getreader getwriterencodedecode iterencode iterdecode strict_errors ignore_errorsreplace_errorsxmlcharrefreplace_errorsbackslashreplace_errorsnamereplace_errorsregister_error lookup_errorssssslittlec@s,eZdZdZdZd ddddZddZdS) rz0Codec details when looking up the codec registryTN)_is_text_encodingc CsPtj|||||f} || _|| _|| _|| _|| _|| _|| _|dk rL|| _ | S)N) tuple__new__namer#r$incrementalencoderincrementaldecoder streamwriter streamreaderr0) clsr#r$r7r6r4r5r3r0selfr:/usr/lib/python3.6/codecs.pyr2]szCodecInfo.__new__cCsd|jj|jj|jt|fS)Nz%<%s.%s object for encoding %s at %#x>) __class__ __module__ __qualname__r3id)r9r:r:r;__repr__ls zCodecInfo.__repr__)NNNNN)__name__r=r>__doc__r0r2r@r:r:r:r;rRs  c@s$eZdZdZdddZd ddZdS) ra9 Defines the interface for stateless encoders/decoders. The .encode()/.decode() methods may use different error handling schemes by providing the errors argument. These string values are predefined: 'strict' - raise a ValueError error (or a subclass) 'ignore' - ignore the character and continue with the next 'replace' - replace with a suitable replacement character; Python will use the official U+FFFD REPLACEMENT CHARACTER for the builtin Unicode codecs on decoding and '?' on encoding. 'surrogateescape' - replace with private code points U+DCnn. 'xmlcharrefreplace' - Replace with the appropriate XML character reference (only for encoding). 'backslashreplace' - Replace with backslashed escape sequences. 'namereplace' - Replace with \N{...} escape sequences (only for encoding). The set of allowed values can be extended via register_error. strictcCstdS)a# Encodes the object input and returns a tuple (output object, length consumed). errors defines the error handling to apply. It defaults to 'strict' handling. The method may not store state in the Codec instance. Use StreamWriter for codecs which have to keep state in order to make encoding efficient. The encoder must be able to handle zero length input and return an empty object of the output object type in this situation. N)NotImplementedError)r9inputerrorsr:r:r;r#sz Codec.encodecCstdS)a Decodes the object input and returns a tuple (output object, length consumed). input must be an object which provides the bf_getreadbuf buffer slot. Python strings, buffer objects and memory mapped files are examples of objects providing this slot. errors defines the error handling to apply. It defaults to 'strict' handling. The method may not store state in the Codec instance. Use StreamReader for codecs which have to keep state in order to make decoding efficient. The decoder must be able to handle zero length input and return an empty object of the output object type in this situation. N)rD)r9rErFr:r:r;r$sz Codec.decodeN)rC)rC)rAr=r>rBr#r$r:r:r:r;rqs c@s<eZdZdZdddZdddZdd Zd d Zd d ZdS)rz An IncrementalEncoder encodes an input in multiple steps. The input can be passed piece by piece to the encode() method. The IncrementalEncoder remembers the state of the encoding process between calls to encode(). rCcCs||_d|_dS)z Creates an IncrementalEncoder instance. The IncrementalEncoder may use different error handling schemes by providing the errors keyword argument. See the module docstring for a list of possible values. N)rFbuffer)r9rFr:r:r;__init__szIncrementalEncoder.__init__FcCstdS)zA Encodes input and returns the resulting object. N)rD)r9rEfinalr:r:r;r#szIncrementalEncoder.encodecCsdS)z: Resets the encoder to the initial state. Nr:)r9r:r:r;resetszIncrementalEncoder.resetcCsdS)z: Return the current state of the encoder. rr:)r9r:r:r;getstateszIncrementalEncoder.getstatecCsdS)zl Set the current state of the encoder. state must have been returned by getstate(). Nr:)r9stater:r:r;setstateszIncrementalEncoder.setstateN)rC)F) rAr=r>rBrIr#rKrLrNr:r:r:r;rs  c@sDeZdZdZdddZddZddd Zd d Zd d ZddZ dS)BufferedIncrementalEncoderz This subclass of IncrementalEncoder can be used as the baseclass for an incremental encoder if the encoder must keep some of the output in a buffer between calls to encode(). rCcCstj||d|_dS)NrG)rrIrH)r9rFr:r:r;rIs z#BufferedIncrementalEncoder.__init__cCstdS)N)rD)r9rErFrJr:r:r;_buffer_encodesz)BufferedIncrementalEncoder._buffer_encodeFcCs0|j|}|j||j|\}}||d|_|S)N)rHrPrF)r9rErJdataresultconsumedr:r:r;r#s z!BufferedIncrementalEncoder.encodecCstj|d|_dS)NrG)rrKrH)r9r:r:r;rKs z BufferedIncrementalEncoder.resetcCs |jpdS)Nr)rH)r9r:r:r;rLsz#BufferedIncrementalEncoder.getstatecCs|pd|_dS)NrG)rH)r9rMr:r:r;rNsz#BufferedIncrementalEncoder.setstateN)rC)F) rAr=r>rBrIrPr#rKrLrNr:r:r:r;rOs  rOc@s<eZdZdZdddZdddZdd Zd d Zd d ZdS)rz An IncrementalDecoder decodes an input in multiple steps. The input can be passed piece by piece to the decode() method. The IncrementalDecoder remembers the state of the decoding process between calls to decode(). rCcCs ||_dS)z Create an IncrementalDecoder instance. The IncrementalDecoder may use different error handling schemes by providing the errors keyword argument. See the module docstring for a list of possible values. N)rF)r9rFr:r:r;rIszIncrementalDecoder.__init__FcCstdS)z@ Decode input and returns the resulting object. N)rD)r9rErJr:r:r;r$ szIncrementalDecoder.decodecCsdS)z9 Reset the decoder to the initial state. Nr:)r9r:r:r;rKszIncrementalDecoder.resetcCsdS)a  Return the current state of the decoder. This must be a (buffered_input, additional_state_info) tuple. buffered_input must be a bytes object containing bytes that were passed to decode() that have not yet been converted. additional_state_info must be a non-negative integer representing the state of the decoder WITHOUT yet having processed the contents of buffered_input. In the initial state and after reset(), getstate() must return (b"", 0). r)rTrr:)r9r:r:r;rLs zIncrementalDecoder.getstatecCsdS)z Set the current state of the decoder. state must have been returned by getstate(). The effect of setstate((b"", 0)) must be equivalent to reset(). Nr:)r9rMr:r:r;rN&szIncrementalDecoder.setstateN)rC)F) rAr=r>rBrIr$rKrLrNr:r:r:r;rs  c@sDeZdZdZdddZddZddd Zd d Zd d ZddZ dS)BufferedIncrementalDecoderz This subclass of IncrementalDecoder can be used as the baseclass for an incremental decoder if the decoder must be able to handle incomplete byte sequences. rCcCstj||d|_dS)NrT)rrIrH)r9rFr:r:r;rI4s z#BufferedIncrementalDecoder.__init__cCstdS)N)rD)r9rErFrJr:r:r;_buffer_decode9sz)BufferedIncrementalDecoder._buffer_decodeFcCs0|j|}|j||j|\}}||d|_|S)N)rHrVrF)r9rErJrQrRrSr:r:r;r$>s z!BufferedIncrementalDecoder.decodecCstj|d|_dS)NrT)rrKrH)r9r:r:r;rKFs z BufferedIncrementalDecoder.resetcCs |jdfS)Nr)rH)r9r:r:r;rLJsz#BufferedIncrementalDecoder.getstatecCs|d|_dS)Nr)rH)r9rMr:r:r;rNNsz#BufferedIncrementalDecoder.setstateN)rC)F) rAr=r>rBrIrVr$rKrLrNr:r:r:r;rU.s  rUc@sTeZdZdddZddZddZdd Zdd d Zefd dZ ddZ ddZ dS)rrCcCs||_||_dS)aw Creates a StreamWriter instance. stream must be a file-like object open for writing. The StreamWriter may use different error handling schemes by providing the errors keyword argument. These parameters are predefined: 'strict' - raise a ValueError (or a subclass) 'ignore' - ignore the character and continue with the next 'replace'- replace with a suitable replacement character 'xmlcharrefreplace' - Replace with the appropriate XML character reference. 'backslashreplace' - Replace with backslashed escape sequences. 'namereplace' - Replace with \N{...} escape sequences. The set of allowed parameter values can be extended via register_error. N)streamrF)r9rWrFr:r:r;rI[szStreamWriter.__init__cCs"|j||j\}}|jj|dS)z> Writes the object's contents encoded to self.stream. N)r#rFrWwrite)r9objectrQrSr:r:r;rXtszStreamWriter.writecCs|jdj|dS)z[ Writes the concatenated list of strings to the stream using .write(). rGN)rXjoin)r9listr:r:r; writelines{szStreamWriter.writelinescCsdS)a5 Flushes and resets the codec buffers used for keeping state. Calling this method should ensure that the data on the output is put into a clean state, that allows appending of new fresh data without having to rescan the whole stream to recover state. Nr:)r9r:r:r;rKs zStreamWriter.resetrcCs*|jj|||dkr&|dkr&|jdS)Nr)rWseekrK)r9offsetwhencer:r:r;r]szStreamWriter.seekcCs ||j|S)z? Inherit all other methods from the underlying stream. )rW)r9r3getattrr:r:r; __getattr__szStreamWriter.__getattr__cCs|S)Nr:)r9r:r:r; __enter__szStreamWriter.__enter__cCs|jjdS)N)rWclose)r9typevaluetbr:r:r;__exit__szStreamWriter.__exit__N)rC)r) rAr=r>rIrXr\rKr]r`rarbrgr:r:r:r;rYs   c@seZdZeZdddZd ddZd#dd Zd$d d Zd%ddZ ddZ d&ddZ ddZ ddZ efddZddZddZd S)'rrCcCs.||_||_d|_|j|_|j|_d|_dS)a Creates a StreamReader instance. stream must be a file-like object open for reading. The StreamReader may use different error handling schemes by providing the errors keyword argument. These parameters are predefined: 'strict' - raise a ValueError (or a subclass) 'ignore' - ignore the character and continue with the next 'replace'- replace with a suitable replacement character 'backslashreplace' - Replace with backslashed escape sequences; The set of allowed parameter values can be extended via register_error. rTN)rWrF bytebuffercharbuffertype_empty_charbuffer charbuffer linebuffer)r9rWrFr:r:r;rIs  zStreamReader.__init__cCstdS)N)rD)r9rErFr:r:r;r$szStreamReader.decodeFc CsL|jr|jj|j|_d|_|dkr(|}x|dkrBt|j|krBP|dkrV|jj}n |jj|}|j|}|srPy|j||j \}}Wn`t k r}zD|r|j|d|j |j \}}|j dd} t| dkr؂nWYdd}~XnX||d|_|j|7_|s*Pq*W|dkr*|j} |j|_n|jd|} |j|d|_| S)a Decodes data from the stream self.stream and returns the resulting object. chars indicates the number of decoded code points or bytes to return. read() will never return more data than requested, but it might return less, if there is not enough available. size indicates the approximate maximum number of decoded bytes or code points to read for decoding. The decoder can modify this setting as appropriate. The default value -1 indicates to read and decode as much as possible. size is intended to prevent having to decode huge files in one step. If firstline is true, and a UnicodeDecodeError happens after the first line terminator in the input only the first line will be returned, the rest of the input will be kept until the next call to read(). The method should use a greedy read strategy, meaning that it should read as much data as is allowed within the definition of the encoding and the given size, e.g. if optional encoding endings or state markers are available on the stream, these should be read too. NrT)keependsrm) rlrjrZrklenrWreadrhr$rFUnicodeDecodeErrorstart splitlines) r9sizechars firstlinenewdatarQnewchars decodedbytesexclinesrRr:r:r;rpsD       zStreamReader.readNTc Cs|jrP|jd}|jd=t|jdkr8|jd|_d|_|sL|jddd}|S|pVd}|j}xr|j|dd}|rt|tr|jd st|t r|jd r||jddd 7}||7}|jdd}|rt|dkr:|d}|d=t|dkr|d|j7<||_d|_n|d|j|_|s8|jddd}P|d}|djddd}||kr|jj |dd|j|_|r|}n|}P| s|dk r|r| r|jddd}P|d krb|d 9}qbW|S)z Read one line from the input stream and return the decoded data. size, if given, is passed as size argument to the read() method. rrmNF)rnHT)rv  )rtrui@) rlrorkrsrjrp isinstancestrendswithbytesrZ) r9rtrnlinereadsizerQr{ line0withendline0withoutendr:r:r;readlines^       zStreamReader.readlinecCs|j}|j|S)aS Read all lines available on the input stream and return them as a list. Line breaks are implemented using the codec's decoder method and are included in the list entries. sizehint, if given, is ignored since there is no efficient way to finding the true end-of-line. )rprs)r9sizehintrnrQr:r:r; readlines]s zStreamReader.readlinescCsd|_|j|_d|_dS)z Resets the codec buffers used for keeping state. Note that no stream repositioning should take place. This method is primarily intended to be able to recover from decoding errors. rTN)rhrjrkrl)r9r:r:r;rKls zStreamReader.resetrcCs|jj|||jdS)zp Set the input stream's current position. Resets the codec buffers used for keeping state. N)rWr]rK)r9r^r_r:r:r;r]yszStreamReader.seekcCs|j}|r|StdS)z4 Return the next decoded line from the input stream.N)r StopIteration)r9rr:r:r;__next__szStreamReader.__next__cCs|S)Nr:)r9r:r:r;__iter__szStreamReader.__iter__cCs ||j|S)z? Inherit all other methods from the underlying stream. )rW)r9r3r`r:r:r;raszStreamReader.__getattr__cCs|S)Nr:)r9r:r:r;rbszStreamReader.__enter__cCs|jjdS)N)rWrc)r9rdrerfr:r:r;rgszStreamReader.__exit__)rC)rCrr)rrF)NT)NT)r)rAr=r>rrirIr$rprrrKr]rrr`rarbrgr:r:r:r;rs   P K   c@seZdZdZdZd!ddZd#ddZd$d d Zd%d d ZddZ ddZ ddZ ddZ ddZ d&ddZefddZddZdd Zd S)'ra StreamReaderWriter instances allow wrapping streams which work in both read and write modes. The design is such that one can use the factory functions returned by the codec.lookup() function to construct the instance. unknownrCcCs(||_||||_||||_||_dS)aR Creates a StreamReaderWriter instance. stream must be a Stream-like object. Reader, Writer must be factory functions or classes providing the StreamReader, StreamWriter interface resp. Error handling is done in the same way as defined for the StreamWriter/Readers. N)rWreaderwriterrF)r9rWReaderWriterrFr:r:r;rIs   zStreamReaderWriter.__init__rmcCs |jj|S)N)rrp)r9rtr:r:r;rpszStreamReaderWriter.readNcCs |jj|S)N)rr)r9rtr:r:r;rszStreamReaderWriter.readlinecCs |jj|S)N)rr)r9rr:r:r;rszStreamReaderWriter.readlinescCs t|jS)z4 Return the next decoded line from the input stream.)nextr)r9r:r:r;rszStreamReaderWriter.__next__cCs|S)Nr:)r9r:r:r;rszStreamReaderWriter.__iter__cCs |jj|S)N)rrX)r9rQr:r:r;rXszStreamReaderWriter.writecCs |jj|S)N)rr\)r9r[r:r:r;r\szStreamReaderWriter.writelinescCs|jj|jjdS)N)rrKr)r9r:r:r;rKs zStreamReaderWriter.resetrcCs6|jj|||jj|dkr2|dkr2|jjdS)Nr)rWr]rrKr)r9r^r_r:r:r;r]s zStreamReaderWriter.seekcCs ||j|S)z? Inherit all other methods from the underlying stream. )rW)r9r3r`r:r:r;raszStreamReaderWriter.__getattr__cCs|S)Nr:)r9r:r:r;rbszStreamReaderWriter.__enter__cCs|jjdS)N)rWrc)r9rdrerfr:r:r;rgszStreamReaderWriter.__exit__)rCr)r)N)N)r)rAr=r>rBencodingrIrprrrrrXr\rKr]r`rarbrgr:r:r:r;rs       c@seZdZdZdZdZdddZd ddZd!d d Zd"d d Z ddZ ddZ ddZ ddZ ddZefddZddZddZd S)#raB StreamRecoder instances translate data from one encoding to another. They use the complete set of APIs returned by the codecs.lookup() function to implement their task. Data written to the StreamRecoder is first decoded into an intermediate format (depending on the "decode" codec) and then written to the underlying stream using an instance of the provided Writer class. In the other direction, data is read from the underlying stream using a Reader instance and then encoded and returned to the caller. rrCcCs4||_||_||_||||_||||_||_dS)a Creates a StreamRecoder instance which implements a two-way conversion: encode and decode work on the frontend (the data visible to .read() and .write()) while Reader and Writer work on the backend (the data in stream). You can use these objects to do transparent transcodings from e.g. latin-1 to utf-8 and back. stream must be a file-like object. encode and decode must adhere to the Codec interface; Reader and Writer must be factory functions or classes providing the StreamReader and StreamWriter interfaces resp. Error handling is done in the same way as defined for the StreamWriter/Readers. N)rWr#r$rrrF)r9rWr#r$rrrFr:r:r;rIs   zStreamRecoder.__init__rmcCs"|jj|}|j||j\}}|S)N)rrpr#rF)r9rtrQ bytesencodedr:r:r;rp"s zStreamRecoder.readNcCs6|dkr|jj}n |jj|}|j||j\}}|S)N)rrr#rF)r9rtrQrr:r:r;r(s   zStreamRecoder.readlinecCs(|jj}|j||j\}}|jddS)NT)rn)rrpr#rFrs)r9rrQrr:r:r;r1s zStreamRecoder.readlinescCs t|j}|j||j\}}|S)z4 Return the next decoded line from the input stream.)rrr#rF)r9rQrr:r:r;r7s zStreamRecoder.__next__cCs|S)Nr:)r9r:r:r;r>szStreamRecoder.__iter__cCs|j||j\}}|jj|S)N)r$rFrrX)r9rQ bytesdecodedr:r:r;rXAszStreamRecoder.writecCs(dj|}|j||j\}}|jj|S)NrG)rZr$rFrrX)r9r[rQrr:r:r;r\Fs zStreamRecoder.writelinescCs|jj|jjdS)N)rrKr)r9r:r:r;rKLs zStreamRecoder.resetcCs ||j|S)z? Inherit all other methods from the underlying stream. )rW)r9r3r`r:r:r;raQszStreamRecoder.__getattr__cCs|S)Nr:)r9r:r:r;rbXszStreamRecoder.__enter__cCs|jjdS)N)rWrc)r9rdrerfr:r:r;rg[szStreamRecoder.__exit__)rCr)r)N)N)rAr=r>rB data_encoding file_encodingrIrprrrrrXr\rKr`rarbrgr:r:r:r;rs    rrCrmcCsV|dk rd|kr|d}tj|||}|dkr2|St|}t||j|j|}||_|S)a> Open an encoded file using the given mode and return a wrapped version providing transparent encoding/decoding. Note: The wrapped version will only accept the object format defined by the codecs, i.e. Unicode objects for most builtin codecs. Output is also codec dependent and will usually be Unicode as well. Underlying encoded files are always opened in binary mode. The default file mode is 'r', meaning to open the file in read mode. encoding specifies the encoding which is to be used for the file. errors may be given to define the error handling. It defaults to 'strict' which causes ValueErrors to be raised in case an encoding error occurs. buffering has the same meaning as for the builtin open() API. It defaults to line buffered. The returned wrapped file object provides an extra attribute .encoding which allows querying the used encoding. This attribute is only available if an encoding was specified as parameter. Nb)builtinsrrrr7r6r)filenamemoderrF bufferingfileinfosrwr:r:r;r`scCsF|dkr |}t|}t|}t||j|j|j|j|}||_||_|S)a Return a wrapped version of file which provides transparent encoding translation. Data written to the wrapped file is decoded according to the given data_encoding and then encoded to the underlying file using file_encoding. The intermediate data type will usually be Unicode but depends on the specified codecs. Bytes read from the file are decoded using file_encoding and then passed back to the caller encoded using data_encoding. If file_encoding is not given, it defaults to data_encoding. errors may be given to define the error handling. It defaults to 'strict' which causes ValueErrors to be raised in case an encoding error occurs. The returned wrapped file object provides two extra attributes .data_encoding and .file_encoding which reflect the given parameters of the same name. The attributes can be used for introspection by Python programs. N)rrr#r$r7r6rr)rrrrF data_info file_infosrr:r:r;rs cCs t|jS)z Lookup up the codec for the given encoding and return its encoder function. Raises a LookupError in case the encoding cannot be found. )rr#)rr:r:r;rscCs t|jS)z Lookup up the codec for the given encoding and return its decoder function. Raises a LookupError in case the encoding cannot be found. )rr$)rr:r:r;rscCst|j}|dkrt||S)z Lookup up the codec for the given encoding and return its IncrementalEncoder class or factory function. Raises a LookupError in case the encoding cannot be found or the codecs doesn't provide an incremental encoder. N)rr4 LookupError)rencoderr:r:r;rs cCst|j}|dkrt||S)z Lookup up the codec for the given encoding and return its IncrementalDecoder class or factory function. Raises a LookupError in case the encoding cannot be found or the codecs doesn't provide an incremental decoder. N)rr5r)rdecoderr:r:r;r s cCs t|jS)z Lookup up the codec for the given encoding and return its StreamReader class or factory function. Raises a LookupError in case the encoding cannot be found. )rr7)rr:r:r;r!scCs t|jS)z Lookup up the codec for the given encoding and return its StreamWriter class or factory function. Raises a LookupError in case the encoding cannot be found. )rr6)rr:r:r;r"scksLt||f|}x |D]}|j|}|r|VqW|jdd}|rH|VdS)z Encoding iterator. Encodes the input strings from the iterator using an IncrementalEncoder. errors and kwargs are passed through to the IncrementalEncoder constructor. rGTN)rr#)iteratorrrFkwargsrrEoutputr:r:r;r%s     cksLt||f|}x |D]}|j|}|r|VqW|jdd}|rH|VdS)z Decoding iterator. Decodes the input strings from the iterator using an IncrementalDecoder. errors and kwargs are passed through to the IncrementalDecoder constructor. rTTN)r r$)rrrFrrrErr:r:r;r&s     cCsdd|DS)z make_identity_dict(rng) -> dict Return a dictionary where elements of the rng sequence are mapped to themselves. cSsi|] }||qSr:r:).0ir:r:r; "sz&make_identity_dict..r:)rngr:r:r;make_identity_dictsrcCs8i}x.|jD]"\}}||kr(|||<qd||<qW|S)a Creates an encoding map from a decoding map. If a target mapping in the decoding map occurs multiple times, then that target is mapped to None (undefined mapping), causing an exception when encountered by the charmap codec during translation. One example where this happens is cp875.py which decodes multiple character to \u001a. N)items) decoding_mapmkvr:r:r;make_encoding_map$s   rignorereplacexmlcharrefreplacebackslashreplace namereplace__main__zlatin-1zutf-8)rNrCrm)NrC)rC)rC)s     B("1+IzWn * &