コード例 #1
0
def test():
    """Run dependency widget test"""
    from spyder import dependencies

    # Test sample
    dependencies.add("IPython", "IPython", "Enhanced Python interpreter",
                     ">=20.0")
    dependencies.add("matplotlib", "matplotlib", "Interactive data plotting",
                     ">=1.0")
    dependencies.add("sympy",
                     "sympy",
                     "Symbolic Mathematics",
                     ">=10.0",
                     kind=OPTIONAL)
    dependencies.add("foo", "foo", "Non-existent module", ">=1.0")
    dependencies.add("numpy",
                     "numpy",
                     "Edit arrays in Variable Explorer",
                     ">=0.10",
                     kind=OPTIONAL)

    from spyder.utils.qthelpers import qapplication
    app = qapplication()
    dlg = DependenciesDialog(None)
    dlg.set_data(dependencies.DEPENDENCIES)
    dlg.show()
    sys.exit(dlg.exec_())
コード例 #2
0
ファイル: registry.py プロジェクト: timgates42/spyder
    def _instantiate_spyder5_plugin(
            self, main_window: Any,
            PluginClass: Type[Spyder5PluginClass],
            external: bool) -> Spyder5PluginClass:
        """Instantiate and register a Spyder 5+ plugin."""
        required_plugins = list(set(PluginClass.REQUIRES))
        optional_plugins = list(set(PluginClass.OPTIONAL))
        plugin_name = PluginClass.NAME

        logger.debug(f'Registering plugin {plugin_name} - {PluginClass}')

        if PluginClass.CONF_FILE:
            CONF.register_plugin(PluginClass)

        for plugin in list(required_plugins):
            if plugin == Plugins.All:
                required_plugins = list(set(required_plugins + ALL_PLUGINS))

        for plugin in list(optional_plugins):
            if plugin == Plugins.All:
                optional_plugins = list(set(optional_plugins + ALL_PLUGINS))

        # Update plugin dependency information
        self._update_plugin_info(plugin_name, required_plugins,
                                 optional_plugins)

        # Create and store plugin instance
        plugin_instance = PluginClass(main_window, configuration=CONF)
        self.plugin_registry[plugin_name] = plugin_instance

        # Connect plugin availability signal to notification system
        plugin_instance.sig_plugin_ready.connect(
            lambda: self.notify_plugin_availability(
                plugin_name, omit_conf=PluginClass.CONF_FILE))

        # Initialize plugin instance
        plugin_instance.initialize()

        # Register plugins that are already available
        self._notify_plugin_dependencies(plugin_name)

        # Register the plugin name under the external or internal
        # plugin set
        if external:
            self.external_plugins |= {plugin_name}
        else:
            self.internal_plugins |= {plugin_name}

        if external:
            # These attributes come from spyder.app.find_plugins
            module = PluginClass._spyder_module_name
            package_name = PluginClass._spyder_package_name
            version = PluginClass._spyder_version
            description = plugin_instance.get_description()
            dependencies.add(module, package_name, description,
                                version, None, kind=dependencies.PLUGIN)

        return plugin_instance
コード例 #3
0
def test_dependencies(dependencies_dialog):
    """Run dependency widget test."""
    # Test sample
    dependencies.add("zmq", "Run introspection services", ">=10.0")
    dependencies.add("foo", "Non-existent module", ">=1.0")

    dependencies_dialog.set_data(dependencies.DEPENDENCIES)
    dependencies_dialog.show()
    assert dependencies_dialog
コード例 #4
0
def test_dependencies(qtbot):
    """Run dependency widget test."""
    # Test sample
    dependencies.add("IPython", "Enhanced Python interpreter", ">=0.13")
    dependencies.add("foo", "Non-existent module", ">=1.0")

    dlg = setup_dependencies(qtbot)
    dlg.set_data(dependencies.DEPENDENCIES)
    dlg.show()
    assert dlg
