o
    f'haë‘  ã                   @   sâ  d Z dZddlZddlZddlZddlZddlZddlZddlmZ ej	dkr4ddl
mZ ddlmZ nddlmZ ddlmZ ddlZddlZddlZdd	lmZmZmZmZ ej	dkr_eZd
d„ Zdd„ Z	d8dd„Z	d8dd„Z	d8dd„Z	d8dd„Z	d8dd„Z	d8dd„Z 	d8dd„Z!	d8dd„Z"	d8dd„Z#	d8d d!„Z$	d8d"d#„Z%	d8d$d%„Z&	d8d&d'„Z'd9d(d)„Z(d*d+„ Z)d,d-„ Z*G d.d/„ d/ej+ƒZ+G d0d1„ d1ej,ƒZ,G d2d3„ d3ej-ej.ƒZ-G d4d5„ d5eƒZG d6d7„ d7e/ƒZ0dS ):au  
Command-line and common processing for Docutils front-end tools.

Exports the following classes:

* `OptionParser`: Standard Docutils command-line processing.
* `Option`: Customized version of `optparse.Option`; validation support.
* `Values`: Runtime settings; objects are simple structs
  (``object.attribute``).  Supports cumulative list settings (attributes).
* `ConfigParser`: Standard Docutils config file processing.

Also exports the following functions:

* Option callbacks: `store_multiple`, `read_config_file`.
* Setting validators: `validate_encoding`,
  `validate_encoding_error_handler`,
  `validate_encoding_and_error_handler`,
  `validate_boolean`, `validate_ternary`, `validate_threshold`,
  `validate_colon_separated_list`,
  `validate_comma_separated_list`,
  `validate_dependency_file`.
* `make_paths_absolute`.
* SettingSpec manipulation: `filter_settings_spec`.
ÚreStructuredTexté    N)ÚSUPPRESS_HELP©é   r   )ÚRawConfigParser)Úgetcwd)Úgetcwdu)Úlocale_encodingÚ
SafeStringÚErrorOutputÚErrorStringc                 O   s<   |D ]	}t |j|dƒ q| ¡ D ]\}}t |j||ƒ qdS )zÀ
    Store multiple values in `parser.values`.  (Option callback.)

    Store `None` for each attribute named in `args`, and store the value for
    each key (attribute name) in `kwargs`.
    N)ÚsetattrÚvaluesÚitems)ÚoptionÚoptÚvalueÚparserÚargsÚkwargsÚ	attributeÚkey© r   ú3/usr/lib/python3/dist-packages/docutils/frontend.pyÚstore_multiple8   s
   ÿr   c              
   C   sP   z|  |¡}W n ty } z| |¡ W Y d}~nd}~ww |j ||¡ dS )zQ
    Read a configuration file during option processing.  (Option callback.)
    N)Úget_config_file_settingsÚ
ValueErrorÚerrorr   Úupdate)r   r   r   r   Únew_settingsr   r   r   r   Úread_config_fileD   s   €ÿr    c                 C   s0   zt  |¡ W |S  ty   td| |f ƒ‚w )Nz$setting "%s": unknown encoding: "%s")ÚcodecsÚlookupÚLookupError©Úsettingr   Úoption_parserÚconfig_parserÚconfig_sectionr   r   r   Úvalidate_encodingN   s   ýÿÿr)   c                 C   s,   zt  |¡ W |S  ty   td| ƒ‚w )Nz¿unknown encoding error handler: "%s" (choices: "strict", "ignore", "replace", "backslashreplace", "xmlcharrefreplace", and possibly others; see documentation for the Python ``codecs`` module))r!   Úlookup_errorr#   r$   r   r   r   Úvalidate_encoding_error_handlerW   s   úýÿÿr+   c                 C   sn   d|v r+|  d¡\}}t| d ||||ƒ |r!| || d |¡ nt|j| d |ƒ n|}t| ||||ƒ |S )zš
    Side-effect: if an error handler is included in the value, it is inserted
    into the appropriate place as if it was a separate setting/option.
    ú:Ú_error_handler)Úsplitr+   Úsetr   r   r)   )r%   r   r&   r'   r(   ÚencodingÚhandlerr   r   r   Ú#validate_encoding_and_error_handlerc   s    
