Chromium Code Reviews| Index: lib/dom/scripts/database.py |
| diff --git a/lib/dom/scripts/database.py b/lib/dom/scripts/database.py |
| index 4c9ef0947e6c94581031c649d1f91ad0d4a79e96..f51e027fa9509842e380b44e44e91959ddf226d4 100755 |
| --- a/lib/dom/scripts/database.py |
| +++ b/lib/dom/scripts/database.py |
| @@ -225,3 +225,15 @@ class Database(object): |
| if os.path.exists(file_path): |
| _logger.debug('deleting %s' % file_path) |
| os.remove(file_path) |
| + |
| + def FindInHierarchy(self, interface, test): |
|
Anton Muhin
2012/07/16 10:27:04
I'd rather implement it as Python's generator, som
podivilov
2012/07/16 12:08:36
Done.
|
| + if test(interface): |
| + return interface |
| + for parent in interface.parents: |
| + parent_name = parent.type.id |
| + if not self.HasInterface(parent.type.id): |
| + continue |
| + parent_interface = self.GetInterface(parent.type.id) |
| + parent_interface = self.FindInHierarchy(parent_interface, test) |
| + if parent_interface: |
| + return parent_interface |