mņ ićøEc@sÕdZdZdkZdkZdklZdklZlZl Z dkl Z l Z l Z l Z lZdklZdklZdkZdfd „ƒYZd Zd Zed ed edeeeedeeed„Zeeeeed ed edeeeeed„Zeeed ed edeeeeed„ Zee ieed ed edeeeeed„Zee ied ed eeeeed„ Zeedeeeeed„Zd„ZdS(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 StringType(s __version__s__version_details__s SettingsSpec(sfrontendsiosutilssreadersswriters(s OptionParser(s Transformert Publisherc BstZdZeeeeeieeied„Zd„Zd„Z d„Z eeeed„Z eeeed„Z d„Z eeeeed„Zeed „Zeed „Zeed „Zd „Zeeeeeeed „Zd„Zd„Zd„Zd„ZRS(sK A facade encapsulating the high-level logic of a Docutils system. c Cs d|_||_||_||_xHdD]@} tt|| ƒt ƒ p t dt|| ƒ| | f‚q+W||_ ||_ ||_ ||_||_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). treadertparsertwriters6passed string as "%s" parameter; use "%s_name" insteadN(sreadersparserswriter(tNonetselftdocumentRRRt componentt isinstancetgetattrt StringTypetAssertionErrortsourcet source_classt destinationtdestination_classtsettings( RRRRR RRRRR((t,/data/zmath/zope/lib/python/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_readerOscCsti|ƒ}|ƒ|_dS(sSet `self.writer` by name.N(twriterstget_writer_classt writer_namet writer_classRR(RRR((Rt set_writerUscCs™|idjo|i||i|ƒn|idjo:|iidjo|ii|ƒn|ii|_n|idjo|i |ƒndS(N( RRRRRRRt set_parserRRR(RRRR((Rtset_componentsZsc KsØ|oa|p tƒ}n||_|iƒ}t|ƒdjo!|ddjodg|_qhntd|i |i |i |fd|ddd|d |ƒ}|S( Nii’’’’t applicationt applicationst componentstdefaultstread_config_filestusaget description(tconfig_sectiont settings_spect SettingsSpectsplittpartstlentconfig_section_dependenciest OptionParserRRRRR$R&R't option_parser(RR&R'R)R(R$R,R0((Rtsetup_option_parserds   $ 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( RR1R&R'R)R(R$R0tget_default_valuesR(RR&R'R)R(R$R0((Rt get_settingsuscCsT|idjo@|phiƒ}|iddƒ|id|d||ndS(Nt tracebackiR)R(( RRRtsettings_overridestcopyR$t setdefaultR3R)R((RR)R5R(R$((Rtprocess_programmatic_settingsƒs  cKsO|i|||||}|djot id}n|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`). iN( RR1R&R'R)R(R$R0targvRtsyst parse_argsR(RR9R&R'R)R(R$R0((Rtprocess_command_lineŽs  cCsL|idjo|id|ƒn|idjo|id|ƒndS(Nt source_pathtdestination_path(RR Rt set_sourceR=Rtset_destinationR>(RR=R>((Rtset_ioscCsT|djo|ii}n ||i_|id|d|d|iiƒ|_dS(NR R=tencoding(R=RRRt_sourceRR tinput_encoding(RR R=((RR?£s   c Cs`|djo|ii}n ||i_|id|d|d|iid|iiƒ|_dS(NRR>RBt error_handler( R>RRRt _destinationRRtoutput_encodingtoutput_encoding_error_handler(RRR>((RR@¬s    cCsH|iii|i|i|ii|i|ifƒ|iii ƒdS(N( RRt transformertpopulate_from_componentsR RRRRtapply_transforms(R((RRK¶s4c Cs•d} y›|idjo'|i||||||phn|i ƒ|i i |i|i|iƒ|_|iƒ|ii|i|iƒ} |iiƒWn€tj o}d} |i} n^tj oQ}|ip‚n|iio|iƒ‚n|i|ƒd} d} nX|iƒ|oD|io:|ii i!|ii"jot#i|ii i!dƒn| 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($RtexitRRR<R9R&R'R)R(R5RARtreadR RRRKRtwriteRtoutputtassemble_partst SystemExitterrortcodet exit_statust ExceptionR4tdebugging_dumpstreport_Exceptiontenable_exit_statustreportert max_leveltexit_status_levelR:( RR9R&R'R)R5R(RXRRRLRTRO((Rtpublish¼s:'         -cCs^|ipdSn|iio-tidIJtiti|iiƒIJn|ii o-tidIJtiti|iiƒIJn|ii oŠtidIJtidIJtitig}|ii i D]?\}}}}||d|i|if|o|i|fqĪ~ƒIJn|iio0tidIJti|iiƒidƒIJndS(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_settingsR:tstderrtpprinttpformatt__dict__tdump_internalstdump_transformst_[1]RItappliedtprioritytxclasstpendingtkwargst __module__t__name__tdetailstdump_pseudo_xmltencode(RReRhRjRiRg((RRVås          p  c Cst|tiƒo|i|ƒnft|tƒo|i|ƒnEti d|i i |fIJti dt t tiiƒdfIJdS(Ns%s: %ssīExiting 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 RRtutilst SystemMessageRtreport_SystemMessaget UnicodeErrortreport_UnicodeErrorR:R_t __class__Rlt __version__t__version_details__tversionR+(RRR((RRWüs cCs+tid|itii|ifIJdS(Ns,Exiting due to level-%s (%s) system message.(R:R_RRtlevelRptReportertlevels(RRR((RRr scCsĻtiid|ii||iifƒyL|i |i |i !}tiid|i ddƒ|i ddƒfƒWn#tj otiidƒnXtiid|iittiiƒdfƒdS( Ns­%s: %s The specified output encoding (%s) cannot handle all of the output. Try setting "--output-encoding-error-handler" to * "xmlcharrefreplace" (for HTML & XML output); s’ the output will contain "%s" and should be usable. * "backslashreplace" (for other output formats, Python 2.3+); look for "%s" in the output. tasciitxmlcharrefreplacetbackslashreplaces% the output should be usable as-is. s~* "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. i(R:R_RNRRRuRlRRRGtobjecttstarttendtdataRotAttributeErrorRHRvRxR+(RRRR‚((RRts) 6(RlRkt__doc__Rtiot FileInputt FileOutputRRRR R1R3R8R<RAR?R@RKR\RVRWRrRt(((RRs$ ',      )   s*%prog [options] [ []]sWReads from (default is stdin) and writes to (default is stdout).t standalonetrestructuredtextt pseudoxmlic 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(RXN(RRRRRtpubR RRRR\R9R&R'R)R5R(RXRO(RRRRRRRR)R5R(RXR9R&R'ROR‹((Rtpublish_cmdline7s 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 R=RRR>RRRRRRRR)R5R(RXN(tpublish_programmaticallyR…R†R R=R‡RR>RRRRRRRR)R5R(RXROR‹(R R=RR>RRRRRRRR)R5R(RXROR‹((Rt publish_fileRs       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 R=RRR>RRRRRRRR)R5R(RXN(RR…t StringInputR R=t StringOutputRR>RRRRRRRR)R5R(RXROR‹(R R=R>RRRRRRRR)R5R(RXROR‹((Rtpublish_stringls      c#Cs‚td|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 R=RRRR>RRRRRRRR)R5R(RXN(RR R=RR…RRR>RRRRRRRR)R5R(RXROR‹R,(R R=RR>RRRRRRRR)R5R(RXROR‹((Rt publish_partss      c  Cstd|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`. RRRRRRtnullRXN(RRRRRRR…t NullOutputR‹R RRR8R)R5R(R?R R=R@R\RXROR(R R=RRRRRRR)R5R(RXROR‹((Rtpublish_doctree²sc Cs›tiiiddƒ} t| d|dti |ƒdti d|ƒ} | o|o| i|ƒn| i|||ƒ| id|ƒ| id|ƒS(sc Set up & run a `Publisher` to render from an existing document tree data structure, for programmatic use with string I/O. Return a pair of encoded string output and document parts. 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`. RR“R RRRXN(tdocutilsRtdoctreetReaderRRRRR…t DocTreeInputRRRR‹RRR8R)R5R(R@R>R\RX( RR>RRRR)R5R(RXRR‹((Rtpublish_from_doctreeŃs c Cs†t||| 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? RRRRXN(RRRRRRRR‹R RRRR8R)R5R(R?R R=R@RR>R\RXRO(RR R=RRR>RRRRRRRR)R5R(RXROR‹((RRųsc ( R„t __docformat__R:R`ttypesR R–RvRwR*tfrontendR…RpRRtdocutils.frontendR/tdocutils.transformst Transformertdocutils.readers.doctreeRt default_usagetdefault_descriptionRRŒRŽR‘RR’R•RšR(R RR‘RpR›RwRŒR…R RR`R–RŽRR¢RvR/RR•R£RR:R*RšR’((Rt?s(   %   ’360$6"-!'