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

Side by Side Diff: chrome/common/extensions/docs/server2/lazy_value.py

Issue 10704252: Extensions Docs Server: Internal file system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests Created 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 _no_value = object()
6
7 class LazyValue(object):
not at google - send to devlin 2012/07/18 10:39:15 I realised today that this isn't *like* Java's Fut
cduvall 2012/07/18 21:26:10 Done.
8 def __init__(self, value=_no_value, error=None, delegate=None):
9 self._value = value
10 self._error = error
11 self._delegate = delegate
12 if (self._value is _no_value and
13 self._error is None and
14 self._delegate is None):
not at google - send to devlin 2012/07/18 10:39:15 what's wrong with ==
cduvall 2012/07/18 21:26:10 See previous comment.
15 raise ValueError('Must have either a value, error, or delegate.')
16
17 def Get(self):
not at google - send to devlin 2012/07/18 10:39:15 documentation
cduvall 2012/07/18 21:26:10 Done.
18 if self._value is not _no_value:
19 return self._value
20 if self._error is not None:
not at google - send to devlin 2012/07/18 10:39:15 what's wrong with !=
cduvall 2012/07/18 21:26:10 See previous comment.
21 raise self._error
22 try:
23 self._value = self._delegate.Get()
24 except Exception as self._error:
25 raise
26 return self._value
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698