þÿÿr2   c                 C   s>   t |tƒr|S z
|j| ¡  ¡  W S  ty   td| ƒ‚w )z|Check/normalize boolean settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
    zunknown boolean value: "%s")Ú
isinstanceÚboolÚbooleansÚstripÚlowerÚKeyErrorr#   r$   r   r   r   Úvalidate_booleany   s   
ÿr9   c                 C   sB   t |tƒs	|du r|S z
|j| ¡  ¡  W S  ty    | Y S w )zªCheck/normalize three-value settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
         any other value: returned as-is.
    N)r3   r4   r5   r6   r7   r8   r$   r   r   r   Úvalidate_ternary†   s   ÿr:   c                 C   s   t |ƒ}|dk rtdƒ‚|S )Nr   z(negative value; must be positive or zero)Úintr   r$   r   r   r   Úvalidate_nonnegative_int”   s   r<   c                 C   sN   zt |ƒW S  ty&   z
|j| ¡  W  Y S  ttfy%   td| ƒ‚w w )Nzunknown threshold: %r.)r;   r   Ú
thresholdsr7   r8   ÚAttributeErrorr#   r$   r   r   r   Úvalidate_threshold›   s   
ÿýr?   c                 C   s4   t |tƒs| d¡}|S | ¡ }| | d¡¡ |S )Nr,   )r3   Úlistr.   ÚpopÚextend)r%   r   r&   r'   r(   Úlastr   r   r   Ú$validate_colon_separated_string_list¥   s   

þrD   c                 C   s:   t |tƒs|g}| ¡ }dd„ | d¡D ƒ}| |¡ |S )zHCheck/normalize list arguments (split at "," and strip whitespace).
    c                 S   s    g | ]}|  d ¡r|  d ¡‘qS )z 	
©r6   )Ú.0Úir   r   r   Ú
<listcomp>¹   s     z1validate_comma_separated_list.<locals>.<listcomp>ú,)r3   r@   rA   r.   rB   )r%   r   r&   r'   r(   rC   r   r   r   r   Úvalidate_comma_separated_list®   s   

rJ   c                 C   s   |sdS |  d¡r|S |d S )Nz./ú/)Úendswithr$   r   r   r   Úvalidate_url_trailing_slash½   s
   
rM   c                 C   s.   zt j |¡W S  ty   t j d ¡ Y S w ©N)ÚdocutilsÚutilsÚDependencyListÚIOErrorr$   r   r   r   Úvalidate_dependency_fileÆ   s
   ÿrS   c                 C   sB   t | ||||ƒ}|D ]}tj |¡}||krtd||f ƒ‚q
|S )Nz$Invalid class value %r (perhaps %r?))rJ   rO   ÚnodesÚmake_idr   )r%   r   r&   r'   r(   ÚclsÚ
normalizedr   r   r   Úvalidate_strip_classÍ   s   ÿÿÿrX   c           
   
   C   sÆ   t | ||||ƒ}g }|D ]T}z
| dd¡\}}W n ty&   | |¡ Y q ty6   td| dd¡ ƒ‚w | ¡ }| d¡}	t|	ƒdkrI|	}nt|ƒdkrYtd| dd¡ ƒ‚| ||f¡ q|S )z~Check/normalize a comma separated list of smart quote definitions.

    Return a list of (language-tag, quotes) string tuples.r,   é   z4Invalid value "%s". Format is "<language>:<quotes>".ÚasciiÚbackslashreplaceé   z[Invalid value "%s". Please specify 4 quotes
    (primary open/close; secondary open/close).)rJ   r.   r>   Úappendr   Úencoder6   Úlen)
r%   r   r&   r'   r(   Ú	lc_quotesÚitemÚlangÚquotesÚmultichar_quotesr   r   r   Úvalidate_smartquotes_localesÚ   s2   ÿ

