m 2Oc@sdZdZdkZdkZdklZlZlZdklZl Z l Z l Z l Z dk lZdklZdklZlZdkZdfd YZd Zd Zed ed edeeeeeeeedZeeeeed ed edeeeeedZeeed ed edeeeeed Zee ieed ed edeeeeedZee ied ed eeeeed Z eedeeeeedZ!ed ed edeeeeeeeeee i"dZ#dZ$dS(s Calling the ``publish_*`` convenience functions (or instantiating a `Publisher` object) with component names will result in default behavior. For custom behavior (setting component options), create custom component objects first, and pass *them* to ``publish_*``/`Publisher`. See `The Docutils Publisher`_. .. _The Docutils Publisher: http://docutils.sf.net/docs/api/publisher.html treStructuredTextN(s __version__s__version_details__s SettingsSpec(sfrontendsiosutilssreadersswriters(s OptionParser(s Transformer(s ErrorOutputs ErrorStringt Publisherc BstZdZeeeeeieeiedZdZdZ dZ eeeedZ eeeedZ dZ eeeeedZeed Zeed Zeed Zd Zeeeeeeed ZdZdZdZdZRS(sK A facade encapsulating the high-level logic of a Docutils system. c Csd|_||_||_||_xHdD]@} tt|| t  p t dt|| | | fq+W||_ ||_ ||_ ||_||_t|_dS(s Initial setup. If any of `reader`, `parser`, or `writer` are not specified, the corresponding ``set_...`` method should be called with a component name (`set_reader` sets the parser as well). treadertparsertwriterspassed string "%s" as "%s" parameter; pass an instance, or use the "%s_name" parameter instead (in docutils.core.publish_* convenience functions).N(sreadersparserswriter(tNonetselftdocumentRRRt componentt isinstancetgetattrtstrtAssertionErrortsourcet source_classt destinationtdestination_classtsettingst ErrorOutputt_stderr( RRRRR RRRRR((tg/home/project-web/docutils/web-update/infrastructure/update-dir/aux/snapshots/docutils/docutils/core.pyt__init__ s.    >     cCs4ti|}||||_|ii|_dS(sSet `self.reader` by name.N(treaderstget_reader_classt reader_namet reader_classRt parser_nameRR(RRRRR((Rt set_readerPscCsti|}||_dS(sSet `self.writer` by name.N(twriterstget_writer_classt writer_namet writer_classRR(RRR((Rt set_writerVscCs|idjo|i||i|n|idjo:|iidjo|ii|n|ii|_n|idjo|i |ndS(N( RRRRRRRt set_parserRR R(RRRR((Rtset_components[sc Ks|oa|p t}n||_|i}t|djo!|ddjodg|_qhntd|i |i |i |fd|dt d|d |}|S( Niit applicationt applicationst componentstdefaultstread_config_filestusaget description(tconfig_sectiont settings_spect SettingsSpectsplittpartstlentconfig_section_dependenciest OptionParserRRRRR&tTrueR(R)t option_parser(RR(R)R+R*R&R.R3((Rtsetup_option_parseres   $ cKs1|i|||||}|i|_ |i S(s  Set and return default settings (overrides in `defaults` dict). Set components first (`self.set_reader` & `self.set_writer`). Explicitly setting `self.settings` disables command line option processing from `self.publish()`. N( RR4R(R)R+R*R&R3tget_default_valuesR(RR(R)R+R*R&R3((Rt get_settingsvscCsT|idjo@|phi}|idt|id|d||ndS(Nt tracebackR+R*( RRRtsettings_overridestcopyR&t setdefaultR2R6R+R*(RR+R8R*R&((Rtprocess_programmatic_settingss  c Ks|i|||||} |djo_t id}t i djo>t i pd} g}|D]}||i| q`~}qn| i||_dS(s Pass an empty list to `argv` to avoid reading `sys.argv` (the default). Set components first (`self.set_reader` & `self.set_writer`). iiitasciiN(ii(RR4R(R)R+R*R&R3targvRtsyst version_infotfrontendtlocale_encodingt argv_encodingt_[1]tatdecodet parse_argsR( RR=R(R)R+R*R&RDRCRBR3((Rtprocess_command_lines  2cCsL|idjo|id|n|idjo|id|ndS(Nt source_pathtdestination_path(RR Rt set_sourceRHRtset_destinationRI(RRHRI((Rtset_iosc Cs|djo|ii}n ||i_y1|id|d|d|iidt|_Wn:t j o.|id|d|d|ii|_nXdS(NR RHtencodingthandle_io_errors( RHRRRt_sourceRR tinput_encodingtFalset TypeError(RR RH((RRJs   c Csl|djo|ii}n ||i_|id|d|d|iid|ii|_t |i_ dS(NRRIRMt error_handler( RIRRRt _destinationRRtoutput_encodingtoutput_encoding_error_handlerRQRN(RRRI((RRKs   cCsH|iii|i|i|ii|i|if|iii dS(N( RRt transformertpopulate_from_componentsR RRRRtapply_transforms(R((RRYs4c Csd} y|idjo'|i||||||phn|i |i i |i|i|i|_|i|ii|i|i} |iiWntj o}d} |i} n^tj oQ}|ipn|iio|in|i|t} d} nX|i|oD|io:|ii!i"|ii#jot$i|ii!i"dn| ot$i| n| S(s Process command line options and arguments (if `self.settings` not already set), run `self.reader` and then `self.writer`. Return `self.writer`'s output. ii N(%RtexitRRRGR=R(R)R+R*R8RLRtreadR RRRYRtwriteRtoutputtassemble_partst SystemExitterrortcodet exit_statust ExceptionR7tdebugging_dumpstreport_ExceptionR2tenable_exit_statustreportert max_leveltexit_status_levelR>( RR=R(R)R+R8R*RfR`RZRbR]((Rtpublishs:'         -cCs^|ipdSn|iio-|idIJ|iti|iiIJn|iio-|idIJ|iti|iiIJn|ii o|idIJ|idIJ|itig}|ii i D]?\}}}}||d|i|if|o|i|fq~IJn|iio0|idIJ|i|iiidIJndS(Ns ::: Runtime settings:s ::: Document internals:s ::: Transforms applied:s@ (priority, transform class, pending node details, keyword args)s%s.%ss ::: Pseudo-XML:traw_unicode_escape(RRRt dump_settingsRtpprinttpformatt__dict__tdump_internalstdump_transformsRCRWtappliedtprioritytxclasstpendingtkwargst __module__t__name__tdetailstdump_pseudo_xmltencode(RRsRCRtRvRu((RRds          p  c Cst|tio|i|nt|to|i|nt|ti o|i i dt |npt|ti o|i i dt |n?|i dt |IJ|i dtttiidfIJdS(Nu-Unable to open source file for reading: %s u2Unable to open destination file for writing: %s u%ssExiting due to error. Use "--traceback" to diagnose. Please report errors to . Include "--traceback" output, Docutils version (%s [%s]), Python version (%s), your OS type & version, and the command line used.i(R R`tutilst SystemMessageRtreport_SystemMessagetUnicodeEncodeErrortreport_UnicodeErrortiot InputErrorRR\t ErrorStringt OutputErrort __version__t__version_details__R>tversionR-(RR`((RRe scCs+|id|itii|ifIJdS(Ns,Exiting due to level-%s (%s) system message.(RRR`tlevelR|tReportertlevels(RR`((RR~#sc Csz|i|i|i!}|iidt||i i |i dd|i dd|i i t tiidfdS(Ns%s The specified output encoding (%s) cannot handle all of the output. Try setting "--output-encoding-error-handler" to * "xmlcharrefreplace" (for HTML & XML output); the output will contain "%s" and should be usable. * "backslashreplace" (for other output formats); look for "%s" in the output. * "replace"; look for "?" in the output. "--output-encoding-error-handler" is currently set to "%s". Exiting due to error. Use "--traceback" to diagnose. If the advice above doesn't eliminate the error, please report it to . Include "--traceback" output, Docutils version (%s), Python version (%s), your OS type & version, and the command line used. R<txmlcharrefreplacetbackslashreplacei(R`tobjecttstarttendtdataRRR\RRRUR{RVRR>RR-(RR`R((RR(s(RxRwt__doc__RRt FileInputt FileOutputRRR R"R4R6R;RGRLRJRKRYRQRjRdReR~R(((RRs$ '0     )   s*%prog [options] [ []]sReads from (default is stdin) and writes to (default is stdout). See for the full reference.t standalonetrestructuredtextt pseudoxmlc CsVt|||d|}|i||||i | | | ||d| d| }|S(s% Set up & run a `Publisher` for command-line-based file I/O (input and output file paths taken automatically from the command line). Return the encoded string output also. Parameters: see `publish_programmatically` for the remainder. - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``. - `usage`: Usage string, output if there's a problem parsing the command line. - `description`: Program description, output for the "--help" option (along with command-line option descriptions). RR*RfN(RRRRRtpubR"RRRRjR=R(R)R+R8R*RfR](RRRRRRRR+R8R*RfR=R(R)R]R((Rtpublish_cmdlineLs c#Cstdtid|d|dtid|d|d|d|d |d |d |d | d | d| d| d| d|\}}|S(s Set up & run a `Publisher` for programmatic use with file-like I/O. Return the encoded string output also. Parameters: see `publish_programmatically`. RR RHRRRIRRRRRRRR+R8R*RfN(tpublish_programmaticallyRRR RHRRRIRRRRRRRR+R8R*RfR]R(R RHRRIRRRRRRRR+R8R*RfR]R((Rt publish_filegs       c#Cstdtid|d|dtiddd|d|d|d |d |d |d |d | d| d| d| d| \}}|S(sB Set up & run a `Publisher` for programmatic use with string I/O. Return the encoded string or Unicode string output. For encoded string output, be sure to set the 'output_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string output. Here's one way:: publish_string(..., settings_overrides={'output_encoding': 'unicode'}) Similarly for Unicode string input (`source`):: publish_string(..., settings_overrides={'input_encoding': 'unicode'}) Parameters: see `publish_programmatically`. RR RHRRRIRRRRRRRR+R8R*RfN(RRt StringInputR RHt StringOutputRRIRRRRRRRR+R8R*RfR]R(R RHRIRRRRRRRR+R8R*RfR]R((Rtpublish_strings      c#Cstd|d|d|dtiddd|d|d|d |d |d |d | d | d| d| d| d|\}}|i iS(s Set up & run a `Publisher`, and return a dictionary of document parts. Dictionary keys are the names of parts, and values are Unicode strings; encoding is up to the client. For programmatic use with string I/O. For encoded string input, be sure to set the 'input_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string input. Here's how:: publish_parts(..., settings_overrides={'input_encoding': 'unicode'}) Parameters: see `publish_programmatically`. R RHRRRRIRRRRRRRR+R8R*RfN(RR RHRRRRRIRRRRRRRR+R8R*RfR]RR.(R RHRRIRRRRRRRR+R8R*RfR]R((Rt publish_partss      c  Cstd|d|dd d|d|dti} | i ||d| i || | | i||| id d | id| } | iS( s Set up & run a `Publisher` for programmatic use with string I/O. Return the document tree. For encoded string input, be sure to set the 'input_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string input. Here's one way:: publish_doctree(..., settings_overrides={'input_encoding': 'unicode'}) Parameters: see `publish_programmatically`. RRRRRRtnullRfN(RRRRRRRt NullOutputRR"RRR;R+R8R*RJR RHRKRjRfR]R(R RHRRRRRRR+R8R*RfR]R((Rtpublish_doctreesc Cstiiidd} t| d|dti |dti d|} | o|o| i|n| i|||| id|| id|S(sJ Set up & run a `Publisher` to render from an existing document tree data structure, for programmatic use with string I/O. Return the encoded string output. Note that document.settings is overridden; if you want to use the settings of the original `document`, pass settings=document.settings. Also, new document.transformer and document.reporter objects are generated. For encoded string output, be sure to set the 'output_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string output. Here's one way:: publish_from_doctree( ..., settings_overrides={'output_encoding': 'unicode'}) Parameters: `document` is a `docutils.nodes.document` object, an existing document tree. Other parameters: see `publish_programmatically`. RRR RRRfN(tdocutilsRtdoctreetReaderRRRRRt DocTreeInputRRRRRR R;R+R8R*RKRIRjRf( RRIRRRR+R8R*RfRR((Rtpublish_from_doctrees c Cs\t|||d|d|}|i||||i | | | ||d| d| }|S(s Set up & run a `Publisher` for command-line-based file I/O (input and output file paths taken automatically from the command line). Return the encoded string output also. This is just like publish_cmdline, except that it uses io.BinaryFileOutput instead of io.FileOutput. Parameters: see `publish_programmatically` for the remainder. - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``. - `usage`: Usage string, output if there's a problem parsing the command line. - `description`: Program description, output for the "--help" option (along with command-line option descriptions). RRR*RfN(RRRRRRRR"RRRRjR=R(R)R+R8R*RfR](RRRRRRRR+R8R*RfR=R(R)RRR]R((Rtpublish_cmdline_to_binary s c Cst||| d| d|d|}|i|| | |i | |||i|||i|||id|}||fS(s7 Set up & run a `Publisher` for custom programmatic use. Return the encoded string output and the Publisher object. Applications should not need to call this function directly. If it does seem to be necessary to call this function directly, please write to the Docutils-develop mailing list . Parameters: * `source_class` **required**: The class for dynamically created source objects. Typically `io.FileInput` or `io.StringInput`. * `source`: Type depends on `source_class`: - If `source_class` is `io.FileInput`: Either a file-like object (must have 'read' and 'close' methods), or ``None`` (`source_path` is opened). If neither `source` nor `source_path` are supplied, `sys.stdin` is used. - If `source_class` is `io.StringInput` **required**: The input string, either an encoded 8-bit string (set the 'input_encoding' setting to the correct encoding) or a Unicode string (set the 'input_encoding' setting to 'unicode'). * `source_path`: Type depends on `source_class`: - `io.FileInput`: Path to the input file, opened if no `source` supplied. - `io.StringInput`: Optional. Path to the file or object that produced `source`. Only used for diagnostic output. * `destination_class` **required**: The class for dynamically created destination objects. Typically `io.FileOutput` or `io.StringOutput`. * `destination`: Type depends on `destination_class`: - `io.FileOutput`: Either a file-like object (must have 'write' and 'close' methods), or ``None`` (`destination_path` is opened). If neither `destination` nor `destination_path` are supplied, `sys.stdout` is used. - `io.StringOutput`: Not used; pass ``None``. * `destination_path`: Type depends on `destination_class`: - `io.FileOutput`: Path to the output file. Opened if no `destination` supplied. - `io.StringOutput`: Path to the file or object which will receive the output; optional. Used for determining relative paths (stylesheets, source links, etc.). * `reader`: A `docutils.readers.Reader` object. * `reader_name`: Name or alias of the Reader class to be instantiated if no `reader` supplied. * `parser`: A `docutils.parsers.Parser` object. * `parser_name`: Name or alias of the Parser class to be instantiated if no `parser` supplied. * `writer`: A `docutils.writers.Writer` object. * `writer_name`: Name or alias of the Writer class to be instantiated if no `writer` supplied. * `settings`: A runtime settings (`docutils.frontend.Values`) object, for dotted-attribute access to runtime settings. It's the end result of the `SettingsSpec`, config file, and option processing. If `settings` is passed, it's assumed to be complete and no further setting/config/option processing is done. * `settings_spec`: A `docutils.SettingsSpec` subclass or object. Provides extra application-specific settings definitions independently of components. In other words, the application becomes a component, and its settings data is processed along with that of the other components. Used only if no `settings` specified. * `settings_overrides`: A dictionary containing application-specific settings defaults that override the defaults of other components. Used only if no `settings` specified. * `config_section`: A string, the name of the configuration file section for this application. Overrides the ``config_section`` attribute defined by `settings_spec`. Used only if no `settings` specified. * `enable_exit_status`: Boolean; enable exit status at end of processing? RRRRfN(RRRRRRRRR"RRRR;R+R8R*RJR RHRKRRIRjRfR](RR RHRRRIRRRRRRRR+R8R*RfR]R((RR.sc (%Rt __docformat__R>RmRRRR,R@RR|RRtdocutils.frontendR1tdocutils.transformst Transformertdocutils.error_reportingRRtdocutils.readers.doctreeRt default_usagetdefault_descriptionRR2RRQRRRRRRtBinaryFileOutputRR(RR@RR|RRRRRRRmRRRRRR1RRRRR>R,RRRR((Rt? s*  %   -360$6"-!'