Debian Codegraph @

envisage/plugins/python_shell/python_shell_plugin.py

raw
1 # (C) Copyright 2007-2025 Enthought, Inc., Austin, TX
2 # All rights reserved.
3 #
4 # This software is provided without warranty under the terms of the BSD
5 # license included in LICENSE.txt and may be redistributed only under
6 # the conditions described in the aforementioned license. The license
7 # is also available online at http://www.enthought.com/licenses/BSD.txt
8 #
9 # Thanks for using Enthought open source!
10 """ The interactive Python shell plugin. """
11
12
13 from traits.api import Dict, List, Str
14
15 # Enthought library imports.
16 from envisage.api import ExtensionPoint, Plugin
17
18
19 class PythonShellPlugin(Plugin):
20 """The interactive Python shell plugin."""
21
22 # Extension point Ids.
23 BINDINGS = "envisage.plugins.python_shell.bindings"
24 COMMANDS = "envisage.plugins.python_shell.commands"
25 VIEWS = "envisage.ui.workbench.views"
26
27 #### 'IPlugin' interface ##################################################
28
29 # The plugin's unique identifier.
30 id = "envisage.plugins.python_shell"
31
32 # The plugin's name (suitable for displaying to the user).
33 name = "Python Shell"
34
35 #### Extension points offered by this plugin ##############################
36
37 bindings = ExtensionPoint(
38 List(Dict),
39 id=BINDINGS,
40 desc="""
41
42 This extension point allows you to contribute name/value pairs that
43 will be bound when the interactive Python shell is started.
44
45 e.g. Each item in the list is a dictionary of name/value pairs::
46
47 {'x' : 10, 'y' : ['a', 'b', 'c']}
48
49 """,
50 )
51
52 commands = ExtensionPoint(
53 List(Str),
54 id=COMMANDS,
55 desc="""
56
57 This extension point allows you to contribute commands that are
58 executed when the interactive Python shell is started.
59
60 e.g. Each item in the list is a string of arbitrary Python code::
61
62 'import os, sys'
63 'from traits.api import *'
64
65 Yes, I know this is insecure but it follows the usual Python rule of
66 'we are all consenting adults'.
67
68 """,
69 )
70
71 #### Contributions to extension points made by this plugin ################
72
73 # Bindings.
74 contributed_bindings = List(contributes_to=BINDINGS)
75
76 def _contributed_bindings_default(self):
77 """Trait initializer."""
78
79 return [{"application": self.application}]
80
81 # Views.
82 contributed_views = List(contributes_to=VIEWS)
83
84 def _contributed_views_default(self):
85 """Trait initializer."""
86
87 # Local imports.
88 from .view.namespace_view import NamespaceView
89 from .view.python_shell_view import PythonShellView
90
91 return [PythonShellView, NamespaceView]