þÿ

þre   c                    s`   ˆ du rt ƒ ‰ |D ]$}|| v r-| | }t|tƒr"‡ fdd„|D ƒ}n|r)tˆ |ƒ}|| |< q	dS )zÉ
    Interpret filesystem path settings relative to the `base_path` given.

    Paths are values in `pathdict` whose keys are in `keys`.  Get `keys` from
    `OptionParser.relative_path_settings`.
    Nc                    s   g | ]}t ˆ |ƒ‘qS r   )Úmake_one_path_absolute)rF   Úpath©Ú	base_pathr   r   rH     s    ÿz'make_paths_absolute.<locals>.<listcomp>)r   r3   r@   rf   )ÚpathdictÚkeysri   r   r   r   rh   r   Úmake_paths_absoluteý   s   

ÿ
€ørl   c                 C   s   t j t j | |¡¡S rN   )Úosrg   ÚabspathÚjoin)ri   rg   r   r   r   rf     s   rf   c                 O   sŠ   t | ƒ}tdt|ƒdƒD ]4}g }|| D ]%}dd„ |d D ƒd }||v r&q|| ¡ v r4| || ¡ q| |¡ qt|ƒ||< qt|ƒS )a�  Return a copy of `settings_spec` excluding/replacing some settings.

    `settings_spec` is a tuple of configuration settings with a structure
    described for docutils.SettingsSpec.settings_spec.

    Optional positional arguments are names of to-be-excluded settings.
    Keyword arguments are option specification replacements.
    (See the html4strict writer for an example.)
    é   r   c                 S   s*   g | ]}|  d ¡r|dd…  dd¡‘qS )z--rp   Nú-Ú_)Ú
startswithÚreplace)rF   Ú
opt_stringr   r   r   rH   $  s    þz(filter_settings_spec.<locals>.<listcomp>rY   r   )r@   Úranger_   rk   r]   Útuple)Úsettings_specÚexcludert   ÚsettingsrG   ÚnewoptsÚopt_specÚopt_namer   r   r   Úfilter_settings_spec  s    
ÿýr~   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚValuesz•
    Updates list attributes by extension rather than by replacement.
    Works in conjunction with the `OptionParser.lists` instance attribute.
    c                 O   sB   t jj| g|¢R i |¤Ž t| dƒr| jd u rtj ¡ | _d S d S )NÚrecord_dependencies)Úoptparser   Ú__init__Úhasattrr€   rO   rP   rQ   ©Úselfr   r   r   r   r   r‚   9  s
   

þzValues.__init__c                 C   sh   t |tƒr|j}| ¡ }|j ¡ D ]}t| |ƒr,||v r,t| |ƒ}|r,||| 7 }||= q|  |¡ d S rN   )	r3   r   Ú__dict__ÚcopyÚlistsrk   rƒ   ÚgetattrÚ_update_loose)r…   Ú
other_dictr&   r%   r   r   r   r   r   @  s   

€zValues.updatec                 C   s   | j | jd�S )z Return a shallow copy of `self`.)Údefaults)Ú	__class__r†   )r…   r   r   r   r‡   L  s   zValues.copyc                 C   s&   t | |dƒdu rt| ||ƒ t | |ƒS )zUV.setdefault(n[,d]) -> getattr(V,n,d), also set D.n=d if n not in D or None.
        N)r‰   r   )r…   ÚnameÚdefaultr   r   r   Ú
setdefaultP  s   
zValues.setdefaultN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r‚   r   r‡   r�   r   r   r   r   r   2  s    r   c                   @   s$   e Zd Zejjddg Zdd„ ZdS )ÚOptionÚ	validatorÚ	overridesc           	   
   C   s”   t j | ||||¡}| j}|rH| jr>t||ƒ}z	|  |||¡}W n ty7 } zt  d|t|ƒf ¡‚d}~ww t	|||ƒ | j
rHt	|| j
dƒ |S )zœ
        Call the validator function on applicable settings and
        evaluate the 'overrides' option.
        Extends `optparse.Option.process`.
        zError in option "%s":
    %sN)r�   r•   ÚprocessÚdestr–   r‰   Ú	ExceptionÚOptionValueErrorr   r   r—   )	r…   r   r   r   r   Úresultr%   Ú	new_valuer   r   r   r   r˜   \  s&   

ÿÿ€ÿzOption.processN)r‘   r’   r“   r�   r•   ÚATTRSr˜   r   r   r   r   r•   X  s    r•   c                   @   sæ  e Zd ZdZg d¢Z	 d ¡ Z	 dddddd	œZ	 d
d
d
d
ddddddœ	Z	 e	e
jddƒp0ep0dZdZddg ddgi f‘dddgdedœf‘ddgdddœf‘ddd gd!d"d#d$œf‘d%d&d'gd!d(d#d$œf‘d)d*gd!dd#d$œf‘d+d,d-gdedœf‘d.d/gd0d1if‘d2d3gd4ed5d6œf‘d7d8gd9d!d:d:d;œf‘d<d=gd9d!d>d?œf‘d@dAgd9ddBœf‘dCdDgddedEœf‘dFdGgdHddBœf‘dIdJgddKdedLœf‘dMdNgddKdœf‘dOdPgdedœf‘dQdRgddSdœf‘dTdUgdVdWdXedYœf‘dZd[gdVd\dXedYœf‘d]d^d_gedd`daedbœf‘dcdddegd!dd`d$œf‘dfdgdhgd!dd`d$œf‘didjgedkddaedlœf‘dmdngd!ddkd$œf‘dodpgedqddaedlœf‘drdsgdedœf‘dtdugddvdœf‘dwdxgdydzd{œf‘d|d}gddedEœf‘d~dgd€ddBœf‘d�d‚dƒgd„ed…œf‘d†d‡gdˆed‰œf‘dŠd‹dŒgd„d�edŽœf‘d�d�gdˆed‰œf‘d‘e d’d“gd„eedŽœf‘d”e d•geed‰œf‘d–d—d˜gd™dšd›dœœf‘d�džgdzeddŸœf‘d d¡gdzd¢d4ed£œf‘d¤d¥d¦gd§d¨if‘d©dªd«gd§d¬if‘ed­gd®d¯if‘ed°gd®d±if‘ed²gd§dif‘ed³gd§dif‘ed´gd§dif‘edµgd§dif‘ed¶gdVd·ed¸œf‘ed¹gd§dif‘R fZ	 dddddºœZ	 d»Zd¼Zd½ejej�r;d¾ej �p<d¯e
j  ¡ d¿ e
j!f Z"	 dÕdÁdÂ„Z#dÃdÄ„ Z$dÅdÆ„ Z%dÇdÈ„ Z&dÉdÊ„ Z'dËdÌ„ Z(dÍdÎ„ Z)dÏdÐ„ Z*dÑdÒ„ Z+dÓdÔ„ Z,dS )ÖÚOptionParsera¢  
    Parser for command-line and library use.  The `settings_spec`
    specification here and in other Docutils components are merged to build
    the set of command-line options and runtime settings for this process.

    Common settings (defined below) and component-specific settings must not
    conflict.  Short options are reserved for common settings, and components
    are restrict to using long options.
    )z/etc/docutils.confz./docutils.confz~/.docutilsz(info 1 warning 2 error 3 severe 4 none 5rY   rp   r   r\   é   )ÚinfoÚwarningr   ÚsevereÚnoneTF)	Ú1ÚonÚyesÚtrueÚ0ÚoffÚnoÚfalseÚ r0   NrZ   r[   zGeneral Docutils Optionsz'Specify the document title as metadata.z--titlez2Include a "Generated by Docutils" credit and link.z--generatorz-gÚ
store_true)Úactionr–   z"Do not include a generator credit.z--no-generatorÚstore_falseÚ	generator)r¯   r™   z2Include the date at the end of the document (UTC).z--datez-dÚstore_constz%Y-%m-%dÚ	datestamp)r¯   Úconstr™   zInclude the time & date (UTC).z--timez-tz%Y-%m-%d %H:%M UTCz'Do not include a datestamp of any kind.z--no-datestampz&Include a "View document source" link.z--source-linkz-sz3Use <URL> for a source link; implies --source-link.z--source-urlÚmetavarz<URL>z-Do not include a "View document source" link.z--no-source-linkÚcallback)Úsource_linkÚ
source_url)r¯   r¶   Úcallback_argsz4Link from section headers to TOC entries.  (default)z--toc-entry-backlinksÚtoc_backlinksÚentry)r™   r¯   r´   r�   z0Link from section headers to the top of the TOC.z--toc-top-backlinksÚtop)r™   r¯   r´   z+Disable backlinks to the table of contents.z--no-toc-backlinks)r™   r¯   z6Link from footnotes/citations to references. (default)z--footnote-backlinks)r¯   r�   r–   z/Disable backlinks from footnotes and citations.z--no-footnote-backlinksÚfootnote_backlinksz0Enable section numbering by Docutils.  (default)z--section-numberingÚsectnum_xform)r¯   r™   r�   r–   z&Disable section numbering by Docutils.z--no-section-numberingz/Remove comment elements from the document tree.z--strip-commentsz6Leave comment elements in the document tree. (default)z--leave-commentsÚstrip_commentsz‹Remove all elements with classes="<class>" from the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)z--strip-elements-with-classr]   Ústrip_elements_with_classesz<class>)r¯   r™   rµ   r–   z”Remove all classes="<class>" attributes from elements in the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)z--strip-classÚstrip_classeszReport system messages at or higher than <level>: "info" or "1", "warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5"z--reportz-rÚreport_levelz<level>)Úchoicesr�   r™   rµ   r–   z4Report all system messages.  (Same as "--report=1".)z	--verbosez-vz3Report no system messages.  (Same as "--report=5".)z--quietz-qzdHalt execution at system messages at or above <level>.  Levels as in --report.  Default: 4 (severe).z--haltÚ
halt_level)rÃ   r™   r�   rµ   r–   z6Halt at the slightest problem.  Same as "--halt=info".z--strictzjEnable a non-zero exit status for non-halting system messages at or above <level>.  Default: 5 (disabled).z--exit-statusÚexit_status_levelz3Enable debug-level system messages and diagnostics.z--debugz Disable debug output.  (default)z
--no-debugÚdebugz-Send the output of system messages to <file>.z
--warningsÚwarning_streamz<file>)r™   rµ   z1Enable Python tracebacks when Docutils is halted.z--tracebackz%Disable Python tracebacks.  (default)z--no-tracebackÚ	tracebackziSpecify the encoding and optionally the error handler of input text.  Default: <locale-dependent>:strict.z--input-encodingz-iz<name[:handler]>)rµ   r–   zlSpecify the error handler for undecodable characters.  Choices: "strict" (default), "ignore", and "replace".z--input-encoding-error-handlerÚstrict)r�   r–   z^Specify the text encoding and optionally the error handler for output.  Default: UTF-8:strict.z--output-encodingz-oúutf-8)rµ   r�   r–   zŠSpecify error handler for unencodable output characters; "strict" (default), "ignore", "replace", "xmlcharrefreplace", "backslashreplace".z--output-encoding-error-handlerz}Specify text encoding and error handler for error output.  Default text encoding: system encoding. Default error handler: %s.z--error-encodingz-ezSSpecify the error handler for unencodable characters in error output.  Default: %s.z--error-encoding-error-handlerz<Specify the language (as BCP 47 language tag).  Default: en.z
--languagez-lÚlanguage_codeÚenz<name>)r™   r�   rµ   z)Write output file dependencies to <file>.z--record-dependencies)rµ   r–   r�   z6Read configuration settings from <file>, if it exists.z--configÚstring)rµ   Útyper¯   r¶   z,Show this program's version number and exit.z	--versionz-Vr¯   Úversionz Show this help message and exit.z--helpz-hÚhelpz--id-prefixr�   r­   z--auto-id-prefixÚidz--dump-settingsz--dump-internalsz--dump-transformsz--dump-pseudo-xmlz--expose-internal-attributeÚexpose_internals)r¯   r™   r–   z--strict-visitor)Ú_disable_configÚ_sourceÚ_destinationÚ_config_files)rÇ   Úgeneralz(%%prog (Docutils %s%s, Python %s, on %s)z [%s]r   r   c              
   O   sä   i | _ 	 g | _	 tjj| g|¢R tdtjdd�dœ|¤Ž | js$| j| _t	| j
