Skip to content

Commit

Permalink
Reapply automated style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Mar 23, 2023
1 parent ee5c071 commit e4db865
Show file tree
Hide file tree
Showing 64 changed files with 380 additions and 125 deletions.
5 changes: 4 additions & 1 deletion envisage/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
from .core_plugin import CorePlugin
from .egg_plugin_manager import EggPluginManager
from .extension_point import ExtensionPoint
from .extension_point_binding import bind_extension_point, ExtensionPointBinding
from .extension_point_binding import (
bind_extension_point,
ExtensionPointBinding,
)
from .extension_point_changed_event import ExtensionPointChangedEvent
from .extension_provider import ExtensionProvider
from .extension_registry import ExtensionRegistry
Expand Down
20 changes: 15 additions & 5 deletions envisage/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def _preferences_default(self):
"""Trait initializer."""

return ScopedPreferences(
application_preferences_filename=os.path.join(self.home, "preferences.ini")
application_preferences_filename=os.path.join(
self.home, "preferences.ini"
)
)

#### Methods ##############################################################
Expand Down Expand Up @@ -218,7 +220,9 @@ def get_extension_points(self):

return self.extension_registry.get_extension_points()

def remove_extension_point_listener(self, listener, extension_point_id=None):
def remove_extension_point_listener(
self, listener, extension_point_id=None
):
"""Remove a listener for extensions being added/removed."""

