ó
'![c           @   sü   d  Z  d d l Z d d l m Z d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ	 d d „ Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   s*   test for Python 3 string formatting error
iÿÿÿÿN(   t   Missingi   t   Customc           B   s   e  Z d  Z d „  Z RS(   s    Has a __getattr__ c         C   s   |  S(   N(    (   t   selft   _(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   __getattr__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyR   	   s   t   Testc           B   s2   e  Z d  Z e ƒ  Z d d d d d d g g Z RS(   s    test format attribute access i   i   i   i   i   i   (   R   R   R   R   t   customt   ids(    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyR      s   	t   Getitemc           B   s   e  Z d  Z d „  Z RS(   s'    test custom getitem for lookup access c         C   s   d S(   Ni*   (    (   R   t   index(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   __getitem__   s    (   R   R   R   R   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyR      s   t	   ReturnYesc           B   s   e  Z d  Z e ƒ  Z RS(   s    can't be properly infered (   R   R   R   R    t   missing(    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyR      s   t   errorc         C   s   |  S(   s    Test (    (   t   messaget   message_type(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   log   s    c           C   s{  d j  d d ƒ d j  d ƒ d j  d ƒ d j  d d ƒ d	 j  d
 t j ƒ  ƒ t d ƒ j  d ƒ d j  t ƒ  ƒ d j  t ƒ  ƒ d j  d t ƒ  ƒ d j  d d g g ƒ d j  i i d d 6d 6ƒ d j  d t ƒ  ƒ d j  d g  ƒ d j  d t ƒ  ƒ d j  d t ƒ  ƒ d j  d t ƒ  g ƒ d j  d g ƒ d j  d d g Œ  d j  i d d 6d d 6  d j  d t ƒ  ƒ d S(   s    Good format strings s   {0} {1}i   i   s   {0!r:20}t   Hellos   {!r:20}s   {a!r:20}t   as   {pid}t   pids   {}s   {0.missing.length}s   {1.missing.length}s   {a.ids[3][1]}s	   {a[0][0]}s   {[0][0]}i    s   {a.test}s   {a.__len__}s   {a.ids.__len__}s   {a[0]}t   tests   {a} {b}t   bs   {a}N(	   t   formatt   ost   getpidt   strR   R   R   R   R    (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt
   print_good    s(    c           C   s°  d j  d ƒ d j  ƒ  d j  ƒ  d j  d d ƒ d j  d d d	 d ƒ d
 j  d d ƒ d j  d ƒ d j  d d d ƒ d j  ƒ  d j  d d d d ƒ d j  d d ƒ d j  d d d ƒ d j  d t ƒ  ƒ d j  d t ƒ  ƒ d j  d t ƒ  ƒ d j  d g ƒ d j  d# ƒ d j  d d ƒ d j  d t ƒ t d j  d d ƒ ƒ d j  d ƒ d j  d d ƒ d j  d d d ƒ d j  d d ƒ d j  d g ƒ d j  d g d  d! ƒ d" S($   s   Test string format s   {{}}i   s   {} {s   {} }s   {0} {}i   s   {a} {b}R   t   cs   {} {a}s   {} {}i   s   {a} {b} {c}R   s   {0} {1} {a}s   {a.ids.__len__.length}s   {a.ids[3][400]}s   {a.ids[3]['string']}s   {[0][1]}s   {[0][0]}s   {b[0]}i   s   {a[0]}s   {}t   infos   {0.missing}s   {0} {1} {2}s   {0} {1}s   {0} {a}i   s   {[0]} {}i   i   N(   i   (   R   R   t   objectR   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt
   pprint_bad8   s4    


c          O   s   d j  |  ƒ d j  | ƒ d S(   s@    Test that using kwargs does not emit a false
    positive.
    s   Hello John Doe {0[0]}s   Hello {0[name]}N(   R   (   t   argst   kwargs(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   good_issue288Z   s    c          C   s>   d }  i d d 6} d | d <| d j  |  ƒ | d <| |  f S(   s‡    Test that the string format checker skips
    format nodes which don't have a string as a parent
    (but a subscript, name etc).
    t   qwertyt    t   comments$   MySQL grant {0} is set to be revoked(   R   (   t   namet   ret(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   good_issue287a   s
    
c           C   s}   d j  d d ƒ d j  d d d d g ƒd j  d d ƒ d j  d ƒ d j  d d d	 ƒ d
 j  d ƒ d j  d d d ƒd S(   s    Test nested format fields. s   {0:>{1}}i*   i   s   {0:{a[1]}} {a}i   R   i   s   {:>{}}i6   s
   {0:{a[1]}}s	   {0:{a.x}}N(   R   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   nested_issue294l   s    c           C   s!   d j  d d ƒ d j  d ƒ d S(   s>    Test a regression using duplicate manual position arguments. s   {0} {1} {0}i   i   N(   R   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   issue310v   s    c           C   sB   d j  d i d d 6ƒ d j  d i d d 6d ƒ d j  d ƒ d S(   sa    Test a regression using mixed manual position arguments
    and attribute access arguments.
    s   {0}{1[FOO]}i{   iÈ  t   FOOiA  N(   R   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   issue322{   s    c          C   s3   d d l  m }  d |  d d ƒ f d „  ƒ  Y} | S(   s›   
    Check that using a namedtuple subclass doesn't crash when
    trying to infer EmptyNodes (resulted after mocking the
    members of namedtuples).
    iÿÿÿÿ(   t
   namedtuplet   Crasht   Cs   foo barc           B   s   e  Z d  Z d „  Z RS(   sd    Looking for attributes in __str__ will crash,
        because EmptyNodes can't be infered.
        c         S   s   d j  |  ƒ S(   Ns   {0.foo}: {0.bar}(   R   (   R   (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   __str__   s    (   R   R   R   R2   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyR0   ‹   s   (   t   collectionsR/   (   R/   R0   (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   issue338ƒ   s    c          C   s4   d j  }  |  d ƒ |  d d ƒ |  d d d ƒ d S(   sI   
    Check that the format method can be assigned to a variable, ie:
    s
   test {} {}t   arg1t   arg2t   arg3N(   R   (   t   fmt(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   issue351“   s    	
c          C   s   d t  f d „  ƒ  Y}  |  S(   s4   
    Ignore any object coming from an argument.
    t	   SomeClassc           B   s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s    empty docstring. c         S   s   | |  _  d  S(   N(   t   opts(   R   R;   (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   __init__¢   s    c         S   s   d j  | |  j ƒ S(   s   Don't try to analyze this.s   A{0}{1}(   R   R;   (   R   t   arg(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   dunc¥   s    c         S   s   d j  |  j ƒ S(   s*   Don't try to analyze the following string.s   AAA{0[iface]}BBB{0[port]}(   R   R;   (   R   (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   func©   s    N(   R   R   R   t   NoneR<   R>   R?   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyR:       s   	(   R    (   R:   (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   issue373œ   s    c          C   s+   d j  d ƒ }  d j  d g ƒ } |  | f S(   sl   
    Mix positional arguments, `{0}`, with positional
    arguments with attribute access, `{0.__x__}`.
    s   {0.__class__.__name__}: {0}i*   s   {0[0]}: {0}i   (   R   (   t   datat   data2(    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt	   issue_463¯   s    c           C   s   d j  d ƒ S(   s0   The following string is invalid, avoid crashing.s%   There are {.:2f} undiscovered errors.i   (   R   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   avoid_empty_attribute¹   s    (   R   R   R   R    t   __revision__R    R   R   R   R   R   R   R!   R$   R*   R+   R,   R.   R4   R9   RA   RD   RE   (    (    (    sG   lib/python2.7/site-packages/pylint/test/functional/string_formatting.pyt   <module>   s(   		"			
							