ƒ| _
| ft|ƒ | _|  | j¡ |  |p=i ¡ |rn| jd spz|  ¡ }W n tye } z|  t|ƒ¡ W Y d}~nd}~ww |  |j¡ dS dS dS )z¶
        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.  `defaults` is a mapping of setting
        default overrides.
        NéN   )Úwidth)Úoption_classÚadd_help_optionÚ	formatterrÓ   )rˆ   Úconfig_filesr�   rŸ   r‚   r•   ÚTitledHelpFormatterrÏ   Úversion_templater@   Úrelative_path_settingsrw   Ú
componentsÚpopulate_from_componentsÚset_defaults_from_dictrŒ   Úget_standard_config_settingsr   r   r
   r†   )r…   rá   rŒ   Úread_config_filesr   r   Úconfig_settingsr   r   r   r   r‚   O  s:   ÿý
þý€ÿûzOptionParser.__init__c                 C   sî   |D ]a}|du r	q|j }| j |j¡ tdt|ƒdƒD ]G}|||d … \}}}|r7t | ||¡}|  |¡ n| }|D ]\}	}
}|j|
d|	i|¤Ž}| 	d¡dkrWd| j
|j< q;|jrb| j |j¡ qq|D ]}|rt|jrt| j |j¡ qfdS )aE  
        For each component, first populate from the `SettingsSpec.settings_spec`
        structure, then from the `SettingsSpec.settings_defaults` dictionary.
        After all components have been processed, check for and populate from
        each component's `SettingsSpec.settings_default_overrides` dictionary.
        Nr   r   rÐ   r¯   r]   T)rx   rà   rB   rv   r_   r�   ÚOptionGroupÚadd_option_groupÚ
