class Dependency(object):
    """Spyder's dependency

    version may starts with =, >=, > or < to specify the exact requirement ;
    multiple conditions may be separated by ';' (e.g. '>=0.13;<1.0')"""

    ok = 'ok'
    NOK = 'NOK'
    
    def __init__(self,modname, package_name, features, required_version,
                 installed_version = None, kind = MANDATORY):
        self.modname = modname
        self.package_name = package_name
        self.features = features
        self.required_version = required_version
        self.kind = kind
        
        if installed_version is None:
            try:
                self.installed_version = programs.get_module_version(modname)
            except Exception:
                # NOTE: Don't add any exception type here!
                # Modules can fail to import in several ways besides
                # ImportError
                self.installed_version = None
        else:
            self.installed_version = installed_version
            
        def check(self):
            """Check if dependency is installed"""
            if self.required_version and self.installed_version:
                return program.is_module_installed(self.modname,
                                                   self.required_version,
                                                   self.installed_version)
            else:
Пример #2
0
    def __init__(self, modname, package_name, features, required_version,
                 installed_version=None, kind=MANDATORY):
        self.modname = modname
        self.package_name = package_name
        self.features = features
        self.required_version = required_version
        self.kind = kind

        # Although this is not necessarily the case, it's customary that a
        # package's distribution name be it's name on PyPI with hyphens
        # replaced by underscores.
        # Example:
        # * Package name: python-lsp-black.
        # * Distribution name: python_lsp_black
        self.distribution_name = self.package_name.replace('-', '_')

        if installed_version is None:
            try:
                self.installed_version = programs.get_module_version(modname)
                if not self.installed_version:
                    # Use get_package_version and the distribution name
                    # because there are cases for which the version can't
                    # be obtained from the module (e.g. pylsp_black).
                    self.installed_version = programs.get_package_version(
                        self.distribution_name)
            except Exception:
                # NOTE: Don't add any exception type here!
                # Modules can fail to import in several ways besides
                # ImportError
                self.installed_version = None
        else:
            self.installed_version = installed_version
Пример #3
0
    def setup_page(self):
	
        pybutton = QPushButton('Click me', self)
        # pybutton.resize(100, 32)
        # pybutton.move(50, 50)
        pybutton.clicked.connect(self.clickMethod)
	
        # Connections group
        connections_group = QGroupBox(_("Automatic connections"))
        connections_label = QLabel(_("This pane can automatically "
                                     "show an object's help information after "
                                     "a left parenthesis is written next to it. "
                                     "Below you can decide to which plugin "
                                     "you want to connect it to turn on this "
                                     "feature."))
        connections_label.setWordWrap(True)
        editor_box = self.create_checkbox(_("Editor"), 'connect/editor')

        ipython_box = self.create_checkbox(_("IPython Console"),
                                           'connect/ipython_console')

        connections_layout = QVBoxLayout()
        connections_layout.addWidget(connections_label)
        connections_layout.addWidget(editor_box)
        connections_layout.addWidget(ipython_box)
        connections_group.setLayout(connections_layout)

        # Features group
        features_group = QGroupBox(_("Additional features"))
        math_box = self.create_checkbox(_("Render mathematical equations"),
                                        'math')
        req_sphinx = programs.is_module_installed('sphinx', '>=1.1')
        math_box.setEnabled(req_sphinx)
        if not req_sphinx:
            sphinx_ver = programs.get_module_version('sphinx')
            sphinx_tip = _("This feature requires Sphinx 1.1 or superior.")
            sphinx_tip += "\n" + _("Sphinx %s is currently installed.") % sphinx_ver
            math_box.setToolTip(sphinx_tip)

        features_layout = QVBoxLayout()
        features_layout.addWidget(math_box)
        features_group.setLayout(features_layout)

        # Source code group
        sourcecode_group = QGroupBox(_("Source code"))
        wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap')

        sourcecode_layout = QVBoxLayout()
        sourcecode_layout.addWidget(wrap_mode_box)
        sourcecode_group.setLayout(sourcecode_layout)

        # Final layout
        vlayout = QVBoxLayout()
        vlayout.addWidget(connections_group)
        vlayout.addWidget(features_group)
        vlayout.addWidget(sourcecode_group)
        vlayout.addWidget(pybutton)
        vlayout.addStretch(1)
        self.setLayout(vlayout)
