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

Unified 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, 6 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/third_party/cachetools/abc.py
diff --git a/client/third_party/cachetools/abc.py b/client/third_party/cachetools/abc.py
new file mode 100644
index 0000000000000000000000000000000000000000..41ad7369fccf45bcfae9fb5b59227a4b4d8f79f4
--- /dev/null
+++ b/client/third_party/cachetools/abc.py
@@ -0,0 +1,48 @@
+from __future__ import absolute_import
+
+import collections
+
+from abc import abstractmethod
+
+
+class DefaultMapping(collections.MutableMapping):
+
+ __slots__ = ()
+
+ @abstractmethod
+ def __contains__(self, key): # pragma: nocover
+ return False
+
+ @abstractmethod
+ def __getitem__(self, key): # pragma: nocover
+ if hasattr(self.__class__, '__missing__'):
+ return self.__class__.__missing__(self, key)
+ else:
+ raise KeyError(key)
+
+ def get(self, key, default=None):
+ if key in self:
+ return self[key]
+ else:
+ return default
+
+ __marker = object()
+
+ def pop(self, key, default=__marker):
+ if key in self:
+ value = self[key]
+ del self[key]
+ elif default is self.__marker:
+ raise KeyError(key)
+ else:
+ value = default
+ return value
+
+ def setdefault(self, key, default=None):
+ if key in self:
+ value = self[key]
+ else:
+ self[key] = value = default
+ return value
+
+DefaultMapping.register(dict)
« 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