File: //usr/lib/python3/dist-packages/trac/mimeview/__pycache__/patch.cpython-310.pyc
o
�k�`�4 � @ s� d dl Zd dlZd dlT d dlmZmZmZ d dlm Z m
Z
d dlmZ d dl
mZ d dlmZmZmZ dgZG d d� de�ZdS )
� N)�*)�content_to_unicode�IHTMLPreviewRenderer�Mimeview)�Markup�escape)�
expandtabs)�_)�Chrome�
add_script�add_stylesheet�
PatchRendererc @ s2 e Zd ZdZee� dd� Zd dd�Zdd� ZdS )
r
z�HTML renderer for patches in unified diff format.
This uses the same layout as in the wiki diff view or the changeset view.
c C s |dv rdS dS )N)ztext/x-diffztext/x-patch� r � )�self�mimetyper r �5/usr/lib/python3/dist-packages/trac/mimeview/patch.py�get_quality_ratio+ s zPatchRenderer.get_quality_ratioNc C s� |j }t| j||�}| �|�� t| j�j�}|r!tdd� |D ��s-| j� d|t
|�� d S ddid|ddd �}t|d
� t|d� t
| j��|d|�S )
Nc s s � | ]}|d V qdS )�diffsNr ��.0�cr r r � <genexpr>5 s � z'PatchRenderer.render.<locals>.<genexpr>z6Invalid unified diff content: %.40r... (%d characters)�style�inlineT�File� )�diff�no_id�changes�longcol�shortcolzcommon/js/diff.jszcommon/css/diff.cssz
diff_div.html)�reqr �env�_diff_to_hdf�
splitlinesr � tab_width�any�log�debug�lenr r r
�render_fragment) r �contextr �content�filename�revr"