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