add_optionÚgetrˆ   r™   Úsettings_defaultsrŒ   r   Úsettings_default_overrides)r…   rá   Ú	componentrx   rG   ÚtitleÚdescriptionÚoption_specÚgroupÚ	help_textÚoption_stringsr   r   r   r   r   râ   o  s:   ÿÿ€€ó
€þz%OptionParser.populate_from_componentsc                    s|   zt jd  t j¡}W n ty   | j}Y nw t jj‰ dt jvr5zddl}W n t	y4   dd„ ‰ Y nw ‡ fdd„|D ƒS )	z:Return list of config files, from environment or standard.ÚDOCUTILSCONFIGÚHOMEr   Nc                 S   s   | S rN   r   )Úxr   r   r   Ú<lambda>Ÿ  s    z8OptionParser.get_standard_config_files.<locals>.<lambda>c                    s   g | ]
}|  ¡ rˆ |ƒ‘qS r   rE   )rF   Úf©Úexpandr   r   rH      s    z:OptionParser.get_standard_config_files.<locals>.<listcomp>)
rm   Úenvironr.   Úpathsepr8   Ústandard_config_filesrg   Ú
expanduserÚpwdÚImportError)r…   rÝ   rÿ   r   rù   r   Úget_standard_config_filesŽ  s   
ÿ
ÿz&OptionParser.get_standard_config_filesc                 C   s*   t ƒ }|  ¡ D ]}| |  |¡| ¡ q|S rN   )r   r  r   r   )r…   rz   Úfilenamer   r   r   rä   ¢  s   z)OptionParser.get_standard_config_settingsc                 C   sž   t ƒ }| || ¡ | j |j¡ tj |¡}i }tƒ }| j	D ]%}|s#qt
|jp(dƒ|jf D ]}||v r5q.d||< | | |¡| ¡ q.qt|j| j|ƒ |jS )zAReturns a dictionary containing appropriate config file settings.r   rY   )ÚConfigParserÚreadrÝ   rB   Ú_filesrm   rg   Údirnamer   rá   rw   Úconfig_section_dependenciesr(   r   Úget_sectionrl   r†   rà   )r…   Úconfig_filer   ri   Úappliedrz   rí   Úsectionr   r   r   r   ¨  s*   
ÿû
ÿz%OptionParser.get_config_file_settingsc                 C   s,   |   |¡\|_|_t|j| jƒ | j|_|S )z/Store positional arguments as runtime settings.)Ú
check_argsrÔ   rÕ   rl   r†   rà   rÝ   rÖ   )r…   r   r   r   r   r   Úcheck_values½  s   zOptionParser.check_valuesc                 C   sh   d  }}|r|  d¡}|dkrd }|r|  d¡}|dkrd }|r%|  d¡ |r0||kr0|  d¡ ||fS )Nr   rq   zMaximum 2 arguments allowed.z_Do not specify the same file for both source and destination.  It will clobber the source file.)rA   r   )r…   r   ÚsourceÚdestinationr   r   r   r  Ä  s   