self.extension_registry.remove_extension_point_listener(
Expand Down Expand Up @@ -343,7 +347,9 @@ def stop_plugin(self, plugin=None, plugin_id=None):
# 'IServiceRegistry' interface.
###########################################################################

def get_required_service(self, protocol, query="", minimize="", maximize=""):
def get_required_service(
self, protocol, query="", minimize="", maximize=""
):
"""Return the service that matches the specified query.
Raise a 'NoSuchServiceError' exception if no such service exists.
Expand All @@ -359,7 +365,9 @@ def get_required_service(self, protocol, query="", minimize="", maximize=""):
def get_service(self, protocol, query="", minimize="", maximize=""):
"""Return at most one service that matches the specified query."""

service = self.service_registry.get_service(protocol, query, minimize, maximize)
service = self.service_registry.get_service(
protocol, query, minimize, maximize
)

return service

Expand All @@ -385,7 +393,9 @@ def get_services(self, protocol, query="", minimize="", maximize=""):
def register_service(self, protocol, obj, properties=None):
"""Register a service."""

service_id = self.service_registry.register_service(protocol, obj, properties)
service_id = self.service_registry.register_service(
protocol, obj, properties
)

return service_id

Expand Down
4 changes: 3 additions & 1 deletion envisage/egg_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def __plugins_default(self):
"""Trait initializer."""

plugins = []
for ep in get_entry_points_in_egg_order(self.working_set, self.PLUGINS):
for ep in get_entry_points_in_egg_order(
self.working_set, self.PLUGINS
):
if self._is_included(ep.name) and not self._is_excluded(ep.name):
plugin = self._create_plugin_from_ep(ep)
plugins.append(plugin)
Expand Down
4 changes: 3 additions & 1 deletion envisage/egg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def get_entry_points_in_egg_order(working_set, entry_point_name):

# Find all distributions that actually contain contributions to the
# entry point.
distributions = get_distributions_with_entry_point(working_set, entry_point_name)
distributions = get_distributions_with_entry_point(
working_set, entry_point_name
)

# Order them in dependency order (i.e. ordered by their requirements).
distributions = get_distributions_in_egg_order(working_set, distributions)
Expand Down
4 changes: 3 additions & 1 deletion envisage/examples/demo/GUI_Application/traitsui_gui_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def on_application_start(self):
# Application entry point.
if __name__ == "__main__":
# Create the application.
application = GUIApplication(id="person_view", plugins=[PersonViewPlugin()])
application = GUIApplication(
id="person_view", plugins=[PersonViewPlugin()]
)

# Run it!
application.run()
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
),
Message(
author="Tom Gilb",
text="If you don't know what you're doing, don't do it on a large" " scale.",
text="If you don't know what you're doing, don't do it on a large"
" scale.",
),
Message(
author="Arthur Norman",
Expand Down
4 changes: 3 additions & 1 deletion envisage/examples/demo/MOTD/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def main():
# Import here so that this script can be run from anywhere without
# having to install the packages.
from acme.motd.motd_plugin import MOTDPlugin
from acme.motd.software_quotes.software_quotes_plugin import SoftwareQuotesPlugin
from acme.motd.software_quotes.software_quotes_plugin import (
SoftwareQuotesPlugin,
)

# Create an application containing the appropriate plugins.
application = Application(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class AttractorsApplication(TasksApplication):
def _default_layout_default(self):
active_task = self.preferences_helper.default_task
tasks = [factory.id for factory in self.task_factories]
return [TaskWindowLayout(*tasks, active_task=active_task, size=(800, 600))]
return [
TaskWindowLayout(*tasks, active_task=active_task, size=(800, 600))
]

def _preferences_helper_default(self):
return AttractorsPreferences(preferences=self.preferences)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class AttractorsPreferencesPane(PreferencesPane):
),
HGroup(
Label("Default active task:"),
Item("default_task", editor=EnumEditor(name="handler.task_map")),
Item(
"default_task", editor=EnumEditor(name="handler.task_map")
),
enabled_when="always_use_default_layout",
show_labels=False,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class Lorenz(HasTraits):
#### 'IModel3d' interface #################################################

name = Str("Lorenz Attractor")
points = Property(Array, observe="prandtl, rayleigh, beta, initial_point, times")
points = Property(
Array, observe="prandtl, rayleigh, beta, initial_point, times"
)

#### 'Lorenz' interface ###################################################

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ class ModelConfigPane(TraitsDockPane):

model = Instance(HasTraits)

view = View(Item("pane.model", style="custom", show_label=False), resizable=True)
view = View(
Item("pane.model", style="custom", show_label=False), resizable=True
)
10 changes: 9 additions & 1 deletion envisage/examples/demo/plugins/tasks/attractors/plot_3d_pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
from tvtk.pyface.scene_editor import SceneEditor

from pyface.tasks.api import TraitsTaskPane
from traits.api import Dict, Enum, Instance, List, on_trait_change, Property, Str
from traits.api import (
Dict,
Enum,
Instance,
List,
on_trait_change,
Property,
Str,
)
from traitsui.api import EnumEditor, HGroup, Item, Label, View


Expand Down
4 changes: 3 additions & 1 deletion envisage/extension_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def disconnect(self, obj, trait_name):
listener = self._obj_to_listeners_map[obj].get(trait_name)
if listener is not None:
# Remove the listener from the extension registry.
extension_registry.remove_extension_point_listener(listener, self.id)
extension_registry.remove_extension_point_listener(
listener, self.id
)

# Clean up.
del self._obj_to_listeners_map[obj][trait_name]
Expand Down
12 changes: 9 additions & 3 deletions envisage/extension_point_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,22 @@ def _update_trait(self, event):

self._set_trait(notify=False)

self.obj.trait_property_changed(self.trait_name + "_items", Undefined, event)
self.obj.trait_property_changed(
self.trait_name + "_items", Undefined, event
)

def _set_extensions(self, extensions):
"""Set the extensions to an extension point."""

self.extension_registry.set_extensions(self.extension_point_id, extensions)
self.extension_registry.set_extensions(
self.extension_point_id, extensions
)


# Factory function for creating bindings.
def bind_extension_point(obj, trait_name, extension_point_id, extension_registry):
def bind_extension_point(
obj, trait_name, extension_point_id, extension_registry
):
"""Create a binding to an extension point."""

return ExtensionPointBinding(
Expand Down
4 changes: 3 additions & 1 deletion envisage/extension_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def get_extensions(self, extension_point_id):

##### Protected 'ExtensionProvider' interface #############################

def _fire_extension_point_changed(self, extension_point_id, added, removed, index):
def _fire_extension_point_changed(
self, extension_point_id, added, removed, index
):
"""Fire an extension point changed event."""

self.extension_point_changed = ExtensionPointChangedEvent(
Expand Down
4 changes: 3 additions & 1 deletion envisage/extension_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def get_extension_points(self):

return list(self._extension_points.values())

def remove_extension_point_listener(self, listener, extension_point_id=None):
def remove_extension_point_listener(
self, listener, extension_point_id=None
):
"""Remove a listener for extensions being added or removed."""

listeners = self._listeners.setdefault(extension_point_id, [])
Expand Down
4 changes: 3 additions & 1 deletion envisage/i_extension_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def get_extension_point(self, extension_point_id):
def get_extension_points(self):
"""Return all extension points that have been added to the registry."""

def remove_extension_point_listener(self, listener, extension_point_id=None):
def remove_extension_point_listener(
self, listener, extension_point_id=None
):
"""Remove a listener for extensions being added or removed.
Raise a 'ValueError' if the listener does not exist.
Expand Down
4 changes: 3 additions & 1 deletion envisage/import_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def import_symbol(self, symbol_path):
module_name = ".".join(components[:-1])
symbol_name = components[-1]

module = __import__(module_name, globals(), locals(), [symbol_name])
module = __import__(
module_name, globals(), locals(), [symbol_name]
)

symbol = getattr(module, symbol_name)

Expand Down
8 changes: 6 additions & 2 deletions envisage/package_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def _get_plugins_module(self, package_name):
"""

try:
module = __import__(package_name + ".plugins", fromlist=["plugins"])
module = __import__(
package_name + ".plugins", fromlist=["plugins"]
)

except ImportError:
module = None
Expand Down Expand Up @@ -140,7 +142,9 @@ def _harvest_plugins_in_packages(self):
for child in File(dirname).children or []:
if child.is_package:
plugins.extend(
self._harvest_plugins_in_package(child.name, child.path)
self._harvest_plugins_in_package(
child.name, child.path
)
)

return plugins
Expand Down
11 changes: 8 additions & 3 deletions envisage/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def get_extension_points(self):
"""Return the extension points offered by the provider."""

extension_points = [
trait.trait_type for trait in self.traits(__extension_point__=True).values()
trait.trait_type
for trait in self.traits(__extension_point__=True).values()
]

return extension_points
Expand Down Expand Up @@ -169,7 +170,9 @@ def _id_default(self):

id = "%s.%s" % (type(self).__module__, type(self).__name__)
logger.warning(
"plugin {} has no Id - using <{}>".format(object.__repr__(self), id)
"plugin {} has no Id - using <{}>".format(
object.__repr__(self), id
)
)

return id
Expand All @@ -179,7 +182,9 @@ def _name_default(self):

name = camel_case_to_words(type(self).__name__)
logger.warning(
"plugin {} has no name - using <{}>".format(object.__repr__(self), name)
"plugin {} has no name - using <{}>".format(
object.__repr__(self), name
)
)

return name
Expand Down
8 changes: 6 additions & 2 deletions envisage/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def __iter__(self):
"""Return an iterator over the manager's plugins."""

plugins = [
plugin for plugin in self._plugins if self._include_plugin(plugin.id)
plugin
for plugin in self._plugins
if self._include_plugin(plugin.id)
]

return iter(plugins)
Expand Down Expand Up @@ -201,7 +203,9 @@ def _include_plugin(self, plugin_id):
"""

return self._is_included(plugin_id) and not self._is_excluded(plugin_id)
return self._is_included(plugin_id) and not self._is_excluded(
plugin_id
)

#### Private protocol #####################################################

Expand Down
8 changes: 6 additions & 2 deletions envisage/plugins/python_shell/view/namespace_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
)

from envisage.plugins.python_shell.api import IPythonShell
from envisage.plugins.python_shell.view.python_shell_view import PythonShellView
from envisage.plugins.python_shell.view.python_shell_view import (
PythonShellView,
)

# Table editor definition:
filters = [EvalFilterTemplate, MenuFilterTemplate, RuleFilterTemplate]
Expand Down Expand Up @@ -157,7 +159,9 @@ class item(HasTraits):
module = Str

data = [
item(name=name, type=type_to_str(value), module=module_to_str(value))
item(
name=name, type=type_to_str(value), module=module_to_str(value)
)
for name, value in self.shell_view.namespace.items()
]

Expand Down
4 changes: 3 additions & 1 deletion envisage/plugins/python_shell/view/python_shell_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def create_control(self, parent):
shell.on_trait_change(self._on_command_executed, "command_executed")

# Write application standard out to this shell instead of to DOS window
self.on_trait_change(self._on_write_stdout, "stdout_text", dispatch="ui")
self.on_trait_change(
self._on_write_stdout, "stdout_text", dispatch="ui"
)
self.original_stdout = sys.stdout
sys.stdout = PseudoFile(self._write_stdout)

Expand Down
4 changes: 3 additions & 1 deletion envisage/plugins/tasks/python_shell_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def start(self):
logger.debug("started python shell plugin")

def _contributed_bindings_default(self):
"""By default, expose the Envisage application object to the namespace"""
"""
By default, expose the Envisage application object to the namespace
"""
return [{"application": self.application}]

def _tasks_default(self):
Expand Down
4 changes: 3 additions & 1 deletion envisage/plugins/text_editor/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class NewFileAction(Action):

def perform(self, event=None):
logger.info("NewFileAction.perform()")
self.window.workbench.edit(File(""), kind=TextEditor, use_existing=False)
self.window.workbench.edit(
File(""), kind=TextEditor, use_existing=False
)


class OpenFileAction(Action):
Expand Down
Loading

0 comments on commit e4db865

Please sign in to comment.