3 ª fxã @sždZddlmZddlmZyTddlmZddlmZddl m Z ddl m Z ddl m Z Gd d „d eƒZd ZWnek rˆd ZYnXGd d„deƒZdS)zCdistutils.command.check Implements the Distutils 'check' command. é)ÚCommand)ÚDistutilsSetupError)ÚReporter)ÚParser)Úfrontend)Únodes)ÚStringIOc@seZdZd dd„Zdd„ZdS) ÚSilentReporterNrÚasciiÚreplacec Cs"g|_tj||||||||ƒdS)N)ÚmessagesrÚ__init__)ÚselfÚsourceÚ report_levelÚ halt_levelÚstreamÚdebugÚencodingÚ error_handler©rú}|djdƒ}|dkr:|d}nd|d|f}|j|ƒqWdS)z4Checks if the long string fields are reST-compliant.r+ÚlineNz %s (line %s)éÿÿÿÿ)r8Zget_long_descriptionÚ_check_rst_dataÚgetr/)rÚdataZwarningr=rrrr3ns  zcheck.check_restructuredtextcCsÀtƒ}tƒ}tjtfd�jƒ}d|_d|_d|_t||j |j |j |j |j |jd�}tj|||d�}|j|d ƒy|j||ƒWn:tk r¸}z|jjd d|difƒWYdd}~XnX|jS) z8Returns warnings when the provided data doesn't compile.)Z componentséN)rrrr)rr+z!Could not finish the parsing: %s.Úr>r>)rrrZ OptionParserZget_default_valuesZ tab_widthZpep_referencesZrfc_referencesr rrZwarning_streamrZerror_encodingZerror_encoding_error_handlerrÚdocumentZ note_sourceÚparseÚAttributeErrorr r)rrAÚ source_pathÚparserZsettingsZreporterrDÚerrrr?ys*  $zcheck._check_rst_dataN)r"r#r$)r%r&r')r(r)r*)rrr Ú__doc__Z descriptionZ user_optionsZboolean_optionsr-r.r/r4r1r3r?rrrrr!$s  r!N)rJZdistutils.corerZdistutils.errorsrZdocutils.utilsrZdocutils.parsers.rstrZdocutilsrrÚiorr r2Ú Exceptionr!rrrrÚs