ó
MÑO]c           @@  s  d  d l  m Z 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    (   t   absolute_importNi   (   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@  sH  |  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 |
 ƒ Wd  QXd  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   open(   t   argst   optionst   file1t   file2t   input1t   input2t   body1t   pret   body2t   postt   resultt   f(    (    s5   lib/python2.7/site-packages/lxml/html/_diffcommand.pyt   main    s,    	
c         C@  sk   |  d k r t  j j ƒ  } nI t j j |  ƒ sC t d |  ƒ ‚ n$ t |  d ƒ  } | j ƒ  } Wd  QX| S(   NR
   s   Input file %s does not existt   rb(   R   t   stdint   readt   ost   patht   existst   OSErrorR   (   t   filenamet   cR*   (    (    s5   lib/python2.7/site-packages/lxml/html/_diffcommand.pyR   9   s    s	   <body.*?>s
   </body.*?>c         C@  s‡   d } } t  j |  ƒ } | rB |  | j ƒ   } |  | j ƒ  }  n  t j |  ƒ } | rz |  | j ƒ  } |  | j ƒ   }  n  | |  | f S(   NR   (   t   body_start_ret   searcht   endt   body_end_ret   start(   t   htmlR&   R(   t   match(    (    s5   lib/python2.7/site-packages/lxml/html/_diffcommand.pyR   I   s    
c         C@  s   d GHt  j d ƒ d  S(   Ns   Not yet implementedi   (   R   R   (   R    R   (    (    s5   lib/python2.7/site-packages/lxml/html/_diffcommand.pyR   U   s    (   t
   __future__R    t   optparseR   t   reR/   t   diffR   R   t   OptionParserR   t
   add_optionR   R+   R   t   compilet   It   SR5   R8   R   R   (    (    (    s5   lib/python2.7/site-packages/lxml/html/_diffcommand.pyt   <module>   s8   						