/usr/lib/python2.7/dist-packages/envisage/tests/mutable_extension_registry.py is in python-envisage 4.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | """ A mutable, manually populated extension registry used for testing. """
# Enthought library imports.
from envisage.api import ExtensionRegistry, UnknownExtension
class MutableExtensionRegistry(ExtensionRegistry):
""" A mutable, manually populated extension registry used for testing. """
###########################################################################
# 'MutableExtensionRegistry' interface.
###########################################################################
def add_extension(self, extension_point_id, extension):
""" Contribute an extension to an extension point. """
self.add_extensions(extension_point_id, [extension])
return
def add_extensions(self, extension_point_id, extensions):
""" Contribute a list of extensions to an extension point. """
self._check_extension_point(extension_point_id)
old = self._get_extensions(extension_point_id)
index = len(old)
old.extend(extensions)
# Let any listeners know that the extensions have been added.
refs = self._get_listener_refs(extension_point_id)
self._call_listeners(refs, extension_point_id, extensions, [], index)
return
def remove_extension(self, extension_point_id, extension):
""" Remove a contribution from an extension point. """
self.remove_extensions(extension_point_id, [extension])
return
def remove_extensions(self, extension_point_id, extensions):
""" Remove a list of contributions from an extension point. """
for extension in extensions:
try:
self._get_extensions(extension_point_id).remove(extension)
except ValueError:
raise UnknownExtension(extension_point_id, extension)
# Let any listeners know that the extensions have been removed.
refs = self._get_listener_refs(extension_point_id)
self._call_listeners(refs, extension_point_id, [], extensions, None)
return
#### EOF ######################################################################
|