HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/trac/notification/__pycache__/prefs.cpython-310.pyc
o

�k�`.%�@s�ddlmZddlmZddlmZmZmZddlm	Z	m
Z
mZmZddl
mZddlmZddlmZddlmZdd	lmZmZdd
lmZmZmZddlmZddlmZd
d�Z Gdd�de�Z!Gdd�de�Z"dS)�)�
itemgetter��resource_filename)�	Component�
implements�ExtensionPoint)�INotificationDistributor�INotificationFormatter�INotificationSubscriber�NotificationSystem)�Subscription)�IPreferencePanelProvider��as_int)�tag)�_�	cleandoc_)�Chrome�ITemplateProvider�
add_notice��get_session_attribute)�
WikiMacroBasecCst|||d|�S)N�notification.format.%sr)�env�sid�
authenticated�	transport�r�9/usr/lib/python3/dist-packages/trac/notification/prefs.py�get_preferred_format"s�r c@s�eZdZeee�ee�Zee	�Z
ee�Zdd�Z
dd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�NotificationPreferencescCs|j|j|j|jd�|_dS)N)zadd-rulezdelete-rulez	move-rule�replace)�	_add_rule�_delete_rule�
_move_rule�_replace_rules�
post_handlers��selfrrr�__init__.s
�z NotificationPreferences.__init__ccs�dtd�fVdS)N�notification�
Notifications)r)r)�reqrrr�get_preference_panels8s�z-NotificationPreferences.get_preference_panelsNc
s*|jdkr7|j�dd��dd�}t|�dkr.|\}}|j�|�}|r.|||�t|td��|�	|j
�d��i}g}	i}
i}i}g}
|jD](}|�
�}|sOqF|jjsX|��rXqF|	�|jj|d	��t|d
�rn|
�|���qFtdd�|	D��}t|j�}|��D]G}g||<|�|�|
|<|j�d
|�||<|�|�||<|�||�D]"�|��d�}|r�d|i}|��fdd�dD��||�|�q�q�i}t|
t d�d�D] ��\}}}}}|�!|g�|�|�}|r�||�||d��q�||	|
|||dtd�td�d�d�}t"|j��#|�dt|d�fS)N�POST�action�r��z!Your preferences have been saved.r+)�class�description�default_subscriptionscss �|]}|d|dfVqdS)r4r5Nr)�.0�srrr�	<genexpr>Ws�zBNotificationPreferences.render_preference_panel.<locals>.<genexpr>rr4r5c3s�|]	}|�|fVqdS�Nr)r7�key��rrrr9cs�)�id�adverbr4�priority�)r;)r?r5)�always�never�NotifyzNever notify)�rules�subscribers�
formatters�selected_format�default_format�
default_rules�adverbs�
adverb_labelszprefs_notification.html)�data)$�method�args�getfirst�split�lenr'�getrr�redirect�href�prefsrFr5�sessionr�requires_authentication�append�	__class__�__name__�hasattr�extendr6�dictrr�_iter_transports�_get_supported_styles�get_default_format�_iter_rules�update�sortedr�
setdefaultr�
add_jquery_ui)r)r-�panel�	path_info�
action_argr0�arg�handlerrErFrGrHrI�defaults�ir5�desc_map�ns�t�valuesrJ�klass�dist�formatr@r?rMrr<r�render_preference_panel;s�



�
�
���	

����z/NotificationPreferences.render_preference_panelcCsgSr:rr(rrr�get_htdocs_dirs�sz'NotificationPreferences.get_htdocs_dirscCstdd�}|gS)Nztrac.notification�	templatesr)r)�resource_dirrrr�get_templates_dirs�s
z*NotificationPreferences.get_templates_dirscCs~t|j�}|jj|d<|jjrdnd|d<||d<|j�d|d�|d<|jd	||d
<|jd||d<t�|j|�dS)
Nrr2rr�distributorz	format-%sr1rtz
new-adverb-%sr?znew-rule-%sr4)rrrWrrrOrS�add)r)rjr-�rulerrrr#�s
z!NotificationPreferences._add_rulecCs |j}t�|j||j|j�dSr:)rWr�deleterrr)r)rjr-rWrrrr$�sz$NotificationPreferences._delete_rulecCshdd�|�dd�D�}t|�dkr.|\}}|dkr0|dkr2|j}t�|j|||j|j�dSdSdSdS)NcSsg|]}t|d��qS)rr)r7�valrrr�
<listcomp>�sz6NotificationPreferences._move_rule.<locals>.<listcomp>�-r2r3r)rQrRrWr�moverrr)r)rjr-�tokens�rule_idr@rWrrrr%�s��z"NotificationPreferences._move_rulec	Cs�g}|��D]F}|j�d|�}|�||�}|j�d||d�|j�d|�}|j�d|�}ttt	|�t	|���D]}|�
||||||d��q;q|jj}	|jj}
|j
j�t�|j
|	|
|�Wd�dS1snwYdS)Nzformat-rr1zadverb-zclass-)rzrtr?r4)r_rOrP�_normalize_formatrW�set�getlist�range�minrRrYrrr�db_transactionr�replace_all)r)rjr-�
subscriptionsr�format_rK�classes�idxrrrrrr&�s*
��
�"�z&NotificationPreferences._replace_rulesccs.�|j}t�|j|j|j|�D]}|VqdSr:)rWr�find_by_sid_and_distributorrrr)r)r-rrWr=rrrrb�s���z#NotificationPreferences._iter_rulesccs&�|jD]}|��D]}|Vq
qdSr:)�distributors�
transports)r)rzrrrrr_�s�
��z(NotificationPreferences._iter_transportscCs8t�}|jD]}|�|�D]	\}}|�|�q
qt|�Sr:)r�rG�get_supported_stylesr{rd)r)r�styles�	formatter�style�realm_rrrr`�s
�z-NotificationPreferences._get_supported_stylescCs|r
|�|�}||vr
|SdS)Nr1)r`)r)r�rr�rrrr��s

z)NotificationPreferences._normalize_formatr:)r[�
__module__�__qualname__rr
rrr
rFrr�r	rGr*r.rurvryr#r$r%r&rbr_r`r�rrrrr!'s$


