ó
œ]Nc           @   s  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z d Z e  j d d d e ƒ Z e j	 d d d	 d
 d d d d d d ƒe j	 d d d d d d d d ƒd d „ Z d „  Z e j d e j e j Bƒ Z e j d e j e j Bƒ Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   htmldifft    t   usagesR   %prog [OPTIONS] FILE1 FILE2
%prog --annotate [OPTIONS] INFO1 FILE1 INFO2 FILE2 ...t   descriptions   -os   --outputt   metavart   FILEt   destt   outputt   defaultt   -t   helps   File to write the difference tos   -as   --annotationt   actiont
   store_truet
   annotations   Do an annotationc         C   sI  |  d  k r t j d }  n  t j |  ƒ \ } }  | j rG t | |  ƒ St |  ƒ d k rx d GHt j ƒ  t j	 d ƒ n  |  \ } } t
 | ƒ } t
 | ƒ } t | ƒ d } t | ƒ \ } } }	 t | | ƒ }
 | |
 |	 }
 | j d k r|
 j d ƒ s	|
 d 7}
 n  t j j |
 ƒ n) t | j d ƒ } | j |
 ƒ | j ƒ  d  S(   Ni   i   s   Error: you must give two filesR	   s   
t   wb(   t   Nonet   syst   argvt   parsert
   parse_argsR   t   annotatet   lent
   print_helpt   exitt	   read_filet
   split_bodyR    R   t   endswitht   stdoutt   writet   opent   close(   t   argst   optionst   file1t   file2t   input1t   input2t   body1t   pret   body2t   postt   resultt   f(    (    s:   /usr/lib/python2.7/dist-packages/lxml/html/_diffcommand.pyt   main   s.    	
c         C   sl   |  d k r t  j j ƒ  } nJ t j j |  ƒ sC t d |  ƒ ‚ n% t |  d ƒ } | j ƒ  } | j ƒ  | S(   NR	   s   Input file %s does not existt   rb(	   R   t   stdint   readt   ost   patht   existst   OSErrorR   R   (   t   filenamet   cR*   (    (    s:   /usr/lib/python2.7/dist-packages/lxml/html/_diffcommand.pyR   8   s    
s	   <body.*?>s
   </body.*?>c         C   s}   t  j |  ƒ } | r8 |  | j ƒ   } |  | j ƒ  }  n  t j |  ƒ } | rp |  | j ƒ  } |  | j ƒ   }  n  | |  | f S(   N(   t   body_start_ret   searcht   endt   body_end_ret   start(   t   htmlt   matchR&   R(   (    (    s:   /usr/lib/python2.7/dist-packages/lxml/html/_diffcommand.pyR   I   s    c         C   s   d GHt  j d ƒ d  S(   Ns   Not yet implementedi   (   R   R   (   R    R   (    (    s:   /usr/lib/python2.7/dist-packages/lxml/html/_diffcommand.pyR   T   s    (   t   optparseR   t   reR/   t   lxml.html.diffR    R   t   OptionParserR   t
   add_optionR   R+   R   t   compilet   It   SR5   R8   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/lxml/html/_diffcommand.pyt   <module>   s6   						