ó �fc @ s¥ d Z d Z d d l Z d d l Z d d l Z d d l Z d a d „ Z d „ Z d „ Z e d ƒ \ Z Z Z Z Z d d d „ ƒ YZ e d k r¡ e ƒ n d S( s checkappend.py -- search for multi-argument .append() calls. Usage: specify one or more file or directory paths: checkappend [-v] file_or_dir [file_or_dir] ... Each file_or_dir is checked for multi-argument .append() calls. When a directory, all .py files in the directory, and recursively in its subdirectories, are checked. Use -v for status msgs. Use -vv for more status msgs. In the absence of -v, the only output is pairs of the form filename(linenumber): line containing the suspicious append Note that this finds multi-argument append calls regardless of whether they're attached to list objects. If a module defines a class with an append method that takes more than one argument, calls to that method will be listed. Note that this will not find multi-argument list.append calls made via a bound method object. For example, this is not caught: somelist = [] push = somelist.append push(1, 2, 3) i i iÿÿÿÿNc G s3 d j | ƒ } t j j | ƒ t j j d ƒ d S( Nt s ( t joint syst stderrt write( t argst msg( ( s1 /usr/lib64/python2.7/Tools/scripts/checkappend.pyt errprint+ s c C sÅ t j d } y# t j t j d d ƒ \ } } Wn/ t j k ra } t t | ƒ d t ƒ d SXx- | D]% \ } } | d k ri t d a qi qi W| s¦ t t ƒ d Sx | D] } t | ƒ q Wd S( Ni t vs s -v( R t argvt getoptt errorR t strt __doc__t verboset check( R t optsR t optt optargt arg( ( s1 /usr/lib64/python2.7/Tools/scripts/checkappend.pyt main0 s # c C sK t j j | ƒ rÁ t j j | ƒ rÁ t r: d | f GHn t j | ƒ } xq | D]i } t j j | | ƒ } t j j | ƒ r� t j j | ƒ s¬ t j j | d ƒ d k rP t | ƒ qP qP Wd Sy t | ƒ } Wn( t k rû } t d | | f ƒ d SXt d k rd | f GHn t | | ƒ j ƒ } t rG| rGd | f GHn d S( Ns %r: listing directoryiýÿÿÿs .pys %r: I/O Error: %si s checking %r ...s %r: Clean bill of health.( t ost patht isdirt islinkR t listdirR t normcaseR t opent IOErrorR t AppendCheckert run( t filet namest namet fullnamet fR t ok( ( s1 /usr/lib64/python2.7/Tools/scripts/checkappend.pyR A s* % i R c B sD e Z d „ Z d „ Z e j e j e j f e j e j d „ Z RS( c C s( | | _ | | _ t | _ d | _ d S( Ni ( t fnameR t FIND_DOTt statet nerrors( t selfR% R ( ( s1 /usr/lib64/python2.7/Tools/scripts/checkappend.pyt __init__b s c C sj y t j | j j | j ƒ Wn= t j k r\ } t d | j | f ƒ | j d | _ n X| j d k S( Ns %r: Token Error: %si i ( t tokenizeR t readlinet tokeneatert TokenErrorR R% R( ( R) R ( ( s1 /usr/lib64/python2.7/Tools/scripts/checkappend.pyR h s c C sÚ | j } | | k r nµ| t k rH | | k rÍ| d k rÍt } qÍn…| t k r” | | k r‹ | d k r‹ | | _ | d | _ t } qÍt } n9| t k rÓ | | k rÊ | d k rÊ d | _ t } qÍt } nú | t k r–| | k rÍ| d k r | j d | _ q“| d k rA| j d | _ | j d k r�t } q�q“| d k r“| j d k r“| j d | _ d | j | j | j f GHt } q“qÍn7 | t k rº| | k rÍt } qÍn t d | f ƒ ‚ | | _ d S( Nt .t appendi t (i t {t [t )t }t ]t ,s %s(%d): %ss unknown internal state '%r'( R1 R2 R3 ( R4 R5 R6 ( R' R&