Your IP : 216.73.216.213
B
7��]� � @ s� d Z dZddlZddlZddlZddlZddlZddlZddl Z ddl m
Z
ddlZddlZddl
ZddlmZmZmZmZ dd� Zdd � Zd4d
d�Zd5dd
�Zd6dd�Zd7dd�Zd8dd�Zd9dd�Zd:dd�Zd;dd�Zd<dd�Zd=dd�Zd>dd�Zd?d d!�Z d@d"d#�Z!dAd$d%�Z"d&d'� Z#d(d)� Z$G d*d+� d+e j%�Z%G d,d-� d-e j&�Z&G d.d/� d/e j'ej(�Z'G d0d1� d1ej)�Z*G d2d3� d3e+�Z,dS )Ba�
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_string_list`,
`validate_comma_separated_string_list`,
`validate_dependency_file`.
* `make_paths_absolute`.
* SettingSpec manipulation: `filter_settings_spec`.
ZreStructuredText� N)�
SUPPRESS_HELP)�locale_encoding�
SafeString�ErrorOutput�ErrorStringc O sH x|D ]}t |j|d� qW x&t|�� �D ]\}}t |j||� q*W dS )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�list�items)�option�opt�value�parser�args�kwargsZ attribute�key� r �B/opt/alt/python37/lib/python3.7/site-packages/docutils/frontend.py�store_multiple/ s
r c
C sN y|� |�}W n, tk
r: } z|�|� W dd}~X Y nX |j�||� dS )zQ
Read a configuration file during option processing. (Option callback.)
N)�get_config_file_settings�
ValueError�errorr �update)r r r
r Znew_settingsr r r r �read_config_file; s
r c C s8 yt �|� W n$ tk
r2 td| |f ��Y nX |S )Nz$setting "%s": unknown encoding: "%s")�codecs�lookup�LookupError)�settingr
�
option_parser�
config_parser�config_sectionr r r �validate_encodingE s r! c C s4 yt �|� W n tk
r. td| ��Y nX |S )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 r r r r �validate_encoding_error_handlerN s r# c C sn d|krV|� d�\}}t| d ||||� |rB|�|| d |� qZt|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.
�:Z_error_handler)�splitr# �setr r r! )r r
r r r �encoding�handlerr r r �#validate_encoding_and_error_handlerZ s
r) c C sF t |t�r|S y|j|�� �� S tk
r@ td| ��Y nX dS )z|Check/normalize boolean settings:
True: '1', 'on', 'yes', 'true'
False: '0', 'off', 'no','false', ''
zunknown boolean value: "%s"N)�
isinstance�bool�booleans�strip�lower�KeyErrorr )r r
r r r r r r �validate_booleanp s
r0 c C sB t |t�s|dkr|S y|j|�� �� S tk
r< |S X dS )z�Check/normalize three-value settings:
True: '1', 'on', 'yes', 'true'
False: '0', 'off', 'no','false', ''
any other value: returned as-is.
N)r* r+ r, r- r. r/ )r r
r r r r r r �validate_ternary} s r1 c C s t |�}|dk rtd��|S )Nr z(negative value; must be positive or zero)�intr )r r
r r r r r r �validate_nonnegative_int� s r3 c C sV yt |�S tk
rP y|j|�� S ttfk
rJ td| ��Y nX Y nX d S )Nzunknown threshold: %r.)r2 r �
thresholdsr. r/ �AttributeErrorr )r r
r r r r r r �validate_threshold� s r6 c C s2 t |t�s|�d�}n|�� }|�|�d�� |S )Nr$ )r* r r% �pop�extend)r r
r r r �lastr r r �$validate_colon_separated_string_list� s
r: c C s: t |t�s|g}|�� }dd� |�d�D �}|�|� |S )zHCheck/normalize list arguments (split at "," and strip whitespace).
c S s g | ]}|� d �r|� d ��qS )z
)r- )�.0�ir r r �
<listcomp>� s z1validate_comma_separated_list.<locals>.<listcomp>�,)r* r r7 r% r8 )r r
r r r r9 r
r r r �validate_comma_separated_list� s
r? c C s"