コード例 #5
0
ファイル: dependencies.py プロジェクト: 0xBADCA7/spyder
def test():
    """Run dependency widget test"""
    from spyder import dependencies
    
    # Test sample
    dependencies.add("IPython", "Enhanced Python interpreter", ">=20.0")
    dependencies.add("matplotlib", "Interactive data plotting", ">=1.0")
    dependencies.add("sympy", "Symbolic Mathematics", ">=10.0", optional=True)
    dependencies.add("foo", "Non-existent module", ">=1.0")
    dependencies.add("numpy", "Edit arrays in Variable Explorer", ">=0.10",
                     optional=True)
    
    from spyder.utils.qthelpers import qapplication
    app = qapplication()
    dlg = DependenciesDialog(None)
    dlg.set_data(dependencies.DEPENDENCIES)
    dlg.show()
    sys.exit(dlg.exec_())
コード例 #6
0
ファイル: test_dependencies.py プロジェクト: cfanpc/spyder
def test_dependencies(dependencies_dialog):
    """Run dependency widget test."""
    # Test sample
    dependencies.add("zmq", "Run introspection services", ">=10.0")
    dependencies.add("foo", "Non-existent module", ">=1.0")
    dependencies.add("bar", "Non-existing optional module", ">=10.0", optional=True)

    dependencies_dialog.set_data(dependencies.DEPENDENCIES)
    dependencies_dialog.show()
    assert dependencies_dialog
コード例 #7
0
def test_dependencies(qtbot):
    """Run dependency widget test."""
    # Test sample
    dependencies.add("zmq", "Run introspection services", ">=10.0")
    dependencies.add("foo", "Non-existent module", ">=1.0")
    dependencies.add("bar",
                     "Non-existing optional module",
                     ">=10.0",
                     optional=True)

    dlg = setup_dependencies(qtbot)
    dlg.set_data(dependencies.DEPENDENCIES)
    dlg.show()
    assert dlg
