from spyder.utils.qthelpers import create_toolbutton, get_icon
from spyder.widgets.comboboxes import PythonModulesComboBox
from spyder.utils.misc import add_pathlist_to_PYTHONPATH
from spyder.widgets.variableexplorer.texteditor import TextEditor

try:
    from spyder.py3compat import to_text_string, getcwd, pickle
except ImportError:
    # python2
    to_text_string = unicode
    getcwd = os.getcwdu
    import cPickle as pickle

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


locale_codec = QTextCodec.codecForLocale()


COL_NO = 0
COL_HITS = 1
COL_TIME = 2
COL_PERHIT = 3
COL_PERCENT = 4
COL_LINE = 5
COL_POS = 0  # Position is not displayed but set as Qt.UserRole
Ejemplo n.º 2
0
from spyder.utils.qthelpers import create_action

# Third party imports
ERR_MSG = ""
try:
    import black
except ImportError:
    ERR_MSG = "Please install black."

try:
    from spyder.py3compat import to_text_string
except ImportError:
    # Python 2
    to_text_string = unicode  # noqa

_ = get_translation("black", dirname="spyder_black")


class Black(SpyderPluginMixin):  # pylint: disable=R0904
    """Python source code automatic formatting based on black.

    QObject is needed to register the action.
    """

    CONF_SECTION = "spyder.autopep8"

    # --- SpyderPlugin API ----------------------------------------------------
    def get_plugin_title(self):
        """Return widget title."""
        return _("black")
Ejemplo n.º 3
0
from spyder.api.plugins import SpyderPluginWidget
from spyder.widgets.dock import SpyderDockWidget
from spyder.py3compat import getcwd, to_text_string
from qtpy.QtWidgets import (QApplication, QMessageBox, QFileDialog, QAction)
from qtpy.compat import getopenfilenames, from_qvariant
from spyder.utils import encoding, sourcecode
from spyder.utils.qthelpers import create_action
from spyder.plugins.editor.widgets.codeeditor import CodeEditor

try:
    import tellurium as te
except ImportError:
    raise Exception(
        "Cannot find Tellurium. Please install Tellurium scripts first")

_ = get_translation("opensbml", dirname="spyder_opensbml")


class openSBML(SpyderPluginWidget):
    "Open sbml files and translate into antimony string"

    CONF_SECTION = 'openSBML'
    CONFIGWIDGET_CLASS = None

    def __init__(self, main):
        super(openSBML, self).__init__(main)
        self.dockwidget = SpyderDockWidget(self.get_plugin_title(), main)
        self.dockwidget.hide()

    # --- SpyderPluginWidget API ----------------------------------------------
    def get_plugin_title(self):
Ejemplo n.º 4
0
from spyder.config.base import get_translation
from spyder.config.gui import fixed_shortcut
from spyder.plugins import SpyderPluginMixin
from spyder.plugins.configdialog import PluginConfigPage
from spyder.utils.qthelpers import get_icon, create_action
from spyder.utils import icon_manager as ima

try:
    from spyder.py3compat import to_text_string
except ImportError:
    # Python 2
    to_text_string = unicode


_ = get_translation("autopep8", dirname="spyder_autopep8")


class AutoPEP8ConfigPage(PluginConfigPage):
    """
    Widget with configuration options for line profiler.
    """
    GROUPS = {
        "1": "Indentation",
        "2": "Whitespace",
        "3": "Blank line",
        "4": "Import",
        "5": "Line length",
        "6": "Deprecation",
        "7": "Statement",
        "9": "Runtime"}
Ejemplo n.º 5
0
# pylint: disable=R0903
# pylint: disable=R0911
# pylint: disable=R0201

# Standard library imports
import os.path as osp

# Local imports
from spyder.config.base import get_translation
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import create_action
from spyder.plugins import SpyderPluginMixin
from spyder.py3compat import to_text_string, is_text_string
from .widgets.breakpointsgui import BreakpointWidget

_ = get_translation("breakpoints", "spyder_breakpoints")


class Breakpoints(BreakpointWidget, SpyderPluginMixin):
    """Breakpoint list"""
    CONF_SECTION = 'breakpoints'

    #    CONFIGWIDGET_CLASS = BreakpointConfigPage
    def __init__(self, parent=None):
        BreakpointWidget.__init__(self, parent=parent)
        SpyderPluginMixin.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()
        self.set_data()
Ejemplo n.º 6
0
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
"""Unit testing Plugin."""