Пример #4
0
    def setup_page(self):
        # Connections group
        connections_group = QGroupBox(_("Automatic connections"))
        connections_label = QLabel(_("This pane can automatically "
                                     "show an object's help information after "
                                     "a left parenthesis is written next to it. "
                                     "Below you can decide to which plugin "
                                     "you want to connect it to turn on this "
                                     "feature."))
        connections_label.setWordWrap(True)
        editor_box = self.create_checkbox(_("Editor"), 'connect/editor')
        rope_installed = programs.is_module_installed('rope')
        jedi_installed = programs.is_module_installed('jedi', '>=0.8.1')
        editor_box.setEnabled(rope_installed or jedi_installed)
        if not rope_installed and not jedi_installed:
            editor_tip = _("This feature requires the Rope or Jedi libraries.\n"
                           "It seems you don't have either installed.")
            editor_box.setToolTip(editor_tip)
        ipython_box = self.create_checkbox(_("IPython Console"),
                                           'connect/ipython_console')

        connections_layout = QVBoxLayout()
        connections_layout.addWidget(connections_label)
        connections_layout.addWidget(editor_box)
        connections_layout.addWidget(ipython_box)
        connections_group.setLayout(connections_layout)

        # Features group
        features_group = QGroupBox(_("Additional features"))
        math_box = self.create_checkbox(_("Render mathematical equations"),
                                        'math')
        req_sphinx = programs.is_module_installed('sphinx', '>=1.1')
        math_box.setEnabled(req_sphinx)
        if not req_sphinx:
            sphinx_ver = programs.get_module_version('sphinx')
            sphinx_tip = _("This feature requires Sphinx 1.1 or superior.")
            sphinx_tip += "\n" + _("Sphinx %s is currently installed.") % sphinx_ver
            math_box.setToolTip(sphinx_tip)

        features_layout = QVBoxLayout()
        features_layout.addWidget(math_box)
        features_group.setLayout(features_layout)

        # Source code group
        sourcecode_group = QGroupBox(_("Source code"))
        wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap')

        sourcecode_layout = QVBoxLayout()
        sourcecode_layout.addWidget(wrap_mode_box)
        sourcecode_group.setLayout(sourcecode_layout)

        # Final layout
        vlayout = QVBoxLayout()
        vlayout.addWidget(connections_group)
        vlayout.addWidget(features_group)
        vlayout.addWidget(sourcecode_group)
        vlayout.addStretch(1)
        self.setLayout(vlayout)