zOptionParser.check_argsc                 C   s   | j  |¡ d S rN   )rŒ   r   ©r…   rŒ   r   r   r   rã   Õ  s   z#OptionParser.set_defaults_from_dictc                 C   s   t | jƒ}| j|_|S )z(Needed to get custom `Values` instances.)r   rŒ   rÝ   rÖ   r  r   r   r   Úget_default_valuesØ  s   
zOptionParser.get_default_valuesc                 C   s@   | j | g D ]}|jD ]}|j|kr|    S qqtd| ƒ‚)a  
        Get an option by its dest.

        If you're supplying a dest which is shared by several options,
        it is undefined which option of those is returned.

        A KeyError is raised if there is no option with the supplied
        dest.
        zNo option with dest == %r.)Úoption_groupsÚoption_listr™   r8   )r…   r™   rñ   r   r   r   r   Úget_option_by_destÞ  s   


ÿÿzOptionParser.get_option_by_dest)r   NN)-r‘   r’   r“   r”   rý   r.   Úthreshold_choicesr=   r5   r‰   ÚsysÚstderrr	   Údefault_error_encodingÚ$default_error_encoding_error_handlerr9   r   rX   r?   r2   r+   rS   r    r   rD   rx   rë   rà   r(   rO   Ú__version__Ú__version_details__rÏ   Úplatformrß   r‚   râ   r  rä   r   r  r  rã   r  r  r   r   r   r   rŸ   s  s´   

ÿÿÿÿÿÿÿþÿû
ÿÿù
þÿöÿÿòÿÿï
ÿìÿþêÿþæ
þâ!þß$ÿþÜ(þØ+ÿþÕ/þÑ2þÎ5þË8ÿüÈ>ÿüÂD
þþ¼I
ÿÿ·L
ÿÿ´Oþþ±Tÿÿ¬Wýþ©]ÿ£_ÿ¡aÿŸcÿÿ�fÿšhÿý˜mý“qÿý�vüŠ{þÿü… þÿü �þ 
ÿÿ �ø ÿþ �õ ÿÿ �ñ ÿ �î ÿ �ì  �é  �è  �æ  �å  �ä  �ã ÿÿ �â ! �ßý &ýÿýÿ
 rŸ   c                   @   sR   e Zd ZddddœZ	 dZdZdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ ZdS )r  )úpep_html writerÚ
