| 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 logging | 5 import logging |
| 6 | 6 |
| 7 _APP_YAML_CONTAINER = ''' | 7 _APP_YAML_CONTAINER = ''' |
| 8 application: chrome-apps-doc | 8 application: chrome-apps-doc |
| 9 version: %s | 9 version: %s |
| 10 runtime: python27 | 10 runtime: python27 |
| 11 api_version: 1 | 11 api_version: 1 |
| 12 threadsafe: false | 12 threadsafe: false |
| 13 ''' | 13 ''' |
| 14 | 14 |
| 15 class AppYamlHelper(object): | 15 class AppYamlHelper(object): |
| 16 '''Parses the app.yaml file, and is able to step back in the host file | 16 '''Parses the app.yaml file, and is able to step back in the host file |
| 17 system's revision history to find when it changed to some given version. | 17 system's revision history to find when it changed to some given version. |
| 18 ''' | 18 ''' |
| 19 class Delegate(object): | 19 class Delegate(object): |
| 20 def GetHostFileSystemForRevision(self, revision): | 20 def GetHostFileSystemForRevision(self, revision): |
| 21 '''Revision may not be None. | 21 '''Revision may not be None. |
| 22 ''' | 22 ''' |
| 23 raise NotImplementedError() | 23 raise NotImplementedError(self.__class__) |
| 24 | 24 |
| 25 def __init__(self, | 25 def __init__(self, |
| 26 app_yaml_path, | 26 app_yaml_path, |
| 27 file_system_at_head, | 27 file_system_at_head, |
| 28 delegate, | 28 delegate, |
| 29 object_store_creator): | 29 object_store_creator): |
| 30 self._app_yaml_path = app_yaml_path | 30 self._app_yaml_path = app_yaml_path |
| 31 self._file_system_at_head = file_system_at_head | 31 self._file_system_at_head = file_system_at_head |
| 32 self._delegate = delegate | 32 self._delegate = delegate |
| 33 self._store = object_store_creator.Create( | 33 self._store = object_store_creator.Create( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 # Back up a revision then find when app.yaml was last updated before then. | 122 # Back up a revision then find when app.yaml was last updated before then. |
| 123 if found == 0: | 123 if found == 0: |
| 124 logging.warning('All revisions are greater than %s' % app_version) | 124 logging.warning('All revisions are greater than %s' % app_version) |
| 125 return 0 | 125 return 0 |
| 126 next_file_system = self._delegate.GetHostFileSystemForRevision( | 126 next_file_system = self._delegate.GetHostFileSystemForRevision( |
| 127 found - 1) | 127 found - 1) |
| 128 | 128 |
| 129 if found is None: | 129 if found is None: |
| 130 raise ValueError('All revisions are less than %s' % app_version) | 130 raise ValueError('All revisions are less than %s' % app_version) |
| 131 return found | 131 return found |
| OLD | NEW |