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

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

Issue 14883011: Switch from {...} to dict((...)) generator syntax. The former doesn't work in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/patched_file_system.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from datetime import datetime, timedelta 5 from datetime import datetime, timedelta
6 from file_system import FileNotFoundError, ToUnicode 6 from file_system import FileNotFoundError, ToUnicode
7 from future import Future 7 from future import Future
8 from patcher import Patcher 8 from patcher import Patcher
9 9
10 _VERSION_CACHE_MAXAGE = timedelta(seconds=5) 10 _VERSION_CACHE_MAXAGE = timedelta(seconds=5)
11 11
12 ''' Append @version for keys to distinguish between different patchsets of 12 ''' Append @version for keys to distinguish between different patchsets of
13 an issue. 13 an issue.
14 ''' 14 '''
15 def _MakeKey(path, version): 15 def _MakeKey(path, version):
16 return '%s@%s' % (path, version) 16 return '%s@%s' % (path, version)
17 17
18 def _ToObjectStoreValue(raw_value, version): 18 def _ToObjectStoreValue(raw_value, version):
19 return {_MakeKey(key, version): raw_value[key] for key in raw_value} 19 return dict((_MakeKey(key, version), raw_value[key])
20 for key in raw_value)
20 21
21 def _FromObjectStoreValue(raw_value, binary): 22 def _FromObjectStoreValue(raw_value, binary):
22 return {key[0:key.rfind('@')]: _HandleBinary(raw_value[key], binary) 23 return dict((key[0:key.rfind('@')], _HandleBinary(raw_value[key], binary))
23 for key in raw_value} 24 for key in raw_value)
24 25
25 def _HandleBinary(data, binary): 26 def _HandleBinary(data, binary):
26 return data if binary else ToUnicode(data) 27 return data if binary else ToUnicode(data)
27 28
28 class _AsyncUncachedFuture(object): 29 class _AsyncUncachedFuture(object):
29 def __init__(self, 30 def __init__(self,
30 version, 31 version,
31 paths, 32 paths,
32 binary, 33 binary,
33 cached_value, 34 cached_value,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return _AsyncUncachedFuture(version, 117 return _AsyncUncachedFuture(version,
117 paths, 118 paths,
118 binary, 119 binary,
119 cached_value, 120 cached_value,
120 missing_paths, 121 missing_paths,
121 self._patcher.Apply(set(added) | set(modified), 122 self._patcher.Apply(set(added) | set(modified),
122 None, 123 None,
123 True, 124 True,
124 version), 125 version),
125 self._file_object_store) 126 self._file_object_store)
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/patched_file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698