mò 2þœOc@sodZdZdkZdkZdkZdkZdklZdkl Z dk l Z l Z l Z defd„ƒYZdefd „ƒYZd efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(s„ I/O classes provide a uniform API for low-level input and output. Subclasses will exist for a variety of input/output mechanisms. treStructuredTextN(s TransformSpec(tb(slocale_encodings ErrorStrings ErrorOutputt InputErrorcBstZRS(N(t__name__t __module__(((te/home/project-web/docutils/web-update/infrastructure/update-dir/aux/snapshots/docutils/docutils/io.pyRst OutputErrorcBstZRS(N(RR(((RRstInputcBs’tZdZdZeZeeedd„Zd„Zd„Zd„Z e i e dƒƒZ eidfeid feid ffZd „ZRS( s1 Abstract base class for input wrappers. tinputtstrictcCsH||_||_||_||_|p|i|_nd|_dS(N(tencodingtselft error_handlertsourcet source_pathtdefault_source_pathtNonetsuccessful_encoding(R R RR R ((Rt__init__#s    cCsd|i|i|ifS(Ns%s: source=%r, source_path=%r(R t __class__R R(R ((Rt__repr__7scCs t‚dS(N(tNotImplementedError(R ((Rtread;sc Csk|io4|iiƒdjot|tƒp td‚nt|tƒo|Sn|io|ig}nK|i|ƒ}|o |g}n(ddg}t o|i dt ƒnxd|D]\}y2t|||i ƒ}||_|iddƒSWqÁttfj o}|}qÁXqÁWtdd ig}|D]}|t|ƒq8~ƒt|ƒfƒ‚d S( s Decode a string, `data`, heuristically. Raise UnicodeError if unsuccessful. The client application should call ``locale.setlocale`` at the beginning of processing:: locale.setlocale(locale.LC_ALL, '') tunicodes=input encoding is "unicode" but input is not a unicode objectsutf-8slatin-1iuusEUnable to decode input data. Tried the following encodings: %s. (%s)s, N(R R tlowert isinstancetdataRtAssertionErrort encodingstdetermine_encoding_from_datat data_encodingtlocale_encodingtinserttencR tdecodedRtreplacet UnicodeErrort LookupErrorterrterrortjoint_[1]treprt ErrorString( R RR"R!R&R'RR)R((Rtdecode>s,      scoding[:=]\s*([-\w.]+)sutf-8s utf-16-bes utf-16-lecCs„x/|iD]$\}}|i|ƒo|Sq q WxK|iƒd D]9}|ii |ƒ}|o|i dƒi dƒSqCqCWdS(s— Try to determine the encoding of `data` by looking *in* `data`. Check for a byte order mark (BOM) or an encoding declaration. iitasciiN(R tbyte_order_markst start_bytesR Rt startswitht splitlinestlinet coding_slugtsearchtmatchtgroupR,R(R RR R/R2R5((RRxs  (RRt__doc__tcomponent_typeRRRRRR,tretcompileRR3tcodecstBOM_UTF8t BOM_UTF16_BEt BOM_UTF16_LER.R(((RRs    0*tOutputcBsJtZdZdZeZeeedd„Zd„Zd„Zd„Z RS(s2 Abstract base class for output wrappers. toutputR cCsF||_|pd|_||_||_|p|i|_ndS(NR (R R R t destinationtdestination_pathtdefault_destination_path(R RARBR R ((RR“s   cCsd|i|i|ifS(Ns'%s: destination=%r, destination_path=%r(R RRARB(R ((RR¤scCs t‚dS(s;`data` is a Unicode string, to be encoded by `self.encode`.N(R(R R((Rtwrite¨scCst|io8|iiƒdjo"t|tƒp td‚|Snt|tƒp|Sn|i|i|iƒSdS(NRsFthe encoding given is "unicode" but the output is not a Unicode string( R R RRRRRtencodeR (R R((RRE¬s  ( RRR7R8RRCRRRDRE(((RR?‰s   t FileInputcBsGtZdZeeedeedd„Zd„Zd„Zd„ZRS(s5 Input for single, simple file-like objects. R trUc Csâti|||||ƒ||_||_t ƒ|_ |djoØ|oÁt i d jo"hd|i<d|i<}nh}yt||||_Wqtj o]} |o5|i t| ƒIJ|i d|IJt idƒnt| i| i|ƒ‚qXqªt i|_nt i d jo~|iott|idƒoa|i|iijoKti|iƒti|iiƒjo#td|i|iifƒ‚n|p-y|ii|_WqÞtj oqÞXndS( sü :Parameters: - `source`: either a file-like object (which is read directly), or `None` (which implies `sys.stdin` if no `source_path` given). - `source_path`: a path to a file, which is opened and then read. - `encoding`: the expected text encoding of the input file. - `error_handler`: the encoding error handler to use. - `autoclose`: close automatically after read (except when `sys.stdin` is the source). - `handle_io_errors`: summarize I/O errors here, and exit? - `mode`: how the file is to be opened (see standard function `open`). The default 'rU' provides universal newline support for text files. iiR terrorsu6Unable to open source file for reading ("%s").Exiting.isOEncoding clash: encoding given is "%s" but source is opened with encoding "%s".N(ii(ii(RRR R RR R t autoclosethandle_io_errorst ErrorOutputt_stderrRtsyst version_infotkwargstopentmodetIOErrorR'R+texitRterrnotstrerrortstdinthasattrR;tlookupR$tnametAttributeError( R R RR R RIRJRQROR'((RR¾s4    "!k#cCs%züyq|itijoKtidjo;|iiiƒ}tdƒi |i ƒƒtdƒ}n|iiƒ}Wn„t t fj or}|i o[|ioQt|idƒ}|iƒ}|iƒtdƒi |i ƒƒtdƒ}qû‚nXWd|io|iƒnX|i|ƒS(sU Read and decode a single file and return the data (Unicode string). iis trbN(ii(R R RMRVRNtbufferRRRR(R1R$R%R&R RRPtb_sourcetcloseRIR,(R R&R]R((RRøs$#)  )  cCs|iƒitƒS(sK Return lines of a single file as list of Unicode strings. N(R RR1tTrue(R ((Rt readlinesscCs(|itij o|iiƒndS(N(R R RMRVR^(R ((RR^s( RRR7RR_RRR`R^(((RRF¹s :  t FileOutputcBsMtZdZdZeeedeeed„Zd„Zd„Zd„Z RS(s6 Output for single, simple file-like objects. twR cCsÃti|||||ƒt|_||_ ||_ |dj o ||_ nt ƒ|_|djo$|o t|_q‹ti|_n|p-y|ii|_Wq¿tj oq¿XndS(s@ :Parameters: - `destination`: either a file-like object (which is written directly) or `None` (which implies `sys.stdout` if no `destination_path` given). - `destination_path`: a path to a file, which is opened and then written. - `encoding`: the text encoding of the output file. - `error_handler`: the encoding error handler to use. - `autoclose`: close automatically after write (except when `sys.stdout` or `sys.stderr` is the destination). - `handle_io_errors`: summarize I/O errors here, and exit? - `mode`: how the file is to be opened (see standard function `open`). The default is 'w', providing universal newline support for text files. N(R?RR RARBR R R_topenedRIRJRQRRKRLtFalseRMtstdoutRYRZ(R RARBR R RIRJRQ((RR+s$         cCsÙtidjo"hd|i<d|i<}nh}yt|i|i||_ Wnrt j of}|i o8|i t|ƒIJ|i d|iIJtidƒnt|i|i|iƒ‚nXt|_dS(NiiR RHu=Unable to open destination file for writing ('%s'). Exiting.i(ii(RMRNR R R RORPRBRQRARRR'RJRLR+RSRRTRUR_Rc(R ROR'((RRPQs" cCsjtidjo|i|ƒ}n|ip|iƒnzyÎtidjoª|io t|i dƒo|i|i ijowt i |iƒt i |i iƒjoO|i|ƒ}t idjo|idt iƒ}ntiii|ƒn|i i|ƒWn:ttfj o(}td|it|ƒfƒ‚nXWd|io|iƒnX|S( suEncode `data`, write it to a single file, and return it. In Python 3, `data` is returned unchanged. iiR s s:Unable to encode output data. output-encoding is: %s. (%s)N(ii(ii(RMRNR RERRcRPR RWRAR;RXtbdatatostlinesepR#ReR\RDR$R%R&R+RIR^(R RR&Rf((RRDds& k( cCs:|ititifjo|iiƒt|_ndS(N(R RARMRetstderrR^RdRc(R ((RR^„s ( RRR7RQRR_RRPRDR^(((RRas &  tBinaryFileOutputcBstZdZdZRS(sL A version of docutils.io.FileOutput which writes to a binary file. twb(RRR7RQ(((RRjŠs t StringInputcBstZdZdZd„ZRS(s Direct string input. scCs|i|iƒS(s$Decode and return the source string.N(R R,R (R ((RR›s(RRR7RR(((RRl“s t StringOutputcBstZdZdZd„ZRS(s Direct string output. scCs|i|ƒ|_|iS(s=Encode `data`, store it in `self.destination`, and return it.N(R RERRA(R R((RRD¨s(RRR7RCRD(((RRm s t NullInputcBstZdZdZd„ZRS(s) Degenerate input: read nothing. s null inputcCsdS(sReturn a null string.uN((R ((RR¶s(RRR7RR(((RRn®s t NullOutputcBstZdZdZd„ZRS(s+ Degenerate output: write nothing. s null outputcCsdS(s6Do nothing ([don't even] send data to the bit bucket).N((R R((RRDÃs(RRR7RCRD(((RRo»s t DocTreeInputcBstZdZdZd„ZRS(sm Adapter for document tree input. The document tree must be passed in the ``source`` parameter. s doctree inputcCs|iS(sReturn the document tree.N(R R (R ((RRÒs(RRR7RR(((RRpÈs (R7t __docformat__RMRgR9R;tdocutilst TransformSpectdocutils._compatRtdocutils.error_reportingRR+RKRRRRRR?RFRaRjRlRmRnRoRp(RRsRFRqRR9RoRRRaRMRlRpR;R?RjRmRR+RnRKRg((Rt?s(      p0fk