ó
è¾bc           @   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   sB   |  j  j | | | | f ƒ t j | d | d |  j | | | ŽS(   Nt   levelt   type(   R   t   appendR   t   system_messaget   levels(   R   R   t   messaget   childrent   kwargs(    (    s-   /usr/lib/python2.7/distutils/command/check.pyR      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_options3   s    			c         C   s   d  S(   N(    (   R   (    (    s-   /usr/lib/python2.7/distutils/command/check.pyt   finalize_options:   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   runB   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(   R0   R1   R2   (   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,   R   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(
   R3   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.   p   s    c         C   s  |  j  j p d } t ƒ  } t j d t f ƒ j ƒ  } d | _ d | _ d | _	 t
 | | j | j d | j d | j d | j d | j ƒ} t j | | d | ƒ} | j | d	 ƒ y | j | | ƒ Wn3 t k
 rþ } | j j d	 d
 | d i  f ƒ n X| j S(   s8   Returns warnings when the provided data doesn't compile.s   setup.pyt
   componentsi   R   R   R   R   R   iÿÿÿÿs!   Could not finish the parsing: %s.t    N(   R3   t   script_nameR   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   RD   t   source_patht   parsert   settingst   reporterRQ   t   e(    (    s-   /usr/lib/python2.7/distutils/command/check.pyRB   }   s*    									(   R!   R"   s   Verify meta-data(   R#   R$   sE   Checks if long string meta-data syntax are reStructuredText-compliant(   R%   R&   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.   RB   (    (    (    s-   /usr/lib/python2.7/distutils/command/check.pyR    &   s     							N(   RZ   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   

