OLD | NEW |
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 import json | 5 import json |
6 import logging | 6 import logging |
7 from cStringIO import StringIO | 7 from cStringIO import StringIO |
8 import posixpath | 8 import posixpath |
9 import traceback | 9 import traceback |
10 from zipfile import ZipFile | 10 from zipfile import ZipFile |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 repo, | 119 repo, |
120 object_store_creator or ObjectStoreCreator.ForTest(), | 120 object_store_creator or ObjectStoreCreator.ForTest(), |
121 fake_fetcher) | 121 fake_fetcher) |
122 | 122 |
123 def __init__(self, base_url, owner, repo, object_store_creator, Fetcher): | 123 def __init__(self, base_url, owner, repo, object_store_creator, Fetcher): |
124 self._repo_key = posixpath.join(owner, repo) | 124 self._repo_key = posixpath.join(owner, repo) |
125 self._repo_url = posixpath.join(base_url, owner, repo) | 125 self._repo_url = posixpath.join(base_url, owner, repo) |
126 self._username, self._password = _LoadCredentials(object_store_creator) | 126 self._username, self._password = _LoadCredentials(object_store_creator) |
127 self._blobstore = blobstore.AppEngineBlobstore() | 127 self._blobstore = blobstore.AppEngineBlobstore() |
128 self._fetcher = Fetcher(self._repo_url) | 128 self._fetcher = Fetcher(self._repo_url) |
129 # Stores whether the github is up-to-date. This will either be True or | 129 # Stores whether the github is up to date. This will either be True or |
130 # empty, the emptiness most likely due to this being a cron run. | 130 # empty, the emptiness most likely due to this being a cron run. |
131 self._up_to_date_cache = object_store_creator.Create( | 131 self._up_to_date_cache = object_store_creator.Create( |
132 GithubFileSystem, category='up-to-date') | 132 GithubFileSystem, category='up-to-date') |
133 # Caches the zip file's stat. Overrides start_empty=False and use | 133 # Caches the zip file's stat. Overrides start_empty=False and use |
134 # |self._up_to_date_cache| to determine whether we need to refresh. | 134 # |self._up_to_date_cache| to determine whether we need to refresh. |
135 self._stat_cache = object_store_creator.Create( | 135 self._stat_cache = object_store_creator.Create( |
136 GithubFileSystem, category='stat-cache', start_empty=False) | 136 GithubFileSystem, category='stat-cache', start_empty=False) |
137 | 137 |
138 # Created lazily in |_EnsureRepoZip|. | 138 # Created lazily in |_EnsureRepoZip|. |
139 self._repo_zip = None | 139 self._repo_zip = None |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 for p in repo_zip.List(path)) | 285 for p in repo_zip.List(path)) |
286 return stat_info | 286 return stat_info |
287 | 287 |
288 def GetIdentity(self): | 288 def GetIdentity(self): |
289 return '%s' % StringIdentity(self.__class__.__name__ + self._repo_key) | 289 return '%s' % StringIdentity(self.__class__.__name__ + self._repo_key) |
290 | 290 |
291 def __repr__(self): | 291 def __repr__(self): |
292 return '%s(key=%s, url=%s)' % (type(self).__name__, | 292 return '%s(key=%s, url=%s)' % (type(self).__name__, |
293 self._repo_key, | 293 self._repo_key, |
294 self._repo_url) | 294 self._repo_url) |
OLD | NEW |