stylesheet)r  Ústylesheet_path)r  Útemplate)Úpep_stylesheetÚpep_stylesheet_pathÚpep_templatea  
The "[option]" section is deprecated.  Support for old-format configuration
files may be removed in a future Docutils release.  Please revise your
configuration files.  See <http://docutils.sf.net/docs/user/config.html>,
section "Old-Format Configuration Files".
zhUnable to read configuration file "%s": content not encoded as UTF-8.
Skipping "%s" configuration file.
c                 O   s,   t j| g|¢R i |¤Ž g | _	 tƒ | _d S rN   )r   r‚   r  r   Ú_stderrr„   r   r   r   r‚     s
   zConfigParser.__init__c              	   C   sÜ   t |ƒttfv r|g}|D ]^}z	t |dd¡}W n	 ty!   Y qw ztjdk r0t 	| ||¡ nt 
| ||¡ W n tyP   | j | j||f ¡ | ¡  Y qw | ¡  | j |¡ |  d¡re|  |¡ |  ||¡ qd S )NÚrrÊ   r   Úoptions)rÎ   ÚstrÚunicoder!   ÚopenrR   r  Úversion_infor   ÚreadfpÚ	read_fileÚUnicodeDecodeErrorr$  ÚwriteÚnot_utf8_errorÚcloser  r]   Úhas_sectionÚhandle_old_configÚvalidate_settings)r…   Ú	filenamesr&   r  Úfpr   r   r   r    s0   ÿ
€ý

