OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 from telemetry.core import extension_to_load |
5 from telemetry import extension_to_load | |
6 | 5 |
7 class ExtensionDict(object): | 6 class ExtensionDict(object): |
8 """Dictionary of ExtensionPage instances, with extension_id as key""" | 7 """Dictionary of ExtensionPage instances, with extension_id as key""" |
9 | 8 |
10 def __init__(self, extension_dict_backend): | 9 def __init__(self, extension_dict_backend): |
11 self._extension_dict_backend = extension_dict_backend | 10 self._extension_dict_backend = extension_dict_backend |
12 | 11 |
13 def __getitem__(self, load_extension): | 12 def __getitem__(self, load_extension): |
14 """Given an ExtensionToLoad instance, returns the corresponding | 13 """Given an ExtensionToLoad instance, returns the corresponding |
15 ExtensionPage instance.""" | 14 ExtensionPage instance.""" |
16 if not isinstance(load_extension, extension_to_load.ExtensionToLoad): | 15 if not isinstance(load_extension, extension_to_load.ExtensionToLoad): |
17 raise Exception("Input param must be of type ExtensionToLoad") | 16 raise Exception("Input param must be of type ExtensionToLoad") |
18 return self._extension_dict_backend.__getitem__( | 17 return self._extension_dict_backend.__getitem__( |
19 load_extension.extension_id()) | 18 load_extension.extension_id()) |
20 | 19 |
21 def __contains__(self, load_extension): | 20 def __contains__(self, load_extension): |
22 """Checks if this ExtensionToLoad instance has been loaded""" | 21 """Checks if this ExtensionToLoad instance has been loaded""" |
23 if not isinstance(load_extension, extension_to_load.ExtensionToLoad): | 22 if not isinstance(load_extension, extension_to_load.ExtensionToLoad): |
24 raise Exception("Input param must be of type ExtensionToLoad") | 23 raise Exception("Input param must be of type ExtensionToLoad") |
25 return self._extension_dict_backend.__contains__( | 24 return self._extension_dict_backend.__contains__( |
26 load_extension.extension_id()) | 25 load_extension.extension_id()) |
OLD | NEW |