# Third party imports
from qtpy.QtWidgets import QVBoxLayout
from spyder.config.base import get_translation
from spyder.plugins import SpyderPluginWidget
from spyder.py3compat import getcwd
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import create_action

# Local imports
from .widgets.unittestgui import UnitTestWidget, is_unittesting_installed

_ = get_translation("unittest", dirname="spyder_unittest")


class UnitTestPlugin(SpyderPluginWidget):
    """Spyder plugin for unit testing."""

    CONF_SECTION = 'unittest'

    def __init__(self, parent=None):
        """Initialize plugin and corresponding widget."""
        SpyderPluginWidget.__init__(self, parent)
        self.main = parent  # Spyder 3 compatibility

        # Create unit test widget
        self.unittestwidget = UnitTestWidget(self.main)
        self.update_pythonpath()
Ejemplo n.º 7
0
# Local imports
from spyder import dependencies
from spyder.config.base import get_conf_path, get_translation
from spyder.py3compat import pickle, to_text_string
from spyder.utils import icon_manager as ima
from spyder.utils.encoding import to_unicode_from_fs
from spyder.utils.qthelpers import create_toolbutton
from spyder.utils.misc import getcwd_or_home
from spyder.widgets.comboboxes import (is_module_or_package,
                                       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):
Ejemplo n.º 8
0
# Third party imports
from qtpy.QtCore import Qt, Signal
from qtpy.QtWidgets import QGroupBox, QLabel, QVBoxLayout

# Local imports
from spyder.config.base import get_translation
from spyder.plugins import SpyderPluginMixin
from spyder.plugins.configdialog import PluginConfigPage
from spyder.plugins.runconfig import get_run_configuration
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import create_action
from .widgets.profilergui import ProfilerWidget, is_profiler_installed


_ = get_translation("profiler", "spyder_profiler")


class ProfilerConfigPage(PluginConfigPage):
    def setup_page(self):
        results_group = QGroupBox(_("Results"))
        results_label1 = QLabel(
            _("Profiler plugin results " "(the output of python's profile/cProfile)\n" "are stored here:")
        )
        results_label1.setWordWrap(True)

        # Warning: do not try to regroup the following QLabel contents with
        # widgets above -- this string was isolated here in a single QLabel
        # on purpose: to fix Issue 863
        results_label2 = QLabel(ProfilerWidget.DATAPATH)
Ejemplo n.º 9
0
import sys
import os
import os.path as osp
import time
from lxml import etree

# Local imports
from spyder.utils.qthelpers import create_toolbutton
from spyder.utils import icon_manager as ima
from spyder.utils import programs
from spyder.config.base import get_conf_path, get_translation
from spyder.widgets.variableexplorer.texteditor import TextEditor
from spyder.widgets.comboboxes import PythonModulesComboBox
from spyder.widgets.externalshell import baseshell
from spyder.py3compat import to_text_string, getcwd
_ = get_translation("unittesting", dirname="spyder_unittesting")


COL_POS = 0  # Position is not displayed but set as Qt.UserRole

COLOR_OK = QBrush(QColor("#C1FFBA"))
COLOR_SKIP = QBrush(QColor("#C5C5C5"))
COLOR_FAIL = QBrush(QColor("#FF0000"))
COLORS = {
    "ok": COLOR_OK,
    "failure": COLOR_FAIL,  # py.test
    "error": COLOR_FAIL,  # nose
    "skipped": COLOR_SKIP,  # py.test, nose
    }

# Third party imports
from qtpy.QtCore import Qt, Signal
from qtpy.QtWidgets import QVBoxLayout, QGroupBox, QLabel

from spyder.config.base import get_translation
from spyder.config.gui import fixed_shortcut
from spyder.plugins import SpyderPluginMixin, runconfig
from spyder.plugins.configdialog import PluginConfigPage
from spyder.utils.qthelpers import get_icon, create_action

# Local imports
from .widgets.memoryprofiler import (MemoryProfilerWidget,
					           is_memoryprofiler_installed)

_ = get_translation("memory_profiler", dirname="spyder_memory_profiler")


class MemoryProfilerConfigPage(PluginConfigPage):
    """
    Widget with configuration options for memory profiler.
    """

    def setup_page(self):
        settings_group = QGroupBox(_("Settings"))
        use_color_box = self.create_checkbox(
            _("Use deterministic colors to differentiate functions"),
            'use_colors', default=True)

        results_group = QGroupBox(_("Results"))
        results_label1 = QLabel(_("Memory profiler plugin results "
Ejemplo n.º 11
0
                            QVBoxLayout, QWidget)

from spyder.plugins.coalaspyder.widgets.run_coala import UseCoala as coala
from spyder import dependencies
from spyder.config.base import get_conf_path, get_translation
from spyder.py3compat import pickle, to_text_string
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import create_toolbutton
from spyder.utils.misc import getcwd_or_home
from spyder.widgets.comboboxes import (is_module_or_package,
                                       PythonModulesComboBox)
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)

