Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure you want to rename?
File Manager
/
ALFA_DATA
/
alfasymlink
/
root
/
opt
/
alt
/
python37
/
lib64
/
python3.7
/
site-packages
/
lxml
/
html
/
__pycache__
:
diff.cpython-37.pyc
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
B �|/\Yw � @ s� d dl mZ d dlZd dlmZ d dlmZ d dlZddgZyd dl m Z W n ek rl d dl m Z Y nX yeZW n ek r� eZY nX ye W n ek r� eZY nX dd � Zefd d�Zdd� Zd d� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdidd�Zdd� ZG dd � d �ZG d!d"� d"�Z G d#d$� d$e!�Z"d%d&� Z#d'd(� Z$d)d*� Z%d+d,� Z&d-d.� Z'd/d0� Z(G d1d2� d2e�Z)G d3d4� d4e)�Z*G d5d6� d6e)�Z+djd8d9�Z,dkd:d;�Z-e�.d<ej/ej0B �Z1e�.d=ej/ej0B �Z2e�.d>ej/ej0B �Z3d?d@� Z4e�.dA�Z5dBdC� Z6dDdE� Z7dFZ8dGZ9dHZ:dldIdJ�Z;e�.dKej<�Z=dLdM� Z>e�.dN�Z?dOdP� Z@dQdR� ZAdSdT� ZBdUdV� ZCdWdX� ZDdYdZ� ZEdmd[d\�ZFd]d^� ZGd_d`� ZHdadb� ZIdcdd� ZJG dedf� dfejK�ZLeMdgk�r�d dhlmNZN eN�O� dS )n� )�absolute_importN)�etree)�fragment_fromstring� html_annotate�htmldiff)�escapec C s dt t|�d�| f S )Nz<span title="%s">%s</span>� )�html_escape�_unicode)�text�version� r �A/opt/alt/python37/lib64/python3.7/site-packages/lxml/html/diff.py�default_markup s r c C sZ dd� | D �}|d }x"|dd� D ]}t ||� |}q$W t|�}t||�}d�|��� S )a doclist should be ordered from oldest to newest, like:: >>> version1 = 'Hello World' >>> version2 = 'Goodbye World' >>> print(html_annotate([(version1, 'version 1'), ... (version2, 'version 2')])) <span title="version 2">Goodbye</span> <span title="version 1">World</span> The documents must be *fragments* (str/UTF8 or unicode), not complete documents The markup argument is a function to markup the spans of words. This function is called like markup('Hello', 'version 2'), and returns HTML. The first argument is text and never includes any markup. The default uses a span with a title: >>> print(default_markup('Some Text', 'by Joe')) <span title="by Joe">Some Text</span> c S s g | ]\}}t ||��qS r )�tokenize_annotated)�.0�docr r r r � <listcomp>= s z!html_annotate.<locals>.<listcomp>r r N� )�html_annotate_merge_annotations�compress_tokens�markup_serialize_tokens�join�strip)ZdoclistZmarkupZ tokenlistZ cur_tokens�tokens�resultr r r r # s c C s$ t | dd�}x|D ] }||_qW |S )zFTokenize a document and add an annotation attribute to each token F)� include_hrefs)�tokenize� annotation)r r r �tokr r r r K s r c C sZ t | |d�}|�� }x@|D ]8\}}}}}|dkr| ||� } |||� } t| | � qW dS )z�Merge the annotations from tokens_old into tokens_new, when the tokens in the new document already existed in the old document. )�a�b�equalN)�InsensitiveSequenceMatcher�get_opcodes�copy_annotations)Z tokens_oldZ tokens_new�s�commands�command�i1�i2�j1�j2Zeq_oldZeq_newr r r r S s r c C s8 t | �t |�kst�xt| |�D ]\}}|j|_q W dS )zN Copy annotations from the tokens listed in src to the tokens in dest N)�len�AssertionError�zipr )�src�destZsrc_tokZdest_tokr r r r% ` s r% c C sZ | d g}xJ| dd� D ]:}|d j sH|jsH|d j|jkrHt||� q|�|� qW |S )zm Combine adjacent tokens when there is no HTML between the tokens, and they share an annotation r r N���)� post_tags�pre_tagsr �compress_merge_back�append)r r r r r r r h s r c C sv | d }t |�tk s t |�tk r,| �|� nFt|�}|jrD||j7 }||7 }t||j|j|jd�}|j|_|| d<