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/genshi/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/genshi/__pycache__/util.cpython-310.pyc
o

!�bm�@spdZddlZddlmZddlZdZGdd�de�Zdd�Z	dd
d�Z
e�d�Zddd�Z
e�d�Zdd�ZdS)z&Various utility classes and functions.�N)�
html_entitieszrestructuredtext enc@speZdZdZGdd�de�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�LRUCacheaeA dictionary-like object that stores only a certain number of items, and
    discards its least recently used item when full.
    
    >>> cache = LRUCache(3)
    >>> cache['A'] = 0
    >>> cache['B'] = 1
    >>> cache['C'] = 2
    >>> len(cache)
    3
    
    >>> cache['A']
    0
    
    Adding new items to the cache does not increase its size. Instead, the least
    recently used item is dropped:
    
    >>> cache['D'] = 3
    >>> len(cache)
    3
    >>> 'B' in cache
    False
    
    Iterating over the cache returns the keys, starting with the most recently
    used:
    
    >>> for key in cache:
    ...     print(key)
    D
    A
    C

    This code is based on the LRUCache class from ``myghtyutils.util``, written
    by Mike Bayer and released under the MIT license. See:

      http://svn.myghty.org/myghtyutils/trunk/lib/myghtyutils/util.py
    c@seZdZdd�Zdd�ZdS)zLRUCache._ItemcCsd|_|_||_||_dS�N)�prv�nxt�key�value)�selfrr�r
�-/usr/lib/python3/dist-packages/genshi/util.py�__init__@s
zLRUCache._Item.__init__cC�
t|j�Sr)�reprr�r	r
r
r�__repr__D�
zLRUCache._Item.__repr__N)�__name__�
__module__�__qualname__rrr
r
r
r�_Item?srcCst�|_||_d|_d|_dSr)�dict�_dict�capacity�head�tail)r	rr
r
rrGs
zLRUCache.__init__cCs
||jvSr)r)r	rr
r
r�__contains__MrzLRUCache.__contains__ccs&�|j}|r|jV|j}|sdSdSr)rrr)r	�curr
r
r�__iter__Ps��zLRUCache.__iter__cCr
r)�lenrrr
r
r�__len__VrzLRUCache.__len__cCs|j|}|�|�|jSr)r�_update_itemr)r	r�itemr
r
r�__getitem__Ys

zLRUCache.__getitem__cCsT|j�|�}|dur|�||�}||j|<|�|�dS||_|�|�|��dSr)r�getr�_insert_itemrr �_manage_size)r	rrr!r
r
r�__setitem__^s

zLRUCache.__setitem__cCr
r)rrrr
r
rrirzLRUCache.__repr__cCs:d|_|j|_|jdur||j_n||_||_|��dSr)rrrrr%)r	r!r
r
rr$ls

zLRUCache._insert_itemcCs`t|j�|jkr.|j|jj=|j|jkr|jj|_d|j_nd|_|_t|j�|jksdSdSr)rrrrrrrrrr
r
rr%vs

�zLRUCache._manage_sizecCsV|j|krdS|j}|j|_|jdur||j_n||_d|_|j|_||j_|_dSr)rrrr)r	r!rr
r
rr s


zLRUCache._update_itemN)rrr�__doc__�objectrrrrrr"r&rr$r%r r
r
r
rrs%
	rcCs<g}|D]}t|ttttf�r|t|�7}q|�|�q|S)z�Flattens a potentially nested sequence into a flat list.
    
    :param items: the sequence to flatten
    
    >>> flatten((1, 2))
    [1, 2]
    >>> flatten([1, (2, 3), 4])
    [1, 2, 3, 4]
    >>> flatten([1, (2, [3, 4]), 5])
    [1, 2, 3, 4, 5]
    )�
isinstance�	frozenset�list�set�tuple�flatten�append)�items�retvalr!r
r
rr.�sr.TcCs tt|��}|s|�dd�}|S)a�Return the text with all entities and tags removed.
    
    >>> plaintext('<b>1 &lt; 2</b>')
    '1 < 2'
    
    The `keeplinebreaks` parameter can be set to ``False`` to replace any line
    breaks by simple spaces:
    
    >>> plaintext('''<b>1
    ... &lt;
    ... 2</b>''', keeplinebreaks=False)
    '1 < 2'
    
    :param text: the text to convert to plain text
    :param keeplinebreaks: whether line breaks in the text should be kept intact
    :return: the text with tags and entities removed
    �
� )�
stripentities�	striptags�replace)�text�keeplinebreaksr
r
r�	plaintext�sr9z-&(?:#((?:\d+)|(?:[xX][0-9a-fA-F]+));?|(\w+);)Fcs�fdd�}t�||�S)u5Return a copy of the given text with any character or numeric entities
    replaced by the equivalent UTF-8 characters.
    
    >>> stripentities('1 &lt; 2')
    '1 < 2'
    >>> stripentities('more &hellip;')
    'more …'
    >>> stripentities('&#8230;')
    '…'
    >>> stripentities('&#x2026;')
    '…'
    
    If the `keepxmlentities` parameter is provided and is a truth value, the
    core XML entities (&amp;, &apos;, &gt;, &lt; and &quot;) are left intact.
    
    >>> stripentities('1 &lt; 2 &hellip;', keepxmlentities=True)
    '1 &lt; 2 …'
    cs�|�d�r#|�d�}|�d�rt|dd�d�}nt|d�}t�|�S|�d�}�r2|dvr2d|Sz	t�tj|�WStyN�rJd|YS|YSw)	N��x��
�)�amp�apos�gt�lt�quotz&%s;z&amp;%s;)�group�
startswith�int�six�unichr�entities�name2codepoint�KeyError)�match�ref��keepxmlentitiesr
r�_replace_entity�s 





�z&stripentities.<locals>._replace_entity)�_STRIPENTITIES_RE�sub)r7rOrPr
rNrr4�sr4z(<!--.*?-->|<[^>]*>)cCst�d|�S)a�Return a copy of the text with any XML/HTML tags removed.
    
    >>> striptags('<span>Foo</span> bar')
    'Foo bar'
    >>> striptags('<span class="bar">Foo</span>')
    'Foo'
    >>> striptags('Foo<br />')
    'Foo'
    
    HTML/XML comments are stripped, too:
    
    >>> striptags('<!-- <blub>hehe</blah> -->test')
    'test'
    
    :param text: the string to remove tags from
    :return: the text with tags removed
    �)�
_STRIPTAGS_RErR)r7r
r
rr5�sr5)T)F)r'�re�	six.movesrrIrG�
__docformat__rrr.r9�compilerQr4rTr5r
r
r
r�<module>s
v



)

https://t.me/RX1948 - 2025