Ejemplo n.º 12
0
# -*- coding: utf-8 -*-
#
# Copyright (c) Spyder Project Contributors
# Licensed under the terms of the MIT License
"""Localization utility function."""

from spyder.config.base import get_translation

_ = get_translation('spyder_notebook')
Ejemplo n.º 13
0
ERR_MSG = ""
try:
    from black import format_str, FileMode, TargetVersion
except ImportError:
    ERR_MSG = "Please, install black."

try:  # Spyder4
    from spyder.api.plugins import SpyderPluginWidget as BasePluginClass
    from spyder.api.preferences import PluginConfigPage
except ImportError:  # Spyder3
    from spyder.plugins import SpyderPluginMixin as BasePluginClass
    from spyder.plugins.configdialog import PluginConfigPage

# from spyder.utils.icon_manager import get_icon

_ = get_translation("black", dirname="spyder_black_formatter")


def get_python_version():
    major = sys.version_info.major
    minor = sys.version_info.minor
    return f"python {major}.{minor}"


target_version = (
    ("python 3.3", "PY33"),
    ("python 3.4", "PY34"),
    ("python 3.5", "PY35"),
    ("python 3.6", "PY36"),
    ("python 3.7", "PY37"),
    ("python 3.8", "PY38"),
Ejemplo n.º 14
0
from spyder.utils.qthelpers import create_action, add_actions
from spyder.plugins.editor.widgets.codeeditor import CodeEditor

try:
    import tellurium as te
except ImportError:
    raise Exception(
        "Cannot find Tellurium. Please install Tellurium scripts first")

try:
    import phrasedml as pl
except ImportError:
    raise Exception(
        "Cannot find PhrasedML. Please install PhrasedML package first")

_ = get_translation("teImport", dirname="spyder_teimport")


class teImport(SpyderPluginWidget):
    """teImport script"""
    CONF_SECTION = 'teImport'
    CONFIGWIDGET_CLASS = None

    def __init__(self, main):
        super(teImport, self).__init__(main)
        self.dockwidget = SpyderDockWidget(self.get_plugin_title(), main)
        self.dockwidget.hide()

    #------ SpyderPluginWidget API --------------------------------------------
    def get_plugin_title(self):
        """Return widget title"""
Ejemplo n.º 15
0
# Local imports
from spyder import dependencies
from spyder.config.base import get_conf_path, get_translation
from spyder.py3compat import getcwd, pickle, to_text_string
from spyder.utils import icon_manager as ima
from spyder.utils.encoding import to_unicode_from_fs
from spyder.utils.qthelpers import create_toolbutton
from spyder.widgets.comboboxes import (is_module_or_package,
                                       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)
Ejemplo n.º 16
0
# Need running QApplication before importing runconfig
from spyder.utils.qthelpers import qapplication
MAIN_APP = qapplication()

from spyder.api.plugins import SpyderPluginWidget
from spyder.api.preferences import PluginConfigPage
from spyder.config.base import get_translation
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import create_action

# Local imports
from .data import images
from .widgets.lineprofiler import LineProfilerWidget, is_lineprofiler_installed


_ = get_translation("line_profiler", dirname="spyder_line_profiler")


class LineProfilerConfigPage(PluginConfigPage):
    """
    Widget with configuration options for line profiler.
    """
    def setup_page(self):
        settings_group = QGroupBox(_("Settings"))
        use_color_box = self.create_checkbox(
            _("Use deterministic colors to differentiate functions"),
            'use_colors', default=True)

        results_group = QGroupBox(_("Results"))
        results_label1 = QLabel(_("Line profiler plugin results "
                                  "(the output of kernprof.py)\n"
from spyder.config.base import get_conf_path, get_translation
from spyder.utils import programs
from spyder.utils.qthelpers import create_toolbutton, get_icon
from spyder.utils.misc import add_pathlist_to_PYTHONPATH, get_python_executable
from spyder.widgets.comboboxes import PythonModulesComboBox
from spyder.widgets.variableexplorer.texteditor import TextEditor

try:
    from spyder.py3compat import to_text_string, getcwd
except ImportError:
    # python2
    to_text_string = unicode
    getcwd = os.getcwdu

locale_codec = QTextCodec.codecForLocale()
_ = get_translation("memory_profiler", dirname="spyder_memory_profiler")

COL_NO = 0
COL_USAGE = 1
COL_INCREMENT = 2
COL_LINE = 3
COL_POS = 0  # Position is not displayed but set as Qt.UserRole

CODE_NOT_RUN_COLOR = QBrush(QColor.fromRgb(128, 128, 128, 200))

WEBSITE_URL = 'https://pypi.python.org/pypi/memory_profiler/'


def is_memoryprofiler_installed():
    """
    Checks if the library for memory_profiler is installed.
Ejemplo n.º 18
0
from qtpy import API
from qtpy.compat import to_qvariant
from qtpy.QtCore import (QAbstractTableModel, QModelIndex, QTextCodec, Qt,
                         Signal)
from qtpy.QtWidgets import (QItemDelegate, QMenu, QTableView, QHBoxLayout,
                            QVBoxLayout, QWidget)

# Local imports
from spyder.config.base import get_translation
from spyder.config.main import CONF
from spyder.utils.qthelpers import (add_actions, create_action,
                                    create_plugin_layout)

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


locale_codec = QTextCodec.codecForLocale()


class BreakpointTableModel(QAbstractTableModel):
    """
    Table model for breakpoints dictionary
    
    """
    def __init__(self, parent, data):
        QAbstractTableModel.__init__(self, parent)
Ejemplo n.º 19
0
from spyder.config.gui import is_dark_interface
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import create_action, add_actions
from spyder.widgets.browser import WebView

# Local imports
from spyder_terminal.widgets.style.themes import ANSI_COLORS
from spyder_terminal.config import CONF_SECTION

if WEBENGINE:
    from qtpy.QtWebChannel import QWebChannel

PREFIX = 'spyder_terminal.default.'

# For translations
_ = get_translation('spyder_terminal')


class ChannelHandler(QObject):
    """QWebChannel handler for JS calls."""

    sig_ready = Signal()
    sig_closed = Signal()

    def __init__(self, parent):
        """Handler main constructor."""
        QObject.__init__(self, parent)

    @Slot()
    def ready(self):
        """Invoke signal when terminal prompt is ready."""
Ejemplo n.º 20
0
# Standard library imports
import os
import sys

# Third party imports
from qtpy.QtCore import Signal
from qtpy.QtWidgets import (QLabel, QListWidget, QStackedWidget, QGroupBox,
                            QListWidgetItem, QGridLayout, QLineEdit,
                            QPushButton, QSplitter, QVBoxLayout, QWidget)
from spyder.config.base import get_translation
from xml.dom import minidom

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


class RateLawWidget(QWidget):
    """
    Rate Law widget
    """
    redirect_stdio = Signal(bool)

    def __init__(self, parent, max_entries=100):
        "Initialize Various list objects before assignment"

        displaylist = []
Ejemplo n.º 21
0
                            QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget)

# Local imports
from spyder.config.base import get_conf_path, get_translation, debug_print
from spyder.py3compat import to_text_string
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import (create_toolbutton, get_item_user_text,
                                    set_item_user_text)
from spyder.utils.programs import shell_split
from spyder.widgets.comboboxes import PythonModulesComboBox
from spyder.utils.misc import add_pathlist_to_PYTHONPATH, getcwd_or_home
from spyder.widgets.variableexplorer.texteditor import TextEditor

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

locale_codec = QTextCodec.codecForLocale()


def is_profiler_installed():
    from spyder.utils.programs import is_module_installed
    return is_module_installed('cProfile') and is_module_installed('pstats')


class ProfilerWidget(QWidget):
    """
    Profiler widget
Ejemplo n.º 22
0
from qtpy.QtGui import QTextCursor

from spyder.config.base import get_translation
from spyder.config.gui import fixed_shortcut
from spyder.plugins import SpyderPluginMixin
from spyder.plugins.configdialog import PluginConfigPage
from spyder.utils.qthelpers import get_icon, create_action
from spyder.utils import icon_manager as ima

try:
    from spyder.py3compat import to_text_string
except ImportError:
    # Python 2
    to_text_string = unicode

_ = get_translation("autopep8", dirname="spyder_autopep8")


class AutoPEP8ConfigPage(PluginConfigPage):
    """
    Widget with configuration options for line profiler.
    """
    GROUPS = {
        "1": "Indentation",
        "2": "Whitespace",
        "3": "Blank line",
        "4": "Import",
        "5": "Line length",
        "6": "Deprecation",
        "7": "Statement",
        "9": "Runtime"