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

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

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First round of changes Created 7 years, 9 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
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 from file_system import FileNotFoundError
6 import object_store
7
8 class AvailabilityDataSource:
cduvall 2013/03/25 22:59:43 Class level comment about what this does.
epeterson 2013/03/27 22:36:09 Done.
9 def __init__(self,
10 version_data_source,
11 version_number,
12 object_store):
13 self._version_data_source = version_data_source
14 self._version_number = version_number
15 self._object_store = object_store
16
17 def FindEarliestAvailability(self, api_name):
18 """Searches in descending order through filesystem caches tied to specific
19 chrome version numbers and looks for the existence of a specified api,
20 |api_name|. When an api is not found, returns the previous version number
21 (the last known version where the api was found).
22 """
23 version = self._object_store.Get(
24 api_name,
25 object_store.AVAILABILITY_DATA_SOURCE).Get()
26
27 if version is not None:
28 return version
29
30 version_number = int(self._version_number)
31 # extension api's are not present before version 18
cduvall 2013/03/25 22:59:43 Full sentence with proper punctuation for all comm
epeterson 2013/03/27 22:36:09 Done.
32 while version_number >= 18:
33 api_data_source = self._version_data_source.GetDataSourceForVersion(
34 '%d' % version_number)
35 try:
36 api_data_source.tryGet(api_name)
37 except FileNotFoundError:
38 try:
39 api_data_source.tryGet(api_name, try_non_unix=True)
40 except FileNotFoundError:
41 break
42 version_number -= 1
43
44 version_number += 1
45 # if version_number is greater than self._version_number, then the api was
46 # not found in the current version
47 if version_number > self._version_number:
48 version = 'Not available yet'
49 else:
50 version = '%d' % version_number
51 self._object_store.Set(api_name,
52 version,
53 object_store.AVAILABILITY_DATA_SOURCE)
54 return version
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698