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 : |
o !�bm � @ sp d Z ddlZddlmZ ddlZdZG dd� de�Zdd� Z dd d�Z e�d�Zddd�Z e�d�Zdd� ZdS )z&Various utility classes and functions.� N)� html_entitieszrestructuredtext enc @ sp e Zd ZdZG dd� de�Zdd� Zdd� Zdd � Zd d� Z dd � Z dd� Zdd� Zdd� Z dd� Zdd� ZdS )�LRUCacheae A 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 @ s e Zd Zdd� Zdd� ZdS )zLRUCache._Itemc C s d | _ | _|| _|| _d S �N)�prv�nxt�key�value)�selfr r � r �-/usr/lib/python3/dist-packages/genshi/util.py�__init__@ s zLRUCache._Item.__init__c C � t | j�S r )�reprr �r r r r �__repr__D � zLRUCache._Item.__repr__N)�__name__� __module__�__qualname__r r r r r r �_Item? s r c C s t � | _|| _d | _d | _d S r )�dict�_dict�capacity�head�tail)r r r r r r G s zLRUCache.__init__c C s || j v S r )r )r r r r r �__contains__M r zLRUCache.__contains__c c s&