Skip to content

Commit

Permalink
Merge pull request #7725 from ccordoba12/merge-split-plugins
Browse files Browse the repository at this point in the history
PR: Split all plugins into their own modules
  • Loading branch information
ccordoba12 authored Aug 21, 2018
2 parents 5abd2a2 + c3544f6 commit 5affb8d
Show file tree
Hide file tree
Showing 503 changed files with 3,862 additions and 4,248 deletions.
29 changes: 16 additions & 13 deletions .circleci/modules_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,16 @@ for f in spyder/*/*/*.py; do
if [[ $f == spyder/utils/external/*.py ]]; then
continue
fi
if [[ $f == spyder/utils/help/*.py ]]; then
if [[ $f == spyder/plugins/*/plugin.py ]]; then
continue
fi
if [[ $f == spyder/utils/introspection/plugin_client.py ]]; then
continue
fi
if [[ $f == spyder/utils/introspection/numpy_docstr.py ]]; then
if [[ $f == spyder/plugins/*/__init__.py ]]; then
continue
fi
if [[ $f == spyder/utils/lsp_transport/*.py ]]; then
continue
fi
if [[ $f == spyder/utils/code_analysis/*.py ]]; then
if [[ $f == spyder/utils/introspection/plugin_client.py ]]; then
continue
fi
if [[ $f == spyder/widgets/ipythonconsole/__init__.py ]]; then
if [[ $f == spyder/utils/introspection/numpy_docstr.py ]]; then
continue
fi
python "$f"
Expand All @@ -90,7 +84,13 @@ for f in spyder/*/*/*/*.py; do
if [[ $f == *test*/*.* ]]; then
continue
fi
if [[ $f == spyder/utils/code_analysis/lsp_*/*.py ]]; then
if [[ $f == spyder/plugins/editor/lsp/*.py ]]; then
continue
fi
if [[ $f == spyder/plugins/help/utils/*.py ]]; then
continue
fi
if [[ $f == spyder/plugins/ipythonconsole/widgets/__init__.py ]]; then
continue
fi
python "$f"
Expand All @@ -100,11 +100,14 @@ for f in spyder/*/*/*/*.py; do
done


# Spyderplugins
for f in spyder_*/widgets/*.py; do
# Depth 5
for f in spyder/*/*/*/*/*.py; do
if [[ $f == *test*/*.* ]]; then
continue
fi
if [[ $f == spyder/plugins/editor/lsp/*/*.py ]]; then
continue
fi
python "$f"
if [ $? -ne 0 ]; then
exit 1
Expand Down
6 changes: 2 additions & 4 deletions create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def get_stdlib_modules():
APP = [APP_MAIN_SCRIPT]
DEPS = ['pylint', 'logilab', 'astroid', 'pycodestyle', 'setuptools']
EXCLUDES = DEPS + ['mercurial']
PACKAGES = ['spyder', 'spyder_breakpoints', 'spyder_io_dcm', 'spyder_io_hdf5',
'spyder_profiler', 'spyder_pylint', 'sphinx', 'jinja2', 'docutils',
PACKAGES = ['spyder', 'sphinx', 'jinja2', 'docutils',
'alabaster', 'babel', 'snowballstemmer', 'sphinx_rtd_theme',
'IPython', 'ipykernel', 'ipython_genutils', 'jupyter_client',
'jupyter_core', 'traitlets', 'qtconsole', 'pexpect', 'jedi',
Expand Down Expand Up @@ -151,8 +150,7 @@ def get_stdlib_modules():
# inside the app.
minimal_lib = osp.join(app_python_lib, 'minimal-lib')
os.mkdir(minimal_lib)
minlib_pkgs = ['spyder', 'spyder_breakpoints', 'spyder_io_dcm',
'spyder_io_hdf5', 'spyder_profiler', 'spyder_pylint']
minlib_pkgs = ['spyder']
for p in minlib_pkgs:
shutil.copytree(osp.join(app_python_lib, p), osp.join(minimal_lib, p))

Expand Down
3 changes: 0 additions & 3 deletions gettext_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@

if __name__ == "__main__":
do_compile("spyder")
do_compile("pylint", "spyder_pylint")
do_compile("profiler", "spyder_profiler")
do_compile("breakpoints", "spyder_breakpoints")
9 changes: 0 additions & 9 deletions gettext_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,3 @@

if __name__ == "__main__":
do_rescan("spyder")
do_rescan_files(["spyder_pylint/pylint.py",
"spyder_pylint/widgets/pylintgui.py"],
"pylint", "spyder_pylint")
do_rescan_files(["spyder_profiler/profiler.py",
"spyder_profiler/widgets/profilergui.py"],
"profiler", "spyder_profiler")
do_rescan_files(["spyder_breakpoints/breakpoints.py",
"spyder_breakpoints/widgets/breakpointsgui.py"],
"breakpoints", "spyder_breakpoints")
2 changes: 0 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ def main():
Run pytest tests.
"""
pytest_args = ['spyder',
'spyder_profiler',
'-x',
'-vv',
'-rw',
'--durations=10',
'--cov=spyder',
'--cov=spyder_profiler',
'--cov-report=term-missing']

if run_slow:
Expand Down
22 changes: 2 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ def get_data_files():

def get_packages():
"""Return package list"""
packages = (
get_subpackages(LIBNAME)
+ get_subpackages('spyder_breakpoints')
+ get_subpackages('spyder_profiler')
+ get_subpackages('spyder_pylint')
+ get_subpackages('spyder_io_dcm')
+ get_subpackages('spyder_io_hdf5')
)
packages = (get_subpackages(LIBNAME))
return packages


Expand Down Expand Up @@ -180,18 +173,7 @@ def run(self):
keywords='PyQt5 editor console widgets IDE science data analysis IPython',
platforms=["Windows", "Linux", "Mac OS-X"],
packages=get_packages(),
package_data={LIBNAME: get_package_data(LIBNAME, EXTLIST),
'spyder_breakpoints': get_package_data('spyder_breakpoints',
EXTLIST),
'spyder_profiler': get_package_data('spyder_profiler',
EXTLIST),
'spyder_pylint': get_package_data('spyder_pylint',
EXTLIST),
'spyder_io_dcm': get_package_data('spyder_io_dcm',
EXTLIST),
'spyder_io_hdf5': get_package_data('spyder_io_hdf5',
EXTLIST),
},
package_data={LIBNAME: get_package_data(LIBNAME, EXTLIST)},
scripts=[osp.join('scripts', fname) for fname in SCRIPTS],
data_files=get_data_files(),
classifiers=['License :: OSI Approved :: MIT License',
Expand Down
4 changes: 2 additions & 2 deletions spyder/api/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
This module contains the code editor API.
"""

from spyder.widgets.sourcecode.api.folding import print_tree, FoldDetector
from spyder.widgets.sourcecode.api.decoration import TextDecoration
from spyder.plugins.editor.api.folding import print_tree, FoldDetector
from spyder.plugins.editor.api.decoration import TextDecoration
7 changes: 4 additions & 3 deletions spyder/api/editorextension.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class EditorExtension(object):
A panel (model child class) is added to an editor by using the
PanelsManager:
- :meth:`spyder.widgets.sourcecode.CodeEditor.panels.append`
- :meth:
`spyder.plugins.editor.widgets.codeeditor.CodeEditor.panels.append`
Subclasses may/should override the following methods:
Expand All @@ -41,7 +42,7 @@ def editor(self):
**READ ONLY**
:rtype: spyder.widgets.sourcecode.CodeEditor
:rtype: spyder.plugins.editor.widgets.codeeditor.CodeEditor
"""
if self._editor is not None:
return self._editor
Expand Down Expand Up @@ -87,7 +88,7 @@ def on_install(self, editor):
Installs the extension on the editor.
:param editor: editor widget instance
:type editor: spyder.widgets.sourcecode.CodeEditor
:type editor: spyder.plugins.editor.widgets.codeeditor.CodeEditor
.. note:: This method is called by editor when you install a
EditorExtension.
Expand Down
2 changes: 1 addition & 1 deletion spyder/api/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def on_install(self, editor):
method!
:param editor: editor instance
:type editor: spyder.widgets.sourcecode.CodeEditor
:type editor: spyder.plugins.editor.widgets.codeeditor.CodeEditor
"""
EditorExtension.on_install(self, editor)
self.setParent(editor)
Expand Down
2 changes: 1 addition & 1 deletion spyder/api/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

# Local imports
from spyder.plugins.configdialog import SpyderConfigPage
from spyder.preferences.configdialog import SpyderConfigPage

class PluginConfigPage(SpyderConfigPage):
"""Plugin configuration dialog box page widget"""
Expand Down
60 changes: 37 additions & 23 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sys
import threading
import traceback
import importlib


#==============================================================================
Expand Down Expand Up @@ -353,19 +354,19 @@ def signal_handler(signum, frame=None):
self.give_updates_feedback = True

# Preferences
from spyder.plugins.configdialog import (MainConfigPage,
from spyder.preferences.configdialog import (MainConfigPage,
ColorSchemeConfigPage)
from spyder.plugins.shortcuts import ShortcutsConfigPage
from spyder.plugins.runconfig import RunConfigPage
from spyder.plugins.maininterpreter import MainInterpreterConfigPage
from spyder.preferences.shortcuts import ShortcutsConfigPage
from spyder.preferences.runconfig import RunConfigPage
from spyder.preferences.maininterpreter import MainInterpreterConfigPage
self.general_prefs = [MainConfigPage, ShortcutsConfigPage,
ColorSchemeConfigPage, MainInterpreterConfigPage,
RunConfigPage]
self.prefs_index = None
self.prefs_dialog_size = None

# Quick Layouts and Dialogs
from spyder.plugins.layoutdialog import (LayoutSaveDialog,
from spyder.preferences.layoutdialog import (LayoutSaveDialog,
LayoutSettingsDialog)
self.dialog_layout_save = LayoutSaveDialog
self.dialog_layout_settings = LayoutSettingsDialog
Expand Down Expand Up @@ -791,7 +792,7 @@ def create_edit_action(text, tr_text, icon):

# Internal console plugin
self.debug_print(" ..plugin: internal console")
from spyder.plugins.console import Console
from spyder.plugins.console.plugin import Console
self.console = Console(self, namespace, exitfunc=self.closing,
profile=self.profile,
multithreaded=self.multithreaded,
Expand All @@ -809,28 +810,28 @@ def create_edit_action(text, tr_text, icon):

# Working directory plugin
self.debug_print(" ..plugin: working directory")
from spyder.plugins.workingdirectory import WorkingDirectory
from spyder.plugins.workingdirectory.plugin import WorkingDirectory
self.workingdirectory = WorkingDirectory(self, self.init_workdir, main=self)
self.workingdirectory.register_plugin()
self.toolbarslist.append(self.workingdirectory.toolbar)

# Help plugin
if CONF.get('help', 'enable'):
self.set_splash(_("Loading help..."))
from spyder.plugins.help import Help
from spyder.plugins.help.plugin import Help
self.help = Help(self)
self.help.register_plugin()

# Outline explorer widget
if CONF.get('outline_explorer', 'enable'):
self.set_splash(_("Loading outline explorer..."))
from spyder.plugins.outlineexplorer import OutlineExplorer
from spyder.plugins.outlineexplorer.plugin import OutlineExplorer
self.outlineexplorer = OutlineExplorer(self)
self.outlineexplorer.register_plugin()

# Editor plugin
self.set_splash(_("Loading editor..."))
from spyder.plugins.editor import Editor
from spyder.plugins.editor.plugin import Editor
self.editor = Editor(self)
self.editor.register_plugin()

Expand Down Expand Up @@ -862,39 +863,39 @@ def create_edit_action(text, tr_text, icon):

# Namespace browser
self.set_splash(_("Loading namespace browser..."))
from spyder.plugins.variableexplorer import VariableExplorer
from spyder.plugins.variableexplorer.plugin import VariableExplorer
self.variableexplorer = VariableExplorer(self)
self.variableexplorer.register_plugin()

# Figure browser
self.set_splash(_("Loading figure browser..."))
from spyder.plugins.plots import Plots
from spyder.plugins.plots.plugin import Plots
self.plots = Plots(self)
self.plots.register_plugin()

# History log widget
if CONF.get('historylog', 'enable'):
self.set_splash(_("Loading history plugin..."))
from spyder.plugins.history import HistoryLog
from spyder.plugins.history.plugin import HistoryLog
self.historylog = HistoryLog(self)
self.historylog.register_plugin()

# IPython console
self.set_splash(_("Loading IPython console..."))
from spyder.plugins.ipythonconsole import IPythonConsole
from spyder.plugins.ipythonconsole.plugin import IPythonConsole
self.ipyconsole = IPythonConsole(self)
self.ipyconsole.register_plugin()

# Explorer
if CONF.get('explorer', 'enable'):
self.set_splash(_("Loading file explorer..."))
from spyder.plugins.explorer import Explorer
from spyder.plugins.explorer.plugin import Explorer
self.explorer = Explorer(self)
self.explorer.register_plugin()

# Online help widget
try: # Qt >= v4.4
from spyder.plugins.onlinehelp import OnlineHelp
from spyder.plugins.onlinehelp.plugin import OnlineHelp
except ImportError: # Qt < v4.4
OnlineHelp = None # analysis:ignore
if CONF.get('onlinehelp', 'enable') and OnlineHelp is not None:
Expand All @@ -904,17 +905,30 @@ def create_edit_action(text, tr_text, icon):

# Project explorer widget
self.set_splash(_("Loading project explorer..."))
from spyder.plugins.projects import Projects
from spyder.plugins.projects.plugin import Projects
self.projects = Projects(self)
self.projects.register_plugin()
self.project_path = self.projects.get_pythonpath(at_start=True)

# Find in files
if CONF.get('find_in_files', 'enable'):
from spyder.plugins.findinfiles import FindInFiles
from spyder.plugins.findinfiles.plugin import FindInFiles
self.findinfiles = FindInFiles(self)
self.findinfiles.register_plugin()

# Load other plugins (former external plugins)
# TODO: Use this bucle to load all internall plugins and remove
# duplicated code
other_plugins = ['breakpoints', 'profiler', 'pylint']
for plugin_name in other_plugins:
if CONF.get(plugin_name, 'enable'):
module = importlib.import_module(
'spyder.plugins.{}'.format(plugin_name))
plugin = module.PLUGIN_CLASS(self)
if plugin.check_compatibility()[0]:
self.thirdparty_plugins.append(plugin)
plugin.register_plugin()

# Third-party plugins
self.set_splash(_("Loading third-party plugins..."))
for mod in get_spyderplugins_mods():
Expand Down Expand Up @@ -2019,9 +2033,9 @@ def get_focus_widget_properties(self):
Returns tuple (widget, properties) where properties is a tuple of
booleans: (is_console, not_readonly, readwrite_editor)"""
widget = QApplication.focusWidget()
from spyder.widgets.shell import ShellBaseWidget
from spyder.widgets.editor import TextEditBaseWidget
from spyder.widgets.ipythonconsole import ControlWidget
from spyder.plugins.console.widgets.shell import ShellBaseWidget
from spyder.plugins.editor.widgets.editor import TextEditBaseWidget
from spyder.plugins.ipythonconsole.widgets import ControlWidget

# if focused widget isn't valid try the last focused
if not isinstance(widget, (ShellBaseWidget, TextEditBaseWidget,
Expand Down Expand Up @@ -2493,7 +2507,7 @@ def global_callback(self):
widget = QApplication.focusWidget()
action = self.sender()
callback = from_qvariant(action.data(), to_text_string)
from spyder.widgets.editor import TextEditBaseWidget
from spyder.plugins.editor.widgets.editor import TextEditBaseWidget

# If focused widget isn't valid try the last focused
if not isinstance(widget, TextEditBaseWidget):
Expand Down Expand Up @@ -2677,7 +2691,7 @@ def apply_statusbar_settings(self):
@Slot()
def edit_preferences(self):
"""Edit Spyder preferences"""
from spyder.plugins.configdialog import ConfigDialog
from spyder.preferences.configdialog import ConfigDialog
dlg = ConfigDialog(self)
dlg.size_change.connect(self.set_prefs_size)
if self.prefs_dialog_size is not None:
Expand Down
Loading

0 comments on commit 5affb8d

Please sign in to comment.