ó
'![c           @   s}   d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d   Z d e j	 f d     YZ
 d	   Z d S(
   s'   Looks for  comparisons to empty string.i˙˙˙˙N(   t
   interfaces(   t   checkers(   t   utilsc         C   s   t  |  t j  o |  j d k S(   Ni    (   t
   isinstancet   astroidt   Constt   value(   t   node(    (    s>   lib/python2.7/site-packages/pylint/extensions/comparetozero.pyt   _is_constant_zero   s    t   CompareToZeroCheckerc           B   sQ   e  Z d  Z e j f Z d Z i d d 6Z d Z d Z	 e
 j d  d    Z RS(	   sê   Checks for comparisons to zero.
    Most of the times you should use the fact that integers with a value of 0 are false.
    An exception to this rule is when 0 is allowed in the program and has a
    different meaning than None!
    s   compare-to-zeros   Avoid comparisons to zeros4   Used when Pylint detects comparison to a 0 constant.t   C2001iŝ˙˙˙c   	      C   s  d d d d g } d | j  f g } | j | j  t t j |    } xĥ t t |  d  D] } | | } | | d } | | d } t } t	 |  rş | | d g k rş t
 } n( | | d	 g k râ t	 |  râ t
 } n  | r` |  j d
 d | q` q` Wd  S(   Ns   !=s   ==s   is nott   ist    i   i   t   <t   >s   compare-to-zeroR   (   t   leftt   extendt   opst   listt	   itertoolst   chaint   ranget   lent   FalseR   t   Truet   add_message(	   t   selfR   t
   _operatorsR   t   ops_idxt   op_1t   op_2t   op_3t   error_detected(    (    s>   lib/python2.7/site-packages/pylint/extensions/comparetozero.pyt   visit_compare*   s    
		(   s   Avoid comparisons to zeros   compare-to-zeros4   Used when Pylint detects comparison to a 0 constant.(    (   t   __name__t
   __module__t   __doc__R    t   IAstroidCheckert   __implements__t   namet   msgst   priorityt   optionsR   t   check_messagesR!   (    (    (    s>   lib/python2.7/site-packages/pylint/extensions/comparetozero.pyR	      s    
c         C   s   |  j  t |    d S(   s.   Required method to auto register this checker.N(   t   register_checkerR	   (   t   linter(    (    s>   lib/python2.7/site-packages/pylint/extensions/comparetozero.pyt   registerF   s    (   R$   R   R   t   pylintR    R   t   pylint.checkersR   R   t   BaseCheckerR	   R.   (    (    (    s>   lib/python2.7/site-packages/pylint/extensions/comparetozero.pyt   <module>   s   	/