B 0h@sddlZddlZddlZddlZddlmZmZmZmZddl m Z dddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8dd9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d"d]d^d_d`dadbdcdddedfdgdhdighZ djdke dlZ e dme Ze dnZe doZiZdpdqdrZdsdtZedudvdwdxdyZedzd{dwd|d}Zedudzd~dZedzddwddZedd{ddrddZddZedkreeejdS)N)joinsplitextabspathexists) defaultdictZ admonitionZ attentionZcautionclassZcompoundZ containercontentsz csv-tableZdangerZdatez default-roleZepigrapherrorZfigureZfooterheaderZ highlightsZhintZimageZ importantZincludez line-blockz list-tablemetaZnotezparsed-literalz pull-quoterawreplacezrestructuredtext-test-directiveZroleZrubricZsectnumZsidebartablez target-notesZtiptitleZtopicZunicodeZwarningZacksZ attributeZ autoattributeZ autoclassZautodataZ autoexceptionZ autofunctionZ automethodZ automoduleZ availabilityZcenteredZ cfunction classmethodZcmacroZ cmdoptionZcmemberz code-blockZconfvalZcssclassZctypeZ currentmoduleZcvardataZ decoratorZdecoratormethodzdeprecated-removedzdeprecated(?!-removed)ZdescribeZ directiveZdoctestZenvvarZeventZ exceptionZfunctionZglossaryZ highlightZ highlightlangz impl-detailindexZliteralincludemethodZmiscnewsmoduleZ moduleauthorZopcodeZ pdbcommandZproductionlistZprogramZ sectionauthorZseealsoZ sourcecode staticmethodZtabularcolumnsZtestcodeZ testoutputZ testsetupZtoctreeZtodoZtodolistZ versionaddedZversionchanged(|)z(?.decor&)r%r$r(r&)r$r%r'checker7sr)z.py)rc csvd|}d|kr.tjdkr"dV|dd}yt||dWn2tk rp}z|jd|fVWdd}~XYnXdS)z'Check Python examples for valid syntax. nt)rz\r in code fileexecznot compilable: %sN)rosnamer compile SyntaxErrorlineno)fnlinescodeerrr&r&r' check_syntaxBs   r8z.rstccsrd}xht|D]\\}}t|r.|ddfVd|kr|ddfV|ddd|ddkr |dd fVq WdS) z,Check for whitespace and line length issues.r,rz \r in line z OMG TABS!!!1Nz ztrailing whitespace)r:rstrip)r4r5r?r@r&r&r'check_whitespace_srEccsZxTt|D]H\}}t|dkr |ddkr d|kr |ds |ddfVq WdS) z:Check for line length; this checker is not run by default.Qrz+|zhttp://)z .. functionz .. methodz .. cfunctionrz line too longN)r:lenlstrip startswith)r4r5r?r@r&r&r'check_line_lengthks  rJz.htmlTccs6x0t|D]$\}}t|r |dd|fVq 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_rer<)r4r5r?r@r&r&r'check_leaked_markupys rLc Cs"d|d}yt|ddd\}}Wntjk rFt|dSXd}d}g}d}xT|D]L\}} |dkrtd}q^|d krd}q^|d krt| }q^|d kr^|t| q^Wt|dkrd } n"t|dkr|d} n t|dSt| std | dStt} xt | D]\} } }t| |kr8| dd=qxb|D]X}t | |}|dddkrn|dd}t||krq@t |d}t |d}|sq@|rtd|y&t|ddd}t|}WdQRXWnLttfk r&}z(td||f| dd7<w@Wdd}~XYnXxn|D]f}|jrD|sDq.|j}||kr.x<|||D].\}}td||||f| |d7<q`Wq.Wq@WqW|rt| s|dkrtd|ntdn>x= sev -i path ignore subdir or file path rrzvfs:i:r9Fz-vTz-fz-sz-i.zError: path %s does not existz./zChecking %s...rzutf-8)encodingz%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+)getoptZ GetoptErrorprintintrrrGrrr/walkrrrr!openlistIOErrorOSErrorrrsortedbool)argvZusageZgoptsargsverboserignoreZfalseposZoptvalpathcountrootdirsfilesr4ZextZ checkerlistfr5r7r)Zcsevr?msgZnumberr&r&r'mains              (  $rg__main__)r/resysrQZos.pathrrrr collectionsrZ directivesZall_directivesr1r;r=rKrrr)r8rArErJrLrg__name__exitr[r&r&r&r' sP                     a