/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/fifo_cache.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        else:
33
33
            self._after_cleanup_count = min(after_cleanup_count,
34
34
                                            self._max_cache)
35
 
        self._cleanup = {} # map to cleanup functions when items are removed
36
 
        self._queue = deque() # Track when things are accessed
 
35
        self._cleanup = {}  # map to cleanup functions when items are removed
 
36
        self._queue = deque()  # Track when things are accessed
37
37
 
38
38
    def __setitem__(self, key, value):
39
39
        """Add a value to the cache, there will be no cleanup function."""
81
81
            self._remove_oldest()
82
82
        if len(self._queue) != len(self):
83
83
            raise AssertionError('The length of the queue should always equal'
84
 
                ' the length of the dict. %s != %s'
85
 
                % (len(self._queue), len(self)))
 
84
                                 ' the length of the dict. %s != %s'
 
85
                                 % (len(self._queue), len(self)))
86
86
 
87
87
    def clear(self):
88
88
        """Clear out all of the cache."""
169
169
    it restricts the cache to be cleaned based on the size of the data.
170
170
    """
171
171
 
172
 
    def __init__(self, max_size=1024*1024, after_cleanup_size=None,
 
172
    def __init__(self, max_size=1024 * 1024, after_cleanup_size=None,
173
173
                 compute_size=None):
174
174
        """Create a new FIFOSizeCache.
175
175
 
258
258
            self._after_cleanup_size = min(max_size, after_cleanup_size)
259
259
        if self._value_size > self._max_size:
260
260
            self.cleanup()
261