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

Unified Diff: chrome/common/extensions/docs/server2/known_issues_data_source.py

Issue 13470005: Refactor the devserver to make it easier to control caching (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cduvall, rebase Created 7 years, 8 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
Index: chrome/common/extensions/docs/server2/known_issues_data_source.py
diff --git a/chrome/common/extensions/docs/server2/known_issues_data_source.py b/chrome/common/extensions/docs/server2/known_issues_data_source.py
deleted file mode 100644
index d527150621f7d81aef362f5616287fc05a56f477..0000000000000000000000000000000000000000
--- a/chrome/common/extensions/docs/server2/known_issues_data_source.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import csv
-import logging
-import operator
-from StringIO import StringIO
-
-import object_store
-from url_constants import OPEN_ISSUES_CSV_URL, CLOSED_ISSUES_CSV_URL
-
-class KnownIssuesDataSource:
- """A data source that fetches Apps issues from code.google.com, and returns a
- list of open and closed issues.
- """
- def __init__(self, object_store, url_fetch):
- self._object_store = object_store
- self._url_fetch = url_fetch
-
- def GetIssues(self, url):
- cached_data = self._object_store.Get(url, object_store.KNOWN_ISSUES).Get()
- if cached_data is not None:
- return cached_data
-
- issues = []
- response = self._url_fetch.Fetch(url)
- if response.status_code != 200:
- logging.warning('Fetching %s gave status code %s.' %
- (KNOWN_ISSUES_CSV_URL, response.status_code))
- # Return None so we can do {{^known_issues.open}} in the template.
- return None
- issues_reader = csv.DictReader(StringIO(response.content))
-
- for issue_dict in issues_reader:
- id = issue_dict.get('ID', '')
- title = issue_dict.get('Summary', '')
- if not id or not title:
- continue
- issues.append({ 'id': id, 'title': title })
- issues = sorted(issues, key=operator.itemgetter('title'))
- self._object_store.Set(url, issues, object_store.KNOWN_ISSUES)
- return issues
-
- def get(self, key):
- return {
- 'open': self.GetIssues(OPEN_ISSUES_CSV_URL),
- 'closed': self.GetIssues(CLOSED_ISSUES_CSV_URL)
- }.get(key, None)

Powered by Google App Engine
This is Rietveld 408576698