Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/Doc/tools/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/Doc/tools/__pycache__/rstlint.cpython-34.pyc

�
e f��g@s�ddlmZddlZddlZddlZddlZddlmZmZm	Z	m
Z
ddlmZddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8dd9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d#d]d^d_d`dadbdcdddedfdgdhdiggZ
djdkje
�dlZejdme�Zejdn�Zejdo�ZiZidpdq6drds6Zdtdu�Zedvdqdw�dxdy��Zedzdqd{�d|d}��Zedvdz�d~d��Zedzdqd�d�d���Zed�dqd{dsd��d�d���Zd�d��Zed�kr�ejeej��ndS)��)�with_statementN)�join�splitext�abspath�exists)�defaultdictZ
admonitionZ	attentionZcaution�classZcompoundZ	container�contentsz	csv-tableZdangerZdatezdefault-roleZepigraph�errorZfigureZfooter�headerZ
highlightsZhintZimageZ	important�includez
line-blockz
list-table�metaZnotezparsed-literalz
pull-quote�raw�replacezrestructuredtext-test-directiveZroleZrubricZsectnumZsidebar�tableztarget-notesZtip�titleZtopicZunicodeZwarningZacksZ	attributeZ
autoattributeZ	autoclassZautodataZ
autoexceptionZautofunctionZ
automethodZ
automoduleZcenteredZ	cfunction�classmethodZcmacroZ	cmdoptionZcmemberz
code-blockZconfvalZcssclassZctypeZ
currentmoduleZcvar�dataZ	decoratorZdecoratormethodzdeprecated-removedzdeprecated(?!-removed)ZdescribeZ	directiveZdoctestZenvvarZeventZ	exceptionZfunctionZglossaryZ	highlightZ
highlightlangzimpl-detail�indexZliteralinclude�methodZmiscnews�moduleZmoduleauthorZopcodeZ
pdbcommandZproductionlistZprogramZ
sectionauthorZseealsoZ
sourcecode�staticmethodZtabularcolumnsZtestcodeZ
testoutputZ	testsetupZtoctreeZtodoZtodolistZversionaddedZversionchanged�(�|�)z\.\. %s([^a-z:]|:(?!:))z(^| )`\w([^`]*?\w)?`($| )z[a-z]::\s|`|\.\.\s*\w+:��severityF�falsepositivescs��fdd�}|S)z.Decorator to register a function as a checker.cs_x'�D]}tj|g�j|�qWx.tD]&}t||�j|t|��q1W|S)N)�checkers�
setdefault�append�
checker_props�setattr�get)�func�suffixZprop)�kwds�suffixes��6/opt/alt/python34/lib64/python3.4/Doc/tools/rstlint.py�deco:s


$zchecker.<locals>.decor()r'r&r*r()r&r'r)�checker8sr+z.py�ccs�dj|�}d|krGtjdkr2d	Vn|jdd�}nyt||d�Wn7tk
r�}z|jd|fVWYdd}~XnXdS)
z'Check Python examples for valid syntax.��
�ntr�\r in code file�execznot compilable: %sN)rr0)r�os�namer�compile�SyntaxError�lineno)�fn�lines�code�errr(r(r)�check_syntaxCsr;z.rst�ccs�d}x�t|�D]�\}}tj|�r@|ddfVnd|krUd}q|r}tj|�r}|ddfVq|r|j�rd}qqWdS)z%Check for suspicious reST constructs.Frz+comment seems to be intended as a directivez.. productionlist::Tzdefault role usedN)�	enumerate�seems_directive_re�match�default_role_re�search�strip)r7r8Zinprod�lno�liner(r(r)�check_suspicious_constructsQs	rEccs�x�t|�D]�\}}d|kr7|ddfVnd|krU|ddfVn|dd	�jd�|dd
�kr
|ddfVq
q
WdS)z,Check for whitespace and line length issues.r.rz
\r in line�	zOMG TABS!!!1Nz 	ztrailing whitespace���rG)r=�rstrip)r7r8rCrDr(r(r)�check_whitespace`s)rIccs�xyt|�D]k\}}t|�dkr
|j�ddkrxd|krx|j�jd�rx|dd	fVqxq
q
Wd
S)z:Check for line length; this checker is not run by default.�Qrz+|zhttp://�.. function�	.. method�.. cfunctionrz
line too longN)rKrLrM)r=�len�lstrip�
startswith)r7r8rCrDr(r(r)�check_line_lengthls
rQz.htmlTccsFx?t|�D]1\}}tj|�r
|dd|fVq
q
WdS)zdCheck HTML files for leaked reST markup; this only works if
    the HTML files have been built.
    rzpossibly leaked markup: %rN)r=�leaked_markup_rerA)r7r8rCrDr(r(r)�check_leaked_markupzsrSc Cs�d|d}y&tj|dd�d�\}}Wn#tjk
rYt|�dSYnXd}d}g}d}x{|D]s\}}	|dkr�d}qy|d	kr�d}qy|d
kr�t|	�}qy|dkry|jt|	��qyqyWt|�dkrd}
n-t|�dkr*|d}
nt|�dSt|
�sVtd
|
�dStt�}x�t	j
|
�D]�\}}
}t|�|kr�|
dd�=qrnx�|D]�}t||�}|dd�dkr�|dd�}nt|�|krq�nt|�d}t
j|d�}|s1q�n|rHtd|�ny.t|ddd��}t|�}WdQXWnPttfk
r�}z*td||f�|dd7<w�WYdd}~XnXx�|D]|}|jr�|r�q�n|j}||kr�xH|||�D]4\}}td||||f�||d7<qWq�q�Wq�WqrW|rht�n|s�|dkr�td|�q�td�nJxGt|�D]9}||}td||dkr�dp�d|f�q�Wtt|��S)NaUsage: %s [-v] [-f] [-s sev] [-i path]* [path]

Options:  -v       verbose (print all checked file names)
          -f       enable checkers that yield many false positives
          -s sev   only show problems with severity >= sev
          -i path  ignore subdir or file path
rrzvfs:i:r<Fz-vTz-fz-sz-i�.zError: path %s does not existz./zChecking %s...�r�encodingzutf-8z%s: cannot open: %sr,z[%d] %s:%d: %sz&No problems with severity >= %d found.zNo problems found.z$%d problem%s with severity %d found.�sr-)�getoptZGetoptError�print�intr rrNrrr2�walkrrrr#�open�list�IOError�OSErrorrr�sorted�bool)�argvZusageZgopts�args�verboser�ignoreZfalseposZopt�val�path�count�root�dirs�filesr7ZextZcheckerlist�fr8r:r+ZcsevrC�msgZnumberr(r(r)�main�s�&
				




	!


'rn�__main__)Z
__future__rr2�re�sysrXZos.pathrrrr�collectionsrZ
directivesZall_directivesr4r>r@rRrr!r+r;rErIrQrSrn�__name__�exitrbr(r(r(r)�<module>sP"$
a