Skip to content
Permalink
Browse files

[pyqgis-console] revert changes for handy commands

  • Loading branch information
slarosa authored and nyalldawson committed Oct 4, 2020
1 parent f724793 commit 2cf6d11997cdabd22451a800f4b848f608eb038c
Showing with 10 additions and 16 deletions.
  1. +0 −13 python/console/console_base.py
  2. +10 −3 python/console/console_sci.py
@@ -25,15 +25,12 @@
from qgis.core import QgsApplication, Qgis
from qgis.gui import QgsCodeEditorPython, QgsCodeEditor
import os
import re


class QgsPythonConsoleBase(QgsCodeEditorPython):

MARKER_NUM = 6

HANDY_COMMANDS = ['_pyqgis', '_api', '_cookbook']

def __init__(self, parent=None):
super().__init__(parent)

@@ -140,16 +137,6 @@ def searchPyQGIS(self):
version = '.'.join(Qgis.QGIS_VERSION.split('.')[0:2])
QDesktopServices.openUrl(QUrl('https://qgis.org/pyqgis/' + version + '/search.html?q=' + text))

def handyCommands(self, hcmd):
version = 'master' if 'master' in Qgis.QGIS_VERSION.lower() else re.findall(r'^\d.[0-9]*', Qgis.QGIS_VERSION)[0]
if hcmd == '_pyqgis':
QDesktopServices.openUrl(QUrl("https://qgis.org/pyqgis/{}".format(version)))
elif hcmd == '_api':
QDesktopServices.openUrl(QUrl("https://qgis.org/api/{}".format('' if version == 'master' else version)))
elif hcmd == '_cookbook':
QDesktopServices.openUrl(QUrl("https://docs.qgis.org/{}/en/docs/pyqgis_developer_cookbook/".format(
'testing' if version == 'master' else version)))


if __name__ == "__main__":
pass
@@ -531,10 +531,17 @@ def entered(self):

def runCommand(self, cmd):
self.writeCMD(cmd)
import webbrowser
self.updateHistory(cmd)
if cmd in self.HANDY_COMMANDS:
self.handyCommands(cmd)
more = False
version = 'master' if 'master' in Qgis.QGIS_VERSION.lower() else re.findall(r'^\d.[0-9]*', Qgis.QGIS_VERSION)[0]
if cmd in ('_pyqgis', '_api', '_cookbook'):
if cmd == '_pyqgis':
webbrowser.open("https://qgis.org/pyqgis/{}".format(version))
elif cmd == '_api':
webbrowser.open("https://qgis.org/api/{}".format('' if version == 'master' else version))
elif cmd == '_cookbook':
webbrowser.open("https://docs.qgis.org/{}/en/docs/pyqgis_developer_cookbook/".format(
'testing' if version == 'master' else version))
else:
self.buffer.append(cmd)
src = "\n".join(self.buffer)

0 comments on commit 2cf6d11

Please sign in to comment.
You can’t perform that action at this time.