コード例 #8
0
ファイル: ipython.py プロジェクト: ShenggaoZhu/spyder
IPython configuration variables needed by Spyder
"""

from spyder.utils import programs
from spyder import dependencies
from spyder.config.base import _


# Constants
QTCONSOLE_REQVER = ">=4.2.0"
ZMQ_REQVER = ">=13.0.0"
NBCONVERT_REQVER = ">=4.0"


# Dependencies
dependencies.add("qtconsole", _("Jupyter Qtconsole integration"),
                 required_version=QTCONSOLE_REQVER)
dependencies.add("nbconvert", _("Manipulate Jupyter notebooks on the Editor"),
                 required_version=NBCONVERT_REQVER)


# Auxiliary functions
def is_qtconsole_installed():
    pyzmq_installed = programs.is_module_installed('zmq', version=ZMQ_REQVER)
    pygments_installed = programs.is_module_installed('pygments')
    qtconsole_installed = programs.is_module_installed('qtconsole',
                                                       version=QTCONSOLE_REQVER)

    if pyzmq_installed and pygments_installed and qtconsole_installed:
        return True
    else:
        return False
コード例 #9
0
ファイル: plugin.py プロジェクト: wtheis/spyder
from spyder.py3compat import get_meth_class_inst, to_text_string
from spyder.utils import icon_manager as ima
from spyder.utils import programs
from spyder.plugins.help.utils.sphinxify import (CSS_PATH,
                                                 generate_context,
                                                 usage, warning)
from spyder.utils.qthelpers import (add_actions, create_action,
                                    create_toolbutton, create_plugin_layout,
                                    MENU_SEPARATOR)
from spyder.plugins.help.confpage import HelpConfigPage
from spyder.plugins.help.utils.sphinxthread import SphinxThread
from spyder.plugins.help.widgets import PlainText, RichText, ObjectComboBox

# Sphinx dependency
dependencies.add("sphinx", "sphinx",
                 _("Show help for objects in the Editor and "
                   "Consoles in a dedicated pane"),
                 required_version='>=0.6.6')



class Help(SpyderPluginWidget):
    """
    Docstrings viewer widget
    """
    CONF_SECTION = 'help'
    CONFIGWIDGET_CLASS = HelpConfigPage
    LOG_PATH = get_conf_path(CONF_SECTION)
    FONT_SIZE_DELTA = DEFAULT_SMALL_DELTA

    # Signals
    focus_changed = Signal()
コード例 #10
0
from spyder.utils import icon_manager as ima
from spyder.utils.misc import (get_error_match, get_python_executable,
                               is_python_script, remove_backslashes)
from spyder.utils.qthelpers import create_action, mimedata2url
from spyder.plugins import SpyderPluginWidget
from spyder.plugins.configdialog import PluginConfigPage
from spyder.plugins.runconfig import get_run_configuration
from spyder.py3compat import to_text_string, is_text_string, getcwd
from spyder.widgets.externalshell.pythonshell import ExternalPythonShell
from spyder.widgets.externalshell.systemshell import ExternalSystemShell
from spyder.widgets.findreplace import FindReplace
from spyder.widgets.tabs import Tabs

MPL_REQVER = '>=1.0'
dependencies.add("matplotlib",
                 _("Interactive data plotting in the consoles"),
                 required_version=MPL_REQVER,
                 optional=True)


class ExternalConsoleConfigPage(PluginConfigPage):
    def __init__(self, plugin, parent):
        PluginConfigPage.__init__(self, plugin, parent)
        self.get_name = lambda: _("Python console")

    def setup_page(self):
        interface_group = QGroupBox(_("Interface"))
        newcb = self.create_checkbox
        singletab_box = newcb(_("One tab per script"), 'single_tab')
        showtime_box = newcb(_("Show elapsed time"), 'show_elapsed_time')
        icontext_box = newcb(_("Show icons and text"), 'show_icontext')
コード例 #11
0
ファイル: status.py プロジェクト: impact27/spyder
# Third party imports
from qtpy.QtCore import Qt, QSize, QTimer
from qtpy.QtGui import QFont
from qtpy.QtWidgets import QHBoxLayout, QLabel, QWidget

# Local imports
from spyder import dependencies
from spyder.config.base import _
from spyder.config.gui import get_font
from spyder.py3compat import to_text_string


if not os.name == 'nt':
    PSUTIL_REQVER = '>=0.3'
    dependencies.add("psutil", _("CPU and memory usage info in the status bar"),
                     required_version=PSUTIL_REQVER)


class StatusBarWidget(QWidget):
    """Status bar widget base."""
    TIP = None

    def __init__(self, parent, statusbar, icon=None):
        """Status bar widget base."""
        super(StatusBarWidget, self).__init__(parent)

        # Variables
        self.value = None

        # Widget
        self._icon = icon
コード例 #12
0
# Local imports
from spyder import dependencies
from spyder.config.base import _, DEBUG, debug_print, get_conf_path
from spyder.utils import sourcecode
from spyder.utils.introspection.plugin_client import PluginClient
from spyder.utils.introspection.utils import CodeInfo

PLUGINS = ['rope', 'jedi', 'fallback']

LOG_FILENAME = get_conf_path('introspection.log')
DEBUG_EDITOR = DEBUG >= 3
LEAD_TIME_SEC = 0.25

ROPE_REQVER = '>=0.9.4'
dependencies.add('rope',
                 _("Editor's code completion, go-to-definition and help"),
                 required_version=ROPE_REQVER)

JEDI_REQVER = '>=0.9.0'
dependencies.add('jedi',
                 _("Editor's code completion, go-to-definition and help"),
                 required_version=JEDI_REQVER)


class PluginManager(QObject):

    introspection_complete = Signal(object)

    def __init__(self, executable):

        super(PluginManager, self).__init__()
コード例 #13
0
from qtpy.QtWidgets import QStackedWidget, QVBoxLayout
from spyder_kernels.utils.nsview import REMOTE_SETTINGS

# Local imports
from spyder import dependencies
from spyder.config.base import _
from spyder.api.plugins import SpyderPluginWidget
from spyder.utils import icon_manager as ima
from spyder.plugins.variableexplorer.widgets.namespacebrowser import (
    NamespaceBrowser)
from spyder.plugins.variableexplorer.confpage import VariableExplorerConfigPage

PANDAS_REQVER = '>=0.13.1'
dependencies.add('pandas',
                 'pandas',
                 _("View and edit DataFrames and Series in the "
                   "Variable Explorer"),
                 required_version=PANDAS_REQVER,
                 optional=True)

NUMPY_REQVER = '>=1.7'
dependencies.add("numpy",
                 "numpy",
                 _("View and edit two and three dimensional arrays "
                   "in the Variable Explorer"),
                 required_version=NUMPY_REQVER,
                 optional=True)

PYMPLER_REQVER = '>=0.7'
dependencies.add("pympler",
                 "pympler",
                 _("Development tool to measure, monitor and analyze the"
コード例 #14
0
ファイル: utils.py プロジェクト: skewdlogix/spyder
# Local imports
from spyder.config.base import get_supported_types
from spyder.py3compat import (NUMERIC_TYPES, TEXT_TYPES, to_text_string,
                              is_text_string, is_binary_string, reprlib,
                              PY2, to_binary_string)
from spyder.utils import programs
from spyder import dependencies
from spyder.config.base import _


#==============================================================================
# Dependencies
#==============================================================================
PANDAS_REQVER = '>=0.13.1'
dependencies.add('pandas',  _("View and edit DataFrames and Series in the "
                              "Variable Explorer"),
                 required_version=PANDAS_REQVER, optional=True)

NUMPY_REQVER = '>=1.7'
dependencies.add("numpy", _("View and edit two and three dimensional arrays "
                            "in the Variable Explorer"),
                 required_version=NUMPY_REQVER, optional=True)

#==============================================================================
# FakeObject
#==============================================================================
class FakeObject(object):
    """Fake class used in replacement of missing modules"""
    pass

コード例 #15
0
ファイル: status.py プロジェクト: srandmose/spyder
from qtpy.QtCore import Qt, QSize, QTimer
from qtpy.QtGui import QFont
from qtpy.QtWidgets import QHBoxLayout, QLabel, QWidget

# Local imports
from spyder import dependencies
from spyder.config.base import _
from spyder.config.gui import get_font
from spyder.py3compat import to_text_string


if not os.name == 'nt':
    PSUTIL_REQVER = '>=0.3'
    dependencies.add(
        "psutil",
        "psutil",
        _("CPU and memory usage info in the status bar"),
        required_version=PSUTIL_REQVER)


class StatusBarWidget(QWidget):
    """Status bar widget base."""
    TIP = None

    def __init__(self, parent, statusbar, icon=None):
        """Status bar widget base."""
        super(StatusBarWidget, self).__init__(parent)

        # Variables
        self.value = None
コード例 #16
0
ファイル: pylintgui.py プロジェクト: rlaverde/spyder
                                       PythonModulesComboBox)
from spyder.widgets.onecolumntree import OneColumnTree
from spyder.widgets.variableexplorer.texteditor import TextEditor


# This is needed for testing this module as a stand alone script
try:
    _ = get_translation("pylint", "spyder_pylint")
except KeyError as error:
    import gettext
    _ = gettext.gettext

locale_codec = QTextCodec.codecForLocale()
PYLINT_REQVER = '>=0.25'
PYLINT_VER = pylint.__version__
dependencies.add("pylint", _("Static code analysis"),
                 required_version=PYLINT_REQVER, installed_version=PYLINT_VER)


#TODO: display results on 3 columns instead of 1: msg_id, lineno, message
class ResultsTree(OneColumnTree):
    sig_edit_goto = Signal(str, int, str)

    def __init__(self, parent):
        OneColumnTree.__init__(self, parent)
        self.filename = None
        self.results = None
        self.data = None
        self.set_title('')
        
    def activated(self, item):
        """Double-click event"""
コード例 #17
0
ファイル: coalagui.py プロジェクト: RohanVB/coala-spyder
from spyder.widgets.onecolumntree import OneColumnTree
from spyder.plugins.variableexplorer.widgets.texteditor import TextEditor

try:
    _ = get_translation('coala', 'spyder_coala')
except KeyError as error:
    import gettext
    _ = gettext.gettext

# todo: add coala-bears version
locale_codec = QTextCodec.codecForLocale()
COALA_REQVER = '>=0.11.0'
COALA_VER = (subprocess.check_output(['coala',
                                      '--version']).decode('utf-8')).rstrip()
dependencies.add("coala",
                 _("Static code analysis"),
                 required_version=COALA_REQVER,
                 installed_version=COALA_VER)


class ResultsTree(OneColumnTree):
    sig_edit_goto = Signal(str, int, str)

    def __init__(self, parent):
        OneColumnTree.__init__(self, parent)
        self.filename = None
        self.results = None
        self.data = None
        self.set_title('')

    def activated(self, item):
        """Double-click event"""
コード例 #18
0
ファイル: help.py プロジェクト: ShenggaoZhu/spyder
from spyder.utils import icon_manager as ima
from spyder.utils import programs
from spyder.utils.help.sphinxify import (CSS_PATH, generate_context,
                                         sphinxify, usage, warning)
from spyder.utils.qthelpers import (add_actions, create_action,
                                    create_toolbutton)
from spyder.widgets.browser import FrameWebView
from spyder.widgets.comboboxes import EditableComboBox
from spyder.widgets.externalshell.pythonshell import ExtPythonShellWidget
from spyder.widgets.findreplace import FindReplace
from spyder.widgets.sourcecode import codeeditor


# Sphinx dependency
dependencies.add("sphinx", _("Show help for objects in the Editor and "
                             "Consoles in a dedicated pane"),
                 required_version='>=0.6.6')


#XXX: Hardcoded dependency on optional IPython plugin component
#     that requires the hack to make this work without IPython
if QTCONSOLE_INSTALLED:
    from spyder.widgets.ipython import IPythonControlWidget
else:
    IPythonControlWidget = None  # analysis:ignore


class ObjectComboBox(EditableComboBox):
    """
    QComboBox handling object names
    """
コード例 #19
0
ファイル: plugin.py プロジェクト: burrbull/spyder
from qtpy.QtCore import QTimer, Signal, Slot
from qtpy.QtWidgets import QStackedWidget, QVBoxLayout
from spyder_kernels.utils.nsview import REMOTE_SETTINGS

# Local imports
from spyder import dependencies
from spyder.config.base import _
from spyder.api.plugins import SpyderPluginWidget
from spyder.utils import icon_manager as ima
from spyder.plugins.variableexplorer.widgets.namespacebrowser import (
        NamespaceBrowser)
from spyder.plugins.variableexplorer.confpage import VariableExplorerConfigPage

PANDAS_REQVER = '>=0.13.1'
dependencies.add('pandas',  _("View and edit DataFrames and Series in the "
                              "Variable Explorer"),
                 required_version=PANDAS_REQVER, optional=True)

NUMPY_REQVER = '>=1.7'
dependencies.add("numpy", _("View and edit two and three dimensional arrays "
                            "in the Variable Explorer"),
                 required_version=NUMPY_REQVER, optional=True)


class VariableExplorer(SpyderPluginWidget):
    """Variable Explorer plugin."""

    CONF_SECTION = 'variable_explorer'
    CONFIGWIDGET_CLASS = VariableExplorerConfigPage
    DISABLE_ACTIONS_WHEN_HIDDEN = False
    INITIAL_FREE_MEMORY_TIME_TRIGGER = 60 * 1000  # ms
コード例 #20
0
ファイル: pylintgui.py プロジェクト: Jbiloki/Discord-Bot-OW
                                       PythonModulesComboBox)
from spyder.widgets.onecolumntree import OneColumnTree
from spyder.widgets.variableexplorer.texteditor import TextEditor

# This is needed for testing this module as a stand alone script
try:
    _ = get_translation("pylint", "spyder_pylint")
except KeyError as error:
    import gettext
    _ = gettext.gettext

locale_codec = QTextCodec.codecForLocale()
PYLINT_REQVER = '>=0.25'
PYLINT_VER = pylint.__version__
dependencies.add("pylint",
                 _("Static code analysis"),
                 required_version=PYLINT_REQVER,
                 installed_version=PYLINT_VER)


#TODO: display results on 3 columns instead of 1: msg_id, lineno, message
class ResultsTree(OneColumnTree):
    def __init__(self, parent):
        OneColumnTree.__init__(self, parent)
        self.filename = None
        self.results = None
        self.data = None
        self.set_title('')

    def activated(self, item):
        """Double-click event"""
        data = self.data.get(id(item))
コード例 #21
0
ファイル: codeanalysis.py プロジェクト: M155K4R4/Spidr
                if 'analysis:ignore' not in \
                   to_text_string(lines[warning.lineno-1], coding):
                    results.append((warning.message % warning.message_args,
                                    warning.lineno))
    except Exception:
        # Never return None to avoid lock in spyder/widgets/editor.py
        # See Issue 1547
        results = []
        if DEBUG_EDITOR:
            traceback.print_exc()  # Print exception in internal console
    return results

# Required version:
# Why 0.5 (Python2)? Because it's based on _ast (thread-safe)
PYFLAKES_REQVER = '>=0.6.0' if PY3 else '>=0.5.0'
dependencies.add("pyflakes", _("Real-time code analysis on the Editor"),
                 required_version=PYFLAKES_REQVER)

PYCODESTYLE_REQVER = '>=2.3'
dependencies.add("pycodestyle", _("Real-time code style analysis on the Editor"),
                 required_version=PYCODESTYLE_REQVER)


def is_pyflakes_installed():
    """Return True if pyflakes required version is installed"""
    return programs.is_module_installed('pyflakes', PYFLAKES_REQVER)


def get_checker_executable(name):
    """Return checker executable in the form of a list of arguments
    for subprocess.Popen"""
    if programs.is_program_installed(name):
コード例 #22
0
ファイル: manager.py プロジェクト: ShenggaoZhu/spyder
from spyder.config.base import _, DEBUG, debug_print, get_conf_path
from spyder.utils import sourcecode
from spyder.utils.introspection.plugin_client import PluginClient
from spyder.utils.introspection.utils import CodeInfo


PLUGINS = ['rope', 'jedi', 'fallback']

LOG_FILENAME = get_conf_path('introspection.log')
DEBUG_EDITOR = DEBUG >= 3
LEAD_TIME_SEC = 0.25


ROPE_REQVER = '>=0.9.4'
dependencies.add('rope',
                 _("Editor's code completion, go-to-definition and help"),
                 required_version=ROPE_REQVER)

JEDI_REQVER = '>=0.8.1'
dependencies.add('jedi',
                 _("Editor's code completion, go-to-definition and help"),
                 required_version=JEDI_REQVER)


class PluginManager(QObject):

    introspection_complete = Signal(object)

    def __init__(self, executable):
        super(PluginManager, self).__init__()
        plugins = OrderedDict()
コード例 #23
0
ファイル: externalconsole.py プロジェクト: jitseniesen/spyder
from spyder.utils import icon_manager as ima
from spyder.utils.misc import (get_error_match, get_python_executable,
                               is_python_script, remove_backslashes)
from spyder.utils.qthelpers import create_action, mimedata2url
from spyder.plugins import SpyderPluginWidget
from spyder.plugins.configdialog import PluginConfigPage
from spyder.plugins.runconfig import get_run_configuration
from spyder.py3compat import to_text_string, is_text_string, getcwd
from spyder.widgets.externalshell.pythonshell import ExternalPythonShell
from spyder.widgets.externalshell.systemshell import ExternalSystemShell
from spyder.widgets.findreplace import FindReplace
from spyder.widgets.tabs import Tabs


MPL_REQVER = '>=1.0'
dependencies.add("matplotlib", _("Interactive data plotting in the consoles"),
                 required_version=MPL_REQVER, optional=True)


class ExternalConsoleConfigPage(PluginConfigPage):

    def __init__(self, plugin, parent):
        PluginConfigPage.__init__(self, plugin, parent)
        self.get_name = lambda: _("Python console")

    def setup_page(self):
        interface_group = QGroupBox(_("Interface"))
        newcb = self.create_checkbox
        singletab_box = newcb(_("One tab per script"), 'single_tab')
        showtime_box = newcb(_("Show elapsed time"), 'show_elapsed_time')
        icontext_box = newcb(_("Show icons and text"), 'show_icontext')