ó
ôŸ?`c           @   sê  d  Z  d Z d d l Z d d l Z d d l Z d d l Z y d d l Z Wn: e k
 rˆ d d d „  ƒ  YZ e ƒ  Z e j d IJn Xe j	 d ƒ Z
 d „  Z d	 „  Z d
 „  Z d e j d Z y# e j e j d d ƒ \ Z Z Wn= e j k
 r&Z e j e IJe j e IJe j d ƒ n Xe j Z e Z xA e D]9 \ Z Z e d k rae j Z q=e d k r=e Z q=q=We se j e IJe j d ƒ n  xF e j e e ƒ D]2 Z e rÈd e GHn  e e ƒ Z e r°e GHq°q°Wd S(   s_   List all those Python files that require a coding directive

Usage: nocoding.py dir1 [dir2...]
s   Oleg Broytmann, Georg BrandliÿÿÿÿNt   pysourcec           B   s   e  Z d Z Z Z d  „  Z RS(   c   	      o   s§   x  | D]˜ } t  j j | ƒ r0 | j d ƒ Vq t  j j | ƒ r xZ t  j | ƒ D]F \ } } } x4 | D], } | j d ƒ rh t  j j | | ƒ Vqh qh WqR Wq q Wd  S(   Ns   .py(   t   ost   patht   isfilet   endswitht   isdirt   walkt   join(	   t   selft   pathst   argst   kwargsR   t   roott   dirst   filest   filename(    (    s2   /usr/lib64/python2.7/Tools/scripts/findnocoding.pyt   walk_python_files   s    N(   t   __name__t
   __module__t   Nonet   has_python_extt   looks_like_pythont   can_be_compiledR   (    (    (    s2   /usr/lib64/python2.7/Tools/scripts/findnocoding.pyR       s   s^   The pysource module is not available; no sophisticated Python source file search will be done.s   coding[=:]\s*([-\w.]+)c         C   s&   t  j |  ƒ } | r" | j d ƒ Sd S(   Ni   t    (   t   decl_ret   searcht   group(   t   linet   match(    (    s2   /usr/lib64/python2.7/Tools/scripts/findnocoding.pyt   get_declaration%   s    c         C   s.   y t  |  | ƒ Wn t k
 r% t SXt Sd  S(   N(   t   unicodet   UnicodeDecodeErrort   Falset   True(   t   textt   codec(    (    s2   /usr/lib64/python2.7/Tools/scripts/findnocoding.pyt   has_correct_encoding+   s
    c         C   s›   y t  |  d ƒ } Wn t k
 r' d  SX| j ƒ  } | j ƒ  } t | ƒ sX t | ƒ rf | j ƒ  t S| j ƒ  } | j ƒ  t | | | d ƒ r— t St	 S(   Nt   rUt   ascii(
   t   opent   IOErrorR   t   readlineR   t   closeR    t   readR$   R!   (   t   fullpatht   infilet   line1t   line2t   rest(    (    s2   /usr/lib64/python2.7/Tools/scripts/findnocoding.pyt   needs_declaration3   s    

sj   Usage: %s [-cd] paths...
    -c: recognize Python source files trying to compile them
    -d: debug outputi    i   t   cds   -cs   -ds   Testing for coding: %s(    (    t   __doc__t
   __author__t   sysR   t   ret   getoptR    t   ImportErrort   stderrt   compileR   R   R$   R1   t   argvt   usaget   optsR
   t   errort   msgt   exitR   t	   is_pythonR    t   debugt   ot   aR   R!   R   R,   t   result(    (    (    s2   /usr/lib64/python2.7/Tools/scripts/findnocoding.pyt   <module>   sF   0				#	