Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Side by Side Diff: client/third_party/cachetools/abc.py

Issue 2953253003: Replace custom blob gRPC API with ByteStream (Closed)
Patch Set: Import ndb directly to test code Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/third_party/cachetools/__init__.py ('k') | client/third_party/cachetools/cache.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 from __future__ import absolute_import
2
3 import collections
4
5 from abc import abstractmethod
6
7
8 class DefaultMapping(collections.MutableMapping):
9
10 __slots__ = ()
11
12 @abstractmethod
13 def __contains__(self, key): # pragma: nocover
14 return False
15
16 @abstractmethod
17 def __getitem__(self, key): # pragma: nocover
18 if hasattr(self.__class__, '__missing__'):
19 return self.__class__.__missing__(self, key)
20 else:
21 raise KeyError(key)
22
23 def get(self, key, default=None):
24 if key in self:
25 return self[key]
26 else:
27 return default
28
29 __marker = object()
30
31 def pop(self, key, default=__marker):
32 if key in self:
33 value = self[key]
34 del self[key]
35 elif default is self.__marker:
36 raise KeyError(key)
37 else:
38 value = default
39 return value
40
41 def setdefault(self, key, default=None):
42 if key in self:
43 value = self[key]
44 else:
45 self[key] = value = default
46 return value
47
48 DefaultMapping.register(dict)
OLDNEW
« no previous file with comments | « client/third_party/cachetools/__init__.py ('k') | client/third_party/cachetools/cache.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698