ó
!Xc           @   sà   d  Z  d Z d d l m Z d d l m Z d d l m Z yp d d l m	 Z	 d d l
 m Z d d l m Z d d	 l m Z d d
 l m Z d e	 f d     YZ e Z Wn e k
 rĊ e Z n Xd e f d     YZ d S(   sC   distutils.command.check

Implements the Distutils 'check' command.
s   $Id$i˙˙˙˙(   t   Command(   t   PKG_INFO_ENCODING(   t   DistutilsSetupError(   t   Reporter(   t   Parser(   t   frontend(   t   nodes(   t   StringIOt   SilentReporterc           B   s&   e  Z d d  d d d  Z d   Z RS(   i    t   asciit   replacec      	   C   s/   g  |  _  t j |  | | | | | | |  d  S(   N(   t   messagesR   t   __init__(   t   selft   sourcet   report_levelt
   halt_levelt   streamt   debugt   encodingt   error_handler(    (    s-   /usr/lib/python2.7/distutils/command/check.pyR      s    	c         O   s    |  j  j | | | | f  d  S(   N(   R   t   append(   R   t   levelt   messaget   childrent   kwargs(    (    s-   /usr/lib/python2.7/distutils/command/check.pyt   system_message   s    N(   t   __name__t
   __module__t   NoneR   R   (    (    (    s-   /usr/lib/python2.7/distutils/command/check.pyR      s   t   checkc           B   sq   e  Z d  Z d Z d d d g Z d d d g Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z RS(   s6   This command checks the meta-data of the package.
    s"   perform some checks on the packaget   metadatat   ms   Verify meta-datat   restructuredtextt   rsE   Checks if long string meta-data syntax are reStructuredText-compliantt   strictt   ss(   Will exit with an error if a check failsc         C   s(   d |  _  d |  _ d |  _ d |  _ d S(   s    Sets default values for options.i    i   N(   R!   R   R#   t	   _warnings(   R   (    (    s-   /usr/lib/python2.7/distutils/command/check.pyt   initialize_options0   s    			c         C   s   d  S(   N(    (   R   (    (    s-   /usr/lib/python2.7/distutils/command/check.pyt   finalize_options7   s    c         C   s   |  j  d 7_  t j |  |  S(   s*   Counts the number of warnings that occurs.i   (   R%   R    t   warn(   R   t   msg(    (    s-   /usr/lib/python2.7/distutils/command/check.pyR(   :   s    c         C   sx   |  j  r |  j   n  |  j rM t r2 |  j   qM |  j rM t d   qM n  |  j rt |  j d k rt t d   n  d S(   s   Runs the command.s   The docutils package is needed.i    s   Please correct your package.N(   R   t   check_metadataR!   t   HAS_DOCUTILSt   check_restructuredtextR#   R   R%   (   R   (    (    s-   /usr/lib/python2.7/distutils/command/check.pyt   run?   s    			c         C   sß   |  j  j } g  } x< d D]4 } t | |  o: t | |  s | j |  q q W| rt |  j d d j |   n  | j r | j sÛ |  j d d  qÛ n> | j	 rĈ | j
 sÛ |  j d d	  qÛ n |  j d
 d d  d S(   sÏ   Ensures that all required elements of meta-data are supplied.

        name, version, URL, (author and author_email) or
        (maintainer and maintainer_email)).

        Warns if any are missing.
        t   namet   versiont   urls   missing required meta-data: %ss   , s)   missing meta-data: if 'author' supplied, s#   'author_email' must be supplied toos-   missing meta-data: if 'maintainer' supplied, s'   'maintainer_email' must be supplied toos4   missing meta-data: either (author and author_email) s%   or (maintainer and maintainer_email) s   must be suppliedN(   s   names   versionR0   (   t   distributionR   t   hasattrt   getattrR   R(   t   joint   authort   author_emailt
   maintainert   maintainer_email(   R   R   t   missingt   attr(    (    s-   /usr/lib/python2.7/distutils/command/check.pyR*   O   s$    						c         C   s   |  j  j   } t | t  s0 | j t  } n  xd |  j |  D]S } | d j d  } | d k rr | d } n d | d | f } |  j	 |  q@ Wd S(   s4   Checks if the long string fields are reST-compliant.i˙˙˙˙t   linei   s   %s (line %s)N(
   R1   t   get_long_descriptiont
   isinstancet   unicodet   decodeR   t   _check_rst_datat   getR   R(   (   R   t   datat   warningR;   (    (    s-   /usr/lib/python2.7/distutils/command/check.pyR,   m   s    c         C   sî   t    } t   } t j   j   } d | _ d
 | _ d
 | _ t	 | | j
 | j d | j d | j d | j d | j } t j | | d | } | j | d  y | j | |  Wn- t k
 rĉ | j j d d d	 i  f  n X| j S(   s8   Returns warnings when the provided data doesn't compile.i   R   R   R   R   R   i˙˙˙˙s   Could not finish the parsing.t    N(   R   R   R   t   OptionParsert   get_default_valuest	   tab_widthR   t   pep_referencest   rfc_referencesR   R   R   t   warning_streamR   t   error_encodingt   error_encoding_error_handlerR   t   documentt   note_sourcet   parset   AttributeErrorR   R   (   R   RB   t   source_patht   parsert   settingst   reporterRM   (    (    s-   /usr/lib/python2.7/distutils/command/check.pyR@   z   s*    									(   s   metadataR    s   Verify meta-data(   s   restructuredtextR"   sE   Checks if long string meta-data syntax are reStructuredText-compliant(   s   strictR$   s(   Will exit with an error if a check fails(   R   R   t   __doc__t   descriptiont   user_optionst   boolean_optionsR&   R'   R(   R-   R*   R,   R@   (    (    (    s-   /usr/lib/python2.7/distutils/command/check.pyR   #   s     							N(   RU   t   __revision__t   distutils.coreR    t   distutils.distR   t   distutils.errorsR   t   docutils.utilsR   t   docutils.parsers.rstR   t   docutilsR   R   R   R   t   TrueR+   t   ImportErrort   FalseR   (    (    (    s-   /usr/lib/python2.7/distutils/command/check.pyt   <module>   s   