F
	r!c@s eZdZdZed�Zdd�ZdS)�SubscriberListMacro�messagesa�Display a list of all installed notification subscribers, including
    documentation if available.

    Optionally, the name of a specific subscriber can be provided as an
    argument. In that case, only the documentation for that subscriber will
    be rendered.

    Note that this macro will not be able to display the documentation of
    subscribers if the `PythonOptimize` option is enabled for mod_python!
    cs�|r|��nd}|�d�}i�t|j�jD]}|jj}|r"|�|�r(|���|<qtj	dd�tj
dd�t�t�t�
td��t�
td����t��fdd	�tt���D����S)
Nr1�*ztrac-subscriberlist��class_�wiki�
Subscriber�Descriptionc3sF�|]\}}tjt�t�|��t��|�|drdndd�VqdS)r3�odd�evenr�N)r�tr�td�code)r7r��name��itemsrrr9�s���
�z3SubscriberListMacro.expand_macro.<locals>.<genexpr>)�striprrrFrZr[�
startswithr5r�div�table�theadr��thr�tbody�	enumeraterd)r)r�r��content�name_filter�
subscriberrr�r�expand_macro�s&
�

�
���z SubscriberListMacro.expand_macroN)r[r�r��_domainr�_descriptionr�rrrrr��s�r�N)#�operatorr�
pkg_resourcesr�	trac.corerrr�trac.notification.apirr	r
r�trac.notification.modelr�trac.prefs.apir
�	trac.utilr�trac.util.htmlr�trac.util.translationrr�trac.web.chromerrr�trac.web.sessionr�trac.wiki.macrosrr r!r�rrrr�<module>s )