ízConfigParser.readc                 C   s    t  | jt|d¡ |  d¡}|  d¡s|  d¡ | ¡ D ],\}}|| jv r7| j| \}}|  |¡s6|  |¡ nd}|}|  	||¡sH|  
|||¡ q|  d¡ d S )Nr   r&  r×   )ÚwarningsÚwarn_explicitÚold_warningÚConfigDeprecationWarningr  r1  Úadd_sectionr   Úold_settingsÚ
has_optionr/   Úremove_section)r…   r  r&  r   r   r  r%   r   r   r   r2  %  s$   
ÿ





€€zConfigParser.handle_old_configc           	      C   sÆ   |   ¡ D ]\}|  |¡D ]T}z| |¡}W n	 ty   Y qw |jrT|  ||¡}z|j|||| |d�}W n tyL } ztd||t|ƒ||f ƒ‚d}~ww |  	|||¡ |j
r_|  	||j
d¡ qqdS )zi
        Call the validator function and implement overrides on all applicable
        settings.
        )r'   r(   zAError in config file "%s", section "[%s]":
    %s
        %s = %sN)Úsectionsr&  r  r8   r–   rê   rš   r   r   r/   r—   )	r…   r  r&   r  r%   r   r   r�   r   r   r   r   r3  7  s<   ÿ
þ
ÿýÿ€ÿ€ìÿzConfigParser.validate_settingsc                 C   s   |  ¡  dd¡S )zW
        Transform '-' to '_' so the cmdline form of option names can be used.
        rq   rr   )r7   rt   )r…   Ú	optionstrr   r   r   ÚoptionxformS  s   zConfigParser.optionxformc                 C   s2   i }|   |¡r|  |¡D ]
}|  ||¡||< q|S )zf
        Return a given section as a dictionary (empty if the section
        doesn't exist).
        )r1  r&  rê   )r…   r  Úsection_dictr   r   r   r   r  Y  s
   
zConfigParser.get_sectionN)r‘   r’   r“   r;  r8  r/  r‚   r  r2  r3  r@  r  r   r   r   r   r  ï  s    ý	r  c                   @   s   e Zd ZdZdS )r9  z3Warning for deprecated configuration file features.N)r‘   r’   r“   r”   r   r   r   r   r9  e  s    r9  )NNrN   )1r”   Ú__docformat__rm   Úos.pathr  r6  r!   r�   r   r*  Úconfigparserr   r   r  r   rO   Údocutils.utilsÚdocutils.nodesÚdocutils.utils.error_reportingr	   r
   r   r   r'  r(  r   r    r)   r+   r2   r9   r:   r<   r?   rD   rJ   rM   rS   rX   re   rl   rf   r~   r   r•   rŸ   ÚSettingsSpecÚDeprecationWarningr9  r   r   r   r   Ú<module>   st   


ÿ

ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿ

ÿ
ÿ

ÿ
ÿ
ÿ
#&  ~v