Пример #5
0
    def setup_page(self):
        # Connections group
        connections_group = QGroupBox(_("Automatic connections"))
        connections_label = QLabel(_("This pane can automatically "
                                     "show an object's help information after "
                                     "a left parenthesis is written next to it. "
                                     "Below you can decide to which plugin "
                                     "you want to connect it to turn on this "
                                     "feature."))
        connections_label.setWordWrap(True)
        editor_box = self.create_checkbox(_("Editor"), 'connect/editor')
        rope_installed = programs.is_module_installed('rope')
        jedi_installed = programs.is_module_installed('jedi', '>=0.8.1')
        editor_box.setEnabled(rope_installed or jedi_installed)
        if not rope_installed and not jedi_installed:
            editor_tip = _("This feature requires the Rope or Jedi libraries.\n"
                           "It seems you don't have either installed.")
            editor_box.setToolTip(editor_tip)
        ipython_box = self.create_checkbox(_("IPython Console"),
                                           'connect/ipython_console')

        connections_layout = QVBoxLayout()
        connections_layout.addWidget(connections_label)
        connections_layout.addWidget(editor_box)
        connections_layout.addWidget(ipython_box)
        connections_group.setLayout(connections_layout)

        # Features group
        features_group = QGroupBox(_("Additional features"))
        math_box = self.create_checkbox(_("Render mathematical equations"),
                                        'math')
        req_sphinx = programs.is_module_installed('sphinx', '>=1.1')
        math_box.setEnabled(req_sphinx)
        if not req_sphinx:
            sphinx_ver = programs.get_module_version('sphinx')
            sphinx_tip = _("This feature requires Sphinx 1.1 or superior.")
            sphinx_tip += "\n" + _("Sphinx %s is currently installed.") % sphinx_ver
            math_box.setToolTip(sphinx_tip)

        features_layout = QVBoxLayout()
        features_layout.addWidget(math_box)
        features_group.setLayout(features_layout)

        # Source code group
        sourcecode_group = QGroupBox(_("Source code"))
        wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap')

        sourcecode_layout = QVBoxLayout()
        sourcecode_layout.addWidget(wrap_mode_box)
        sourcecode_group.setLayout(sourcecode_layout)

        # Final layout
        vlayout = QVBoxLayout()
        vlayout.addWidget(connections_group)
        vlayout.addWidget(features_group)
        vlayout.addWidget(sourcecode_group)
        vlayout.addStretch(1)
        self.setLayout(vlayout)
Пример #6
0
 def _on_sphinx_thread_error_msg(self, error_msg):
     """ Display error message on Sphinx rich text failure"""
     self._sphinx_thread.wait()
     self.plain_text_action.setChecked(True)
     sphinx_ver = programs.get_module_version('sphinx')
     QMessageBox.critical(
         self, _('Help'),
         _("The following error occured when calling "
           "<b>Sphinx %s</b>. <br>Incompatible Sphinx "
           "version or doc string decoding failed."
           "<br><br>Error message:<br>%s") % (sphinx_ver, error_msg))
Пример #7
0
 def _on_sphinx_thread_error_msg(self, error_msg):
     """ Display error message on Sphinx rich text failure"""
     self._sphinx_thread.wait()
     self.plain_text_action.setChecked(True)
     sphinx_ver = programs.get_module_version('sphinx')
     QMessageBox.critical(self,
                 _('Help'),
                 _("The following error occured when calling "
                   "<b>Sphinx %s</b>. <br>Incompatible Sphinx "
                   "version or doc string decoding failed."
                   "<br><br>Error message:<br>%s"
                   ) % (sphinx_ver, error_msg))
Пример #8
0
 def __init__(self, modname, features, required_version,
              installed_version=None, optional=False):
     self.modname = modname
     self.features = features
     self.required_version = required_version
     self.optional = optional
     if installed_version is None:
         try:
             self.installed_version = programs.get_module_version(modname)
         except:
             # NOTE: Don't add any exception type here!
             # Modules can fail to import in several ways besides
             # ImportError
             self.installed_version = None
     else:
         self.installed_version = installed_version
Пример #9
0
 def __init__(self, modname, package_name, features, required_version,
              installed_version=None, optional=False):
     self.modname = modname
     self.package_name = package_name
     self.features = features
     self.required_version = required_version
     self.optional = optional
     if installed_version is None:
         try:
             self.installed_version = programs.get_module_version(modname)
         except:
             # NOTE: Don't add any exception type here!
             # Modules can fail to import in several ways besides
             # ImportError
             self.installed_version = None
     else:
         self.installed_version = installed_version
Пример #10
0
def test_get_module_version():
    # intervaltree should not have a __version__ attribute, so test that the
    # fallback mechanism to get_package_version is working
    assert get_module_version('intervaltree')
Пример #11
0
def test_get_module_version():
    # pyls_black should not have a __version__ attribute, so tests that the
    # fallback mechanism to get_package_version is working
    assert get_module_version('python_lsp_black')