a
    %ñ»jw  ã                   @   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ed�Zej	ddd	d
ddd� ej	dddddd� ddd„Z
dd„ Ze dejejB ¡Ze dejejB ¡Zdd„ Zdd„ ZdS )é    Né   )ÚhtmldiffÚ zR%prog [OPTIONS] FILE1 FILE2
%prog --annotate [OPTIONS] INFO1 FILE1 INFO2 FILE2 ...)ÚusageÚdescriptionz-oz--outputÚFILEÚoutputú-zFile to write the difference to)ÚmetavarÚdestÚdefaultÚhelpz-az--annotationÚ
store_trueÚ
annotationzDo an annotation)Úactionr   r   c                 C   s  | d u rt jdd … } t | ¡\}} |jr4t|| ƒS t| ƒdkrZtdƒ t ¡  t  	d¡ | \}}t
|ƒ}t
|ƒ}t|ƒd }t|ƒ\}}}	t||ƒ}
||
 |	 }
|jdkrÌ|
 d¡s¾|
d7 }
t j |
¡ n6t|jdƒ�}| |
¡ W d   ƒ n1 sø0    Y  d S )Nr   é   zError: you must give two filesr	   Ú
Úwb)ÚsysÚargvÚparserÚ
parse_argsr   ÚannotateÚlenÚprintÚ
print_helpÚexitÚ	read_fileÚ
split_bodyr   r   ÚendswithÚstdoutÚwriteÚopen)ÚargsÚoptionsZfile1Zfile2Zinput1Zinput2Zbody1ÚpreZbody2ÚpostÚresultÚf© r)   ú<E:\soccer\ml_env\Lib\site-packages\lxml/html/_diffcommand.pyÚmain   s,    




r+   c                 C   sd   | dkrt j ¡ }nLtj | ¡s.td|  ƒ‚n2t| dƒ�}| ¡ }W d   ƒ n1 sV0    Y  |S )Nr	   zInput file %s does not existÚrb)r   ÚstdinÚreadÚosÚpathÚexistsÚOSErrorr"   )ÚfilenameÚcr(   r)   r)   r*   r   7   s    ÿ&r   z	<body.*?>z
</body.*?>c                 C   sn   d }}t  | ¡}|r6| d | ¡ … }| | ¡ d … } t | ¡}|rd| | ¡ d … }| d | ¡ … } || |fS )Nr   )Úbody_start_reÚsearchÚendÚbody_end_reÚstart)Úhtmlr%   r&   Úmatchr)   r)   r*   r   G   s    

r   c                 C   s   t dƒ t d¡ d S )NzNot yet implementedr   )r   r   r   )r$   r#   r)   r)   r*   r   S   s    r   )N)Úoptparser   Úrer/   Údiffr   r   ÚOptionParserr   Ú
add_optionr+   r   ÚcompileÚIÚSr5   r8   r   r   r)   r)   r)   r*   Ú<module>   s@   ýûü
ÿÿ