summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Garnaat <mitch@garnaat.com>2012-03-27 19:08:45 -0700
committerMitch Garnaat <mitch@garnaat.com>2012-03-27 19:08:45 -0700
commita25a740196290e9cabf81ae38de963545f49b057 (patch)
tree4c1bfe89e9ed12fd522e5440927608b7613ad7b7
parentbc6b6105dbed87b33aaa20688bb44ca541ff0688 (diff)
downloadboto-a25a740196290e9cabf81ae38de963545f49b057.tar.gz
PEP8 and pyflakes cleanup. Also removing deleted packages from setup.py.
-rw-r--r--boto/utils.py122
-rw-r--r--setup.py1
2 files changed, 0 insertions, 123 deletions
diff --git a/boto/utils.py b/boto/utils.py
index d1d9c7ef..5d5a49d4 100644
--- a/boto/utils.py
+++ b/boto/utils.py
@@ -423,128 +423,6 @@ class AuthSMTPHandler(logging.handlers.SMTPHandler):
self.handleError(record)
-class LRUCache(dict):
- """
- 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 Genshi which is based on
- Mighty's LRUCache from ``myghtyutils.util``, written
- by Mike Bayer and released under the MIT license (Genshi uses the
- BSD License). See:
-
- http://svn.myghty.org/myghtyutils/trunk/lib/myghtyutils/util.py
- """
-
- class _Item(object):
-
- def __init__(self, key, value):
- self.previous = self.next = None
- self.key = key
- self.value = value
-
- def __repr__(self):
- return repr(self.value)
-
- def __init__(self, capacity):
- self._dict = dict()
- self.capacity = capacity
- self.head = None
- self.tail = None
-
- def __contains__(self, key):
- return key in self._dict
-
- def __iter__(self):
- cur = self.head
- while cur:
- yield cur.key
- cur = cur.next
-
- def __len__(self):
- return len(self._dict)
-
- def __getitem__(self, key):
- item = self._dict[key]
- self._update_item(item)
- return item.value
-
- def __setitem__(self, key, value):
- item = self._dict.get(key)
- if item is None:
- item = self._Item(key, value)
- self._dict[key] = item
- self._insert_item(item)
- else:
- item.value = value
- self._update_item(item)
- self._manage_size()
-
- def __repr__(self):
- return repr(self._dict)
-
- def _insert_item(self, item):
- item.previous = None
- item.next = self.head
- if self.head is not None:
- self.head.previous = item
- else:
- self.tail = item
- self.head = item
- self._manage_size()
-
- def _manage_size(self):
- while len(self._dict) > self.capacity:
- del self._dict[self.tail.key]
- if self.tail != self.head:
- self.tail = self.tail.previous
- self.tail.next = None
- else:
- self.head = self.tail = None
-
- def _update_item(self, item):
- if self.head == item:
- return
-
- previous = item.previous
- previous.next = item.next
- if item.next is not None:
- item.next.previous = previous
- else:
- self.tail = previous
-
- item.previous = None
- item.next = self.head
- self.head.previous = self.head = item
-
class Password(object):
"""
diff --git a/setup.py b/setup.py
index c505b4e0..01110576 100644
--- a/setup.py
+++ b/setup.py
@@ -58,7 +58,6 @@ setup(name = "boto",
"boto.sdb.db", "boto.sdb.db.manager",
"boto.mturk", "boto.pyami",
"boto.pyami.installers", "boto.pyami.installers.ubuntu",
- "boto.mashups", "boto.contrib", "boto.manage",
"boto.services", "boto.cloudfront",
"boto.roboto", "boto.rds", "boto.vpc", "boto.fps",
"boto.fps", "boto.emr", "boto.emr", "boto.sns",