Sun, 11 Oct 2020 17:54:52 +0200
Changed code to not use deprecated 'QRegExp' anymore.
--- a/docs/changelog Sat Oct 10 16:03:53 2020 +0200 +++ b/docs/changelog Sun Oct 11 17:54:52 2020 +0200 @@ -13,6 +13,8 @@ - Web Browser -- added a SSL information page to the site info dialog -- added a clickable SSL info label to the URL entry +- Various + -- changed code to not use deprecated 'QRegExp' anymore Version 20.10: - bug fixes
--- a/eric6.e4p Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6.e4p Sun Oct 11 17:54:52 2020 +0200 @@ -398,7 +398,6 @@ <Source>eric6/Plugins/PluginWizardQFontDialog.py</Source> <Source>eric6/Plugins/PluginWizardQInputDialog.py</Source> <Source>eric6/Plugins/PluginWizardQMessageBox.py</Source> - <Source>eric6/Plugins/PluginWizardQRegExp.py</Source> <Source>eric6/Plugins/PluginWizardQRegularExpression.py</Source> <Source>eric6/Plugins/PluginWizardSetup.py</Source> <Source>eric6/Plugins/UiExtensionPlugins/Translator/ConfigurationPage/TranslatorPage.py</Source> @@ -679,10 +678,6 @@ <Source>eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py</Source> <Source>eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardRepeatDialog.py</Source> <Source>eric6/Plugins/WizardPlugins/PyRegExpWizard/__init__.py</Source> - <Source>eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.py</Source> - <Source>eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardDialog.py</Source> - <Source>eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardRepeatDialog.py</Source> - <Source>eric6/Plugins/WizardPlugins/QRegExpWizard/__init__.py</Source> <Source>eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.py</Source> <Source>eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py</Source> <Source>eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardRepeatDialog.py</Source> @@ -1855,9 +1850,6 @@ <Form>eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardCharactersDialog.ui</Form> <Form>eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.ui</Form> <Form>eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardRepeatDialog.ui</Form> - <Form>eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.ui</Form> - <Form>eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardDialog.ui</Form> - <Form>eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardRepeatDialog.ui</Form> <Form>eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.ui</Form> <Form>eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.ui</Form> <Form>eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardRepeatDialog.ui</Form>
--- a/eric6/Cooperation/CooperationClient.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Cooperation/CooperationClient.py Sun Oct 11 17:54:52 2020 +0200 @@ -10,7 +10,7 @@ import collections -from PyQt5.QtCore import QObject, pyqtSignal, QProcess, QRegExp +from PyQt5.QtCore import QObject, pyqtSignal, QProcess from PyQt5.QtNetwork import ( QHostInfo, QHostAddress, QAbstractSocket, QNetworkInterface ) @@ -68,13 +68,13 @@ self.__initialConnection = None - envVariables = ["USERNAME.*", "USER.*", "USERDOMAIN.*", - "HOSTNAME.*", "DOMAINNAME.*"] + envVariables = ["USERNAME", "USERDOMAIN", "USER", + "HOSTNAME", "DOMAINNAME"] environment = QProcess.systemEnvironment() found = False for envVariable in envVariables: for env in environment: - if QRegExp(envVariable).exactMatch(env): + if env.startswith(envVariable): envList = env.split("=") if len(envList) == 2: self.__username = envList[1].strip()
--- a/eric6/DebugClients/Python/DebugClientBase.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/DebugClients/Python/DebugClientBase.py Sun Oct 11 17:54:52 2020 +0200 @@ -1648,7 +1648,7 @@ ("internalId", "int", "{0}".format(value.internalId()))) varlist.append(("internalPointer", "void *", "{0}".format(value.internalPointer()))) - elif qttype == 'QRegExp': + elif qttype in ('QRegExp', "QRegularExpression"): varlist.append(("pattern", "str", "{0}".format(value.pattern()))) # GUI stuff
--- a/eric6/DebugClients/Python/DebugConfig.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/DebugClients/Python/DebugConfig.py Sun Oct 11 17:54:52 2020 +0200 @@ -29,7 +29,7 @@ '.QChar', '.QByteArray', '.QString', '.QStringList', '.QPoint', '.QPointF', '.QRect', '.QRectF', '.QSize', '.QSizeF', '.QColor', '.QDate', '.QTime', '.QDateTime', '.QDir', '.QFile', '.QFont', '.QUrl', '.QModelIndex', - '.QRegExp', '.QAction', '.QKeySequence', '.QDomAttr', '.QDomCharacterData', - '.QDomComment', '.QDomDocument', '.QDomElement', '.QDomText', - '.QHostAddress', '.EnumType' + '.QRegExp', '.QRegularExpression', '.QAction', '.QKeySequence', + '.QDomAttr', '.QDomCharacterData', '.QDomComment', '.QDomDocument', + '.QDomElement', '.QDomText', '.QHostAddress', '.EnumType' )
--- a/eric6/Debugger/CallTraceViewer.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Debugger/CallTraceViewer.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,9 @@ Module implementing the Call Trace viewer widget. """ +import re -from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QRegExp, QFileInfo +from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QFileInfo from PyQt5.QtWidgets import QWidget, QTreeWidgetItem from E5Gui.E5Application import e5App @@ -58,7 +59,7 @@ self.__callStack = [] self.__entryFormat = "{0}:{1} ({2})" - self.__entryRe = QRegExp(r"""(.+):(\d+)\s\((.*)\)""") + self.__entryRe = re.compile(r"""(.+):(\d+)\s\((.*)\)""") self.__projectMode = False self.__project = None @@ -197,8 +198,9 @@ """ if item is not None and column > 0: columnStr = item.text(column) - if self.__entryRe.exactMatch(columnStr.strip()): - filename, lineno, func = self.__entryRe.capturedTexts()[1:] + match = self.__entryRe.fullmatch(columnStr.strip()) + if match: + filename, lineno, func = match.groups() try: lineno = int(lineno) except ValueError:
--- a/eric6/Debugger/VariablesViewer.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Debugger/VariablesViewer.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,11 +7,13 @@ Module implementing the variables viewer view based on QTreeView. """ +import ast +import re -import ast - -from PyQt5.QtCore import (Qt, QAbstractItemModel, QModelIndex, QRegExp, - QCoreApplication, QSortFilterProxyModel, pyqtSignal) +from PyQt5.QtCore import ( + Qt, QAbstractItemModel, QModelIndex, QCoreApplication, + QSortFilterProxyModel, pyqtSignal +) from PyQt5.QtGui import QBrush, QFontMetrics from PyQt5.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu @@ -41,7 +43,7 @@ } # Initialize regular expression for unprintable strings - rx_nonprintable = QRegExp(r"""(\\x\d\d)+""") + rx_nonprintable = re.compile(r"""(\\x\d\d)+""") noOfItemsStr = QCoreApplication.translate("VariablesViewer", "{0} items") unsized = QCoreApplication.translate("VariablesViewer", "unsized") @@ -194,7 +196,7 @@ self.hasChildren = True elif dtype in ['str', 'unicode']: - if VariableItem.rx_nonprintable.indexIn(dvalue) == -1: + if VariableItem.rx_nonprintable.search(dvalue) is None: try: dvalue = ast.literal_eval(dvalue) except Exception: # secok
--- a/eric6/Documentation/Source/eric6.Plugins.PluginWizardQRegExp.html Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric6.Plugins.PluginWizardQRegExp</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body> -<a NAME="top" ID="top"></a> -<h1>eric6.Plugins.PluginWizardQRegExp</h1> - -<p> -Module implementing the QRegExp wizard plugin. -</p> -<h3>Global Attributes</h3> - -<table> -<tr><td>author</td></tr><tr><td>autoactivate</td></tr><tr><td>className</td></tr><tr><td>deactivateable</td></tr><tr><td>error</td></tr><tr><td>longDescription</td></tr><tr><td>name</td></tr><tr><td>packageName</td></tr><tr><td>pyqtApi</td></tr><tr><td>shortDescription</td></tr><tr><td>version</td></tr> -</table> -<h3>Classes</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizard">QRegExpWizard</a></td> -<td>Class implementing the QRegExp wizard plugin.</td> -</tr> -</table> -<h3>Functions</h3> - -<table> -<tr><td>None</td></tr> -</table> -<hr /> -<hr /> -<a NAME="QRegExpWizard" ID="QRegExpWizard"></a> -<h2>QRegExpWizard</h2> - -<p> - Class implementing the QRegExp wizard plugin. -</p> -<h3>Derived from</h3> -QObject -<h3>Class Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Class Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizard.__init__">QRegExpWizard</a></td> -<td>Constructor</td> -</tr> -<tr> -<td><a href="#QRegExpWizard.__callForm">__callForm</a></td> -<td>Private method to display a dialog and get the code.</td> -</tr> -<tr> -<td><a href="#QRegExpWizard.__handle">__handle</a></td> -<td>Private method to handle the wizards action.</td> -</tr> -<tr> -<td><a href="#QRegExpWizard.__initAction">__initAction</a></td> -<td>Private method to initialize the action.</td> -</tr> -<tr> -<td><a href="#QRegExpWizard.__initMenu">__initMenu</a></td> -<td>Private method to add the actions to the right menu.</td> -</tr> -<tr> -<td><a href="#QRegExpWizard.activate">activate</a></td> -<td>Public method to activate this plugin.</td> -</tr> -<tr> -<td><a href="#QRegExpWizard.deactivate">deactivate</a></td> -<td>Public method to deactivate this plugin.</td> -</tr> -</table> -<h3>Static Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> - -<a NAME="QRegExpWizard.__init__" ID="QRegExpWizard.__init__"></a> -<h4>QRegExpWizard (Constructor)</h4> -<b>QRegExpWizard</b>(<i>ui</i>) - -<p> - Constructor -</p> -<dl> - -<dt><i>ui</i></dt> -<dd> -reference to the user interface object (UI.UserInterface) -</dd> -</dl> -<a NAME="QRegExpWizard.__callForm" ID="QRegExpWizard.__callForm"></a> -<h4>QRegExpWizard.__callForm</h4> -<b>__callForm</b>(<i>editor</i>) - -<p> - Private method to display a dialog and get the code. -</p> -<dl> - -<dt><i>editor</i></dt> -<dd> -reference to the current editor -</dd> -</dl> -<dl> -<dt>Returns:</dt> -<dd> -the generated code (string) -</dd> -</dl> -<a NAME="QRegExpWizard.__handle" ID="QRegExpWizard.__handle"></a> -<h4>QRegExpWizard.__handle</h4> -<b>__handle</b>(<i></i>) - -<p> - Private method to handle the wizards action. -</p> -<a NAME="QRegExpWizard.__initAction" ID="QRegExpWizard.__initAction"></a> -<h4>QRegExpWizard.__initAction</h4> -<b>__initAction</b>(<i></i>) - -<p> - Private method to initialize the action. -</p> -<a NAME="QRegExpWizard.__initMenu" ID="QRegExpWizard.__initMenu"></a> -<h4>QRegExpWizard.__initMenu</h4> -<b>__initMenu</b>(<i></i>) - -<p> - Private method to add the actions to the right menu. -</p> -<a NAME="QRegExpWizard.activate" ID="QRegExpWizard.activate"></a> -<h4>QRegExpWizard.activate</h4> -<b>activate</b>(<i></i>) - -<p> - Public method to activate this plugin. -</p> -<dl> -<dt>Returns:</dt> -<dd> -tuple of None and activation status (boolean) -</dd> -</dl> -<a NAME="QRegExpWizard.deactivate" ID="QRegExpWizard.deactivate"></a> -<h4>QRegExpWizard.deactivate</h4> -<b>deactivate</b>(<i></i>) - -<p> - Public method to deactivate this plugin. -</p> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- a/eric6/Documentation/Source/eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardCharactersDialog.html Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,299 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardCharactersDialog</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body> -<a NAME="top" ID="top"></a> -<h1>eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardCharactersDialog</h1> - -<p> -Module implementing a dialog for entering character classes. -</p> -<h3>Global Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardCharactersDialog">QRegExpWizardCharactersDialog</a></td> -<td>Class implementing a dialog for entering character classes.</td> -</tr> -</table> -<h3>Functions</h3> - -<table> -<tr><td>None</td></tr> -</table> -<hr /> -<hr /> -<a NAME="QRegExpWizardCharactersDialog" ID="QRegExpWizardCharactersDialog"></a> -<h2>QRegExpWizardCharactersDialog</h2> - -<p> - Class implementing a dialog for entering character classes. -</p> -<h3>Derived from</h3> -QDialog, Ui_QRegExpWizardCharactersDialog -<h3>Class Attributes</h3> - -<table> -<tr><td>RegExpMode</td></tr><tr><td>W3CMode</td></tr><tr><td>WildcardMode</td></tr> -</table> -<h3>Class Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__init__">QRegExpWizardCharactersDialog</a></td> -<td>Constructor</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__addRangesLine">__addRangesLine</a></td> -<td>Private slot to add a line of entry widgets for character ranges.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__addSinglesLine">__addSinglesLine</a></td> -<td>Private slot to add a line of entry widgets for single characters.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__formatCharacter">__formatCharacter</a></td> -<td>Private method to format the characters entered into the dialog.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__initCharacterSelectors">__initCharacterSelectors</a></td> -<td>Private method to initialize the W3C character selector entries.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__performSelectedAction">__performSelectedAction</a></td> -<td>Private method performing some actions depending on the input.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__populateCharTypeCombo">__populateCharTypeCombo</a></td> -<td>Private method to populate a given character type selection combo box.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__populateW3cCharacterCombo">__populateW3cCharacterCombo</a></td> -<td>Private method to populate a W3C character selection combo.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__rangesCharTypeSelected">__rangesCharTypeSelected</a></td> -<td>Private slot to handle the activated(int) signal of the char ranges combo boxes.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.__singlesCharTypeSelected">__singlesCharTypeSelected</a></td> -<td>Private slot to handle the activated(int) signal of the single chars combo boxes.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardCharactersDialog.getCharacters">getCharacters</a></td> -<td>Public method to return the character string assembled via the dialog.</td> -</tr> -</table> -<h3>Static Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> - -<a NAME="QRegExpWizardCharactersDialog.__init__" ID="QRegExpWizardCharactersDialog.__init__"></a> -<h4>QRegExpWizardCharactersDialog (Constructor)</h4> -<b>QRegExpWizardCharactersDialog</b>(<i>mode=RegExpMode, parent=None</i>) - -<p> - Constructor -</p> -<dl> - -<dt><i>mode</i></dt> -<dd> -mode of the dialog (one of RegExpMode, WildcardMode, - W3CMode) -</dd> -<dt><i>parent</i></dt> -<dd> -parent widget (QWidget) -</dd> -</dl> -<a NAME="QRegExpWizardCharactersDialog.__addRangesLine" ID="QRegExpWizardCharactersDialog.__addRangesLine"></a> -<h4>QRegExpWizardCharactersDialog.__addRangesLine</h4> -<b>__addRangesLine</b>(<i></i>) - -<p> - Private slot to add a line of entry widgets for character ranges. -</p> -<a NAME="QRegExpWizardCharactersDialog.__addSinglesLine" ID="QRegExpWizardCharactersDialog.__addSinglesLine"></a> -<h4>QRegExpWizardCharactersDialog.__addSinglesLine</h4> -<b>__addSinglesLine</b>(<i></i>) - -<p> - Private slot to add a line of entry widgets for single characters. -</p> -<a NAME="QRegExpWizardCharactersDialog.__formatCharacter" ID="QRegExpWizardCharactersDialog.__formatCharacter"></a> -<h4>QRegExpWizardCharactersDialog.__formatCharacter</h4> -<b>__formatCharacter</b>(<i>char, formatIdentifier</i>) - -<p> - Private method to format the characters entered into the dialog. -</p> -<dl> - -<dt><i>char</i></dt> -<dd> -character string entered into the dialog (string) -</dd> -<dt><i>formatIdentifier</i></dt> -<dd> -string giving a special format (-c, -h, -i or - -o) or the already formatted character (string) -</dd> -</dl> -<dl> -<dt>Returns:</dt> -<dd> -formatted character string (string) -</dd> -</dl> -<a NAME="QRegExpWizardCharactersDialog.__initCharacterSelectors" ID="QRegExpWizardCharactersDialog.__initCharacterSelectors"></a> -<h4>QRegExpWizardCharactersDialog.__initCharacterSelectors</h4> -<b>__initCharacterSelectors</b>(<i></i>) - -<p> - Private method to initialize the W3C character selector entries. -</p> -<a NAME="QRegExpWizardCharactersDialog.__performSelectedAction" ID="QRegExpWizardCharactersDialog.__performSelectedAction"></a> -<h4>QRegExpWizardCharactersDialog.__performSelectedAction</h4> -<b>__performSelectedAction</b>(<i>formatIdentifier, lineedit, combo</i>) - -<p> - Private method performing some actions depending on the input. -</p> -<dl> - -<dt><i>formatIdentifier</i></dt> -<dd> -format of the selected entry (string) -</dd> -<dt><i>lineedit</i></dt> -<dd> -line edit widget to act on (QLineEdit) -</dd> -<dt><i>combo</i></dt> -<dd> -combo box widget to act on (QComboBox) -</dd> -</dl> -<a NAME="QRegExpWizardCharactersDialog.__populateCharTypeCombo" ID="QRegExpWizardCharactersDialog.__populateCharTypeCombo"></a> -<h4>QRegExpWizardCharactersDialog.__populateCharTypeCombo</h4> -<b>__populateCharTypeCombo</b>(<i>combo, isSingle</i>) - -<p> - Private method to populate a given character type selection combo box. -</p> -<dl> - -<dt><i>combo</i></dt> -<dd> -reference to the combo box to be populated (QComboBox) -</dd> -<dt><i>isSingle</i></dt> -<dd> -flag indicating a singles combo (boolean) -</dd> -</dl> -<a NAME="QRegExpWizardCharactersDialog.__populateW3cCharacterCombo" ID="QRegExpWizardCharactersDialog.__populateW3cCharacterCombo"></a> -<h4>QRegExpWizardCharactersDialog.__populateW3cCharacterCombo</h4> -<b>__populateW3cCharacterCombo</b>(<i>combo, formatIdentifier</i>) - -<p> - Private method to populate a W3C character selection combo. -</p> -<dl> - -<dt><i>combo</i></dt> -<dd> -combo box to be populated (QComboBox) -</dd> -<dt><i>formatIdentifier</i></dt> -<dd> -format identifier (one of "-ccp", "-ccn", - "-cbp", "-cbn") -</dd> -</dl> -<a NAME="QRegExpWizardCharactersDialog.__rangesCharTypeSelected" ID="QRegExpWizardCharactersDialog.__rangesCharTypeSelected"></a> -<h4>QRegExpWizardCharactersDialog.__rangesCharTypeSelected</h4> -<b>__rangesCharTypeSelected</b>(<i>index, combo</i>) - -<p> - Private slot to handle the activated(int) signal of the char ranges - combo boxes. -</p> -<dl> - -<dt><i>index</i> (int)</dt> -<dd> -selected list index -</dd> -<dt><i>combo</i> (QComboBox)</dt> -<dd> -reference to the combo box -</dd> -</dl> -<a NAME="QRegExpWizardCharactersDialog.__singlesCharTypeSelected" ID="QRegExpWizardCharactersDialog.__singlesCharTypeSelected"></a> -<h4>QRegExpWizardCharactersDialog.__singlesCharTypeSelected</h4> -<b>__singlesCharTypeSelected</b>(<i>index, combo</i>) - -<p> - Private slot to handle the activated(int) signal of the single chars - combo boxes. -</p> -<dl> - -<dt><i>index</i> (int)</dt> -<dd> -selected list index -</dd> -<dt><i>combo</i> (QComboBox)</dt> -<dd> -reference to the combo box -</dd> -</dl> -<a NAME="QRegExpWizardCharactersDialog.getCharacters" ID="QRegExpWizardCharactersDialog.getCharacters"></a> -<h4>QRegExpWizardCharactersDialog.getCharacters</h4> -<b>getCharacters</b>(<i></i>) - -<p> - Public method to return the character string assembled via the dialog. -</p> -<dl> -<dt>Returns:</dt> -<dd> -formatted string for character classes (string) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- a/eric6/Documentation/Source/eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardDialog.html Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,673 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardDialog</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body> -<a NAME="top" ID="top"></a> -<h1>eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardDialog</h1> - -<p> -Module implementing the QRegExp wizard dialog. -</p> -<h3>Global Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardDialog">QRegExpWizardDialog</a></td> -<td>Class for the dialog variant.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget">QRegExpWizardWidget</a></td> -<td>Class implementing the QRegExp wizard dialog.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWindow">QRegExpWizardWindow</a></td> -<td>Main window class for the standalone dialog.</td> -</tr> -</table> -<h3>Functions</h3> - -<table> -<tr><td>None</td></tr> -</table> -<hr /> -<hr /> -<a NAME="QRegExpWizardDialog" ID="QRegExpWizardDialog"></a> -<h2>QRegExpWizardDialog</h2> - -<p> - Class for the dialog variant. -</p> -<h3>Derived from</h3> -QDialog -<h3>Class Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Class Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardDialog.__init__">QRegExpWizardDialog</a></td> -<td>Constructor</td> -</tr> -<tr> -<td><a href="#QRegExpWizardDialog.getCode">getCode</a></td> -<td>Public method to get the source code.</td> -</tr> -</table> -<h3>Static Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> - -<a NAME="QRegExpWizardDialog.__init__" ID="QRegExpWizardDialog.__init__"></a> -<h4>QRegExpWizardDialog (Constructor)</h4> -<b>QRegExpWizardDialog</b>(<i>parent=None, fromEric=True</i>) - -<p> - Constructor -</p> -<dl> - -<dt><i>parent</i></dt> -<dd> -parent widget (QWidget) -</dd> -<dt><i>fromEric</i></dt> -<dd> -flag indicating a call from within eric6 -</dd> -</dl> -<a NAME="QRegExpWizardDialog.getCode" ID="QRegExpWizardDialog.getCode"></a> -<h4>QRegExpWizardDialog.getCode</h4> -<b>getCode</b>(<i>indLevel, indString</i>) - -<p> - Public method to get the source code. -</p> -<dl> - -<dt><i>indLevel</i></dt> -<dd> -indentation level (int) -</dd> -<dt><i>indString</i></dt> -<dd> -string used for indentation (space or tab) (string) -</dd> -</dl> -<dl> -<dt>Returns:</dt> -<dd> -generated code (string) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -<hr /> -<a NAME="QRegExpWizardWidget" ID="QRegExpWizardWidget"></a> -<h2>QRegExpWizardWidget</h2> - -<p> - Class implementing the QRegExp wizard dialog. -</p> -<h3>Derived from</h3> -QWidget, Ui_QRegExpWizardWidget -<h3>Class Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Class Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardWidget.__init__">QRegExpWizardWidget</a></td> -<td>Constructor</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.__getPatternSyntaxCode">__getPatternSyntaxCode</a></td> -<td>Private method to convert a pattern syntax value into a pattern syntax string.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.__insertString">__insertString</a></td> -<td>Private method to insert a string into line edit and move cursor.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.getCode">getCode</a></td> -<td>Public method to get the source code.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_altnButton_clicked">on_altnButton_clicked</a></td> -<td>Private slot to handle the alternatives toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_anycharButton_clicked">on_anycharButton_clicked</a></td> -<td>Private slot to handle the any character toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_beglineButton_clicked">on_beglineButton_clicked</a></td> -<td>Private slot to handle the begin line toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_buttonBox_clicked">on_buttonBox_clicked</a></td> -<td>Private slot called by a button of the button box clicked.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_charButton_clicked">on_charButton_clicked</a></td> -<td>Private slot to handle the characters toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_copyButton_clicked">on_copyButton_clicked</a></td> -<td>Private slot to copy the regexp string into the clipboard.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_endlineButton_clicked">on_endlineButton_clicked</a></td> -<td>Private slot to handle the end line toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_executeButton_clicked">on_executeButton_clicked</a></td> -<td>Private slot to execute the entered regexp on the test text.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_groupButton_clicked">on_groupButton_clicked</a></td> -<td>Private slot to handle the group toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_loadButton_clicked">on_loadButton_clicked</a></td> -<td>Private slot to load a regexp from a file.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_neglookaheadButton_clicked">on_neglookaheadButton_clicked</a></td> -<td>Private slot to handle the negative lookahead toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_nextButton_clicked">on_nextButton_clicked</a></td> -<td>Private slot to find the next match.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_nonGroupButton_clicked">on_nonGroupButton_clicked</a></td> -<td>Private slot to handle the non group toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_nonwordboundButton_clicked">on_nonwordboundButton_clicked</a></td> -<td>Private slot to handle the non word boundary toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_poslookaheadButton_clicked">on_poslookaheadButton_clicked</a></td> -<td>Private slot to handle the positive lookahead toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_regexpLineEdit_textChanged">on_regexpLineEdit_textChanged</a></td> -<td>Private slot called when the regexp changes.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_repeatButton_clicked">on_repeatButton_clicked</a></td> -<td>Private slot to handle the repeat toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_saveButton_clicked">on_saveButton_clicked</a></td> -<td>Private slot to save the regexp to a file.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_syntaxCombo_currentIndexChanged">on_syntaxCombo_currentIndexChanged</a></td> -<td>Private slot handling the selection of a pattern syntax.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_validateButton_clicked">on_validateButton_clicked</a></td> -<td>Private slot to validate the entered regexp.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_w3cAltnButton_clicked">on_w3cAltnButton_clicked</a></td> -<td>Private slot to handle the alternatives toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_w3cAnycharButton_clicked">on_w3cAnycharButton_clicked</a></td> -<td>Private slot to handle the W3C any character toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_w3cCharButton_clicked">on_w3cCharButton_clicked</a></td> -<td>Private slot to handle the wildcard characters toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_w3cGroupButton_clicked">on_w3cGroupButton_clicked</a></td> -<td>Private slot to handle the W3C group toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_w3cRepeatButton_clicked">on_w3cRepeatButton_clicked</a></td> -<td>Private slot to handle the W3C repeat toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_wildcardAnycharButton_clicked">on_wildcardAnycharButton_clicked</a></td> -<td>Private slot to handle the wildcard any character toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_wildcardCharButton_clicked">on_wildcardCharButton_clicked</a></td> -<td>Private slot to handle the wildcard characters toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_wildcardRepeatButton_clicked">on_wildcardRepeatButton_clicked</a></td> -<td>Private slot to handle the wildcard multiple characters toolbutton.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardWidget.on_wordboundButton_clicked">on_wordboundButton_clicked</a></td> -<td>Private slot to handle the word boundary toolbutton.</td> -</tr> -</table> -<h3>Static Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> - -<a NAME="QRegExpWizardWidget.__init__" ID="QRegExpWizardWidget.__init__"></a> -<h4>QRegExpWizardWidget (Constructor)</h4> -<b>QRegExpWizardWidget</b>(<i>parent=None, fromEric=True</i>) - -<p> - Constructor -</p> -<dl> - -<dt><i>parent</i></dt> -<dd> -parent widget (QWidget) -</dd> -<dt><i>fromEric</i></dt> -<dd> -flag indicating a call from within eric6 -</dd> -</dl> -<a NAME="QRegExpWizardWidget.__getPatternSyntaxCode" ID="QRegExpWizardWidget.__getPatternSyntaxCode"></a> -<h4>QRegExpWizardWidget.__getPatternSyntaxCode</h4> -<b>__getPatternSyntaxCode</b>(<i>syntaxValue</i>) - -<p> - Private method to convert a pattern syntax value into a - pattern syntax string. -</p> -<dl> - -<dt><i>syntaxValue</i></dt> -<dd> -pattern syntax value (integer) -</dd> -</dl> -<dl> -<dt>Returns:</dt> -<dd> -pattern syntax string (string) -</dd> -</dl> -<a NAME="QRegExpWizardWidget.__insertString" ID="QRegExpWizardWidget.__insertString"></a> -<h4>QRegExpWizardWidget.__insertString</h4> -<b>__insertString</b>(<i>s, steps=0</i>) - -<p> - Private method to insert a string into line edit and move cursor. -</p> -<dl> - -<dt><i>s</i></dt> -<dd> -string to be inserted into the regexp line edit - (string) -</dd> -<dt><i>steps</i></dt> -<dd> -number of characters to move the cursor (integer). - Negative steps moves cursor back, positives forward. -</dd> -</dl> -<a NAME="QRegExpWizardWidget.getCode" ID="QRegExpWizardWidget.getCode"></a> -<h4>QRegExpWizardWidget.getCode</h4> -<b>getCode</b>(<i>indLevel, indString</i>) - -<p> - Public method to get the source code. -</p> -<dl> - -<dt><i>indLevel</i></dt> -<dd> -indentation level (int) -</dd> -<dt><i>indString</i></dt> -<dd> -string used for indentation (space or tab) (string) -</dd> -</dl> -<dl> -<dt>Returns:</dt> -<dd> -generated code (string) -</dd> -</dl> -<a NAME="QRegExpWizardWidget.on_altnButton_clicked" ID="QRegExpWizardWidget.on_altnButton_clicked"></a> -<h4>QRegExpWizardWidget.on_altnButton_clicked</h4> -<b>on_altnButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the alternatives toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_anycharButton_clicked" ID="QRegExpWizardWidget.on_anycharButton_clicked"></a> -<h4>QRegExpWizardWidget.on_anycharButton_clicked</h4> -<b>on_anycharButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the any character toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_beglineButton_clicked" ID="QRegExpWizardWidget.on_beglineButton_clicked"></a> -<h4>QRegExpWizardWidget.on_beglineButton_clicked</h4> -<b>on_beglineButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the begin line toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_buttonBox_clicked" ID="QRegExpWizardWidget.on_buttonBox_clicked"></a> -<h4>QRegExpWizardWidget.on_buttonBox_clicked</h4> -<b>on_buttonBox_clicked</b>(<i>button</i>) - -<p> - Private slot called by a button of the button box clicked. -</p> -<dl> - -<dt><i>button</i></dt> -<dd> -button that was clicked (QAbstractButton) -</dd> -</dl> -<a NAME="QRegExpWizardWidget.on_charButton_clicked" ID="QRegExpWizardWidget.on_charButton_clicked"></a> -<h4>QRegExpWizardWidget.on_charButton_clicked</h4> -<b>on_charButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the characters toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_copyButton_clicked" ID="QRegExpWizardWidget.on_copyButton_clicked"></a> -<h4>QRegExpWizardWidget.on_copyButton_clicked</h4> -<b>on_copyButton_clicked</b>(<i></i>) - -<p> - Private slot to copy the regexp string into the clipboard. -</p> -<p> - This slot is only available, if not called from within eric6. -</p> -<a NAME="QRegExpWizardWidget.on_endlineButton_clicked" ID="QRegExpWizardWidget.on_endlineButton_clicked"></a> -<h4>QRegExpWizardWidget.on_endlineButton_clicked</h4> -<b>on_endlineButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the end line toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_executeButton_clicked" ID="QRegExpWizardWidget.on_executeButton_clicked"></a> -<h4>QRegExpWizardWidget.on_executeButton_clicked</h4> -<b>on_executeButton_clicked</b>(<i>startpos=0</i>) - -<p> - Private slot to execute the entered regexp on the test text. -</p> -<p> - This slot will execute the entered regexp on the entered test - data and will display the result in the table part of the dialog. -</p> -<dl> - -<dt><i>startpos</i></dt> -<dd> -starting position for the regexp matching -</dd> -</dl> -<a NAME="QRegExpWizardWidget.on_groupButton_clicked" ID="QRegExpWizardWidget.on_groupButton_clicked"></a> -<h4>QRegExpWizardWidget.on_groupButton_clicked</h4> -<b>on_groupButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the group toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_loadButton_clicked" ID="QRegExpWizardWidget.on_loadButton_clicked"></a> -<h4>QRegExpWizardWidget.on_loadButton_clicked</h4> -<b>on_loadButton_clicked</b>(<i></i>) - -<p> - Private slot to load a regexp from a file. -</p> -<a NAME="QRegExpWizardWidget.on_neglookaheadButton_clicked" ID="QRegExpWizardWidget.on_neglookaheadButton_clicked"></a> -<h4>QRegExpWizardWidget.on_neglookaheadButton_clicked</h4> -<b>on_neglookaheadButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the negative lookahead toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_nextButton_clicked" ID="QRegExpWizardWidget.on_nextButton_clicked"></a> -<h4>QRegExpWizardWidget.on_nextButton_clicked</h4> -<b>on_nextButton_clicked</b>(<i></i>) - -<p> - Private slot to find the next match. -</p> -<a NAME="QRegExpWizardWidget.on_nonGroupButton_clicked" ID="QRegExpWizardWidget.on_nonGroupButton_clicked"></a> -<h4>QRegExpWizardWidget.on_nonGroupButton_clicked</h4> -<b>on_nonGroupButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the non group toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_nonwordboundButton_clicked" ID="QRegExpWizardWidget.on_nonwordboundButton_clicked"></a> -<h4>QRegExpWizardWidget.on_nonwordboundButton_clicked</h4> -<b>on_nonwordboundButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the non word boundary toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_poslookaheadButton_clicked" ID="QRegExpWizardWidget.on_poslookaheadButton_clicked"></a> -<h4>QRegExpWizardWidget.on_poslookaheadButton_clicked</h4> -<b>on_poslookaheadButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the positive lookahead toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_regexpLineEdit_textChanged" ID="QRegExpWizardWidget.on_regexpLineEdit_textChanged"></a> -<h4>QRegExpWizardWidget.on_regexpLineEdit_textChanged</h4> -<b>on_regexpLineEdit_textChanged</b>(<i>txt</i>) - -<p> - Private slot called when the regexp changes. -</p> -<dl> - -<dt><i>txt</i></dt> -<dd> -the new text of the line edit (string) -</dd> -</dl> -<a NAME="QRegExpWizardWidget.on_repeatButton_clicked" ID="QRegExpWizardWidget.on_repeatButton_clicked"></a> -<h4>QRegExpWizardWidget.on_repeatButton_clicked</h4> -<b>on_repeatButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the repeat toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_saveButton_clicked" ID="QRegExpWizardWidget.on_saveButton_clicked"></a> -<h4>QRegExpWizardWidget.on_saveButton_clicked</h4> -<b>on_saveButton_clicked</b>(<i></i>) - -<p> - Private slot to save the regexp to a file. -</p> -<a NAME="QRegExpWizardWidget.on_syntaxCombo_currentIndexChanged" ID="QRegExpWizardWidget.on_syntaxCombo_currentIndexChanged"></a> -<h4>QRegExpWizardWidget.on_syntaxCombo_currentIndexChanged</h4> -<b>on_syntaxCombo_currentIndexChanged</b>(<i>index</i>) - -<p> - Private slot handling the selection of a pattern syntax. -</p> -<dl> - -<dt><i>index</i></dt> -<dd> -index of the selected entry (integer) -</dd> -</dl> -<a NAME="QRegExpWizardWidget.on_validateButton_clicked" ID="QRegExpWizardWidget.on_validateButton_clicked"></a> -<h4>QRegExpWizardWidget.on_validateButton_clicked</h4> -<b>on_validateButton_clicked</b>(<i></i>) - -<p> - Private slot to validate the entered regexp. -</p> -<a NAME="QRegExpWizardWidget.on_w3cAltnButton_clicked" ID="QRegExpWizardWidget.on_w3cAltnButton_clicked"></a> -<h4>QRegExpWizardWidget.on_w3cAltnButton_clicked</h4> -<b>on_w3cAltnButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the alternatives toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_w3cAnycharButton_clicked" ID="QRegExpWizardWidget.on_w3cAnycharButton_clicked"></a> -<h4>QRegExpWizardWidget.on_w3cAnycharButton_clicked</h4> -<b>on_w3cAnycharButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the W3C any character toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_w3cCharButton_clicked" ID="QRegExpWizardWidget.on_w3cCharButton_clicked"></a> -<h4>QRegExpWizardWidget.on_w3cCharButton_clicked</h4> -<b>on_w3cCharButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the wildcard characters toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_w3cGroupButton_clicked" ID="QRegExpWizardWidget.on_w3cGroupButton_clicked"></a> -<h4>QRegExpWizardWidget.on_w3cGroupButton_clicked</h4> -<b>on_w3cGroupButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the W3C group toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_w3cRepeatButton_clicked" ID="QRegExpWizardWidget.on_w3cRepeatButton_clicked"></a> -<h4>QRegExpWizardWidget.on_w3cRepeatButton_clicked</h4> -<b>on_w3cRepeatButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the W3C repeat toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_wildcardAnycharButton_clicked" ID="QRegExpWizardWidget.on_wildcardAnycharButton_clicked"></a> -<h4>QRegExpWizardWidget.on_wildcardAnycharButton_clicked</h4> -<b>on_wildcardAnycharButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the wildcard any character toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_wildcardCharButton_clicked" ID="QRegExpWizardWidget.on_wildcardCharButton_clicked"></a> -<h4>QRegExpWizardWidget.on_wildcardCharButton_clicked</h4> -<b>on_wildcardCharButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the wildcard characters toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_wildcardRepeatButton_clicked" ID="QRegExpWizardWidget.on_wildcardRepeatButton_clicked"></a> -<h4>QRegExpWizardWidget.on_wildcardRepeatButton_clicked</h4> -<b>on_wildcardRepeatButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the wildcard multiple characters toolbutton. -</p> -<a NAME="QRegExpWizardWidget.on_wordboundButton_clicked" ID="QRegExpWizardWidget.on_wordboundButton_clicked"></a> -<h4>QRegExpWizardWidget.on_wordboundButton_clicked</h4> -<b>on_wordboundButton_clicked</b>(<i></i>) - -<p> - Private slot to handle the word boundary toolbutton. -</p> -<div align="right"><a href="#top">Up</a></div> -<hr /> -<hr /> -<a NAME="QRegExpWizardWindow" ID="QRegExpWizardWindow"></a> -<h2>QRegExpWizardWindow</h2> - -<p> - Main window class for the standalone dialog. -</p> -<h3>Derived from</h3> -E5MainWindow -<h3>Class Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Class Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardWindow.__init__">QRegExpWizardWindow</a></td> -<td>Constructor</td> -</tr> -</table> -<h3>Static Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> - -<a NAME="QRegExpWizardWindow.__init__" ID="QRegExpWizardWindow.__init__"></a> -<h4>QRegExpWizardWindow (Constructor)</h4> -<b>QRegExpWizardWindow</b>(<i>parent=None</i>) - -<p> - Constructor -</p> -<dl> - -<dt><i>parent</i></dt> -<dd> -reference to the parent widget (QWidget) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- a/eric6/Documentation/Source/eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardRepeatDialog.html Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardRepeatDialog</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body> -<a NAME="top" ID="top"></a> -<h1>eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardRepeatDialog</h1> - -<p> -Module implementing a dialog for entering repeat counts. -</p> -<h3>Global Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardRepeatDialog">QRegExpWizardRepeatDialog</a></td> -<td>Class implementing a dialog for entering repeat counts.</td> -</tr> -</table> -<h3>Functions</h3> - -<table> -<tr><td>None</td></tr> -</table> -<hr /> -<hr /> -<a NAME="QRegExpWizardRepeatDialog" ID="QRegExpWizardRepeatDialog"></a> -<h2>QRegExpWizardRepeatDialog</h2> - -<p> - Class implementing a dialog for entering repeat counts. -</p> -<h3>Derived from</h3> -QDialog, Ui_QRegExpWizardRepeatDialog -<h3>Class Attributes</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Class Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> - -<table> - -<tr> -<td><a href="#QRegExpWizardRepeatDialog.__init__">QRegExpWizardRepeatDialog</a></td> -<td>Constructor</td> -</tr> -<tr> -<td><a href="#QRegExpWizardRepeatDialog.getRepeat">getRepeat</a></td> -<td>Public method to retrieve the dialog's result.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardRepeatDialog.on_lowerSpin_valueChanged">on_lowerSpin_valueChanged</a></td> -<td>Private slot to handle the lowerSpin valueChanged signal.</td> -</tr> -<tr> -<td><a href="#QRegExpWizardRepeatDialog.on_upperSpin_valueChanged">on_upperSpin_valueChanged</a></td> -<td>Private slot to handle the upperSpin valueChanged signal.</td> -</tr> -</table> -<h3>Static Methods</h3> - -<table> -<tr><td>None</td></tr> -</table> - -<a NAME="QRegExpWizardRepeatDialog.__init__" ID="QRegExpWizardRepeatDialog.__init__"></a> -<h4>QRegExpWizardRepeatDialog (Constructor)</h4> -<b>QRegExpWizardRepeatDialog</b>(<i>parent=None</i>) - -<p> - Constructor -</p> -<dl> - -<dt><i>parent</i></dt> -<dd> -parent widget (QWidget) -</dd> -</dl> -<a NAME="QRegExpWizardRepeatDialog.getRepeat" ID="QRegExpWizardRepeatDialog.getRepeat"></a> -<h4>QRegExpWizardRepeatDialog.getRepeat</h4> -<b>getRepeat</b>(<i></i>) - -<p> - Public method to retrieve the dialog's result. -</p> -<dl> -<dt>Returns:</dt> -<dd> -ready formatted repeat string (string) -</dd> -</dl> -<a NAME="QRegExpWizardRepeatDialog.on_lowerSpin_valueChanged" ID="QRegExpWizardRepeatDialog.on_lowerSpin_valueChanged"></a> -<h4>QRegExpWizardRepeatDialog.on_lowerSpin_valueChanged</h4> -<b>on_lowerSpin_valueChanged</b>(<i>value</i>) - -<p> - Private slot to handle the lowerSpin valueChanged signal. -</p> -<dl> - -<dt><i>value</i></dt> -<dd> -value of the spinbox (integer) -</dd> -</dl> -<a NAME="QRegExpWizardRepeatDialog.on_upperSpin_valueChanged" ID="QRegExpWizardRepeatDialog.on_upperSpin_valueChanged"></a> -<h4>QRegExpWizardRepeatDialog.on_upperSpin_valueChanged</h4> -<b>on_upperSpin_valueChanged</b>(<i>value</i>) - -<p> - Private slot to handle the upperSpin valueChanged signal. -</p> -<dl> - -<dt><i>value</i></dt> -<dd> -value of the spinbox (integer) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- a/eric6/Documentation/Source/index-eric6.Plugins.WizardPlugins.QRegExpWizard.html Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric6.Plugins.WizardPlugins.QRegExpWizard</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body> -<h1>eric6.Plugins.WizardPlugins.QRegExpWizard</h1> - -<p> -Package implementing the QRegExp wizard. -</p> - - -<h3>Modules</h3> -<table> - -<tr> -<td><a href="eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardCharactersDialog.html">QRegExpWizardCharactersDialog</a></td> -<td>Module implementing a dialog for entering character classes.</td> -</tr> -<tr> -<td><a href="eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardDialog.html">QRegExpWizardDialog</a></td> -<td>Module implementing the QRegExp wizard dialog.</td> -</tr> -<tr> -<td><a href="eric6.Plugins.WizardPlugins.QRegExpWizard.QRegExpWizardRepeatDialog.html">QRegExpWizardRepeatDialog</a></td> -<td>Module implementing a dialog for entering repeat counts.</td> -</tr> -</table> -</body></html> \ No newline at end of file
--- a/eric6/E5Gui/E5OverrideCursor.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/E5Gui/E5OverrideCursor.py Sun Oct 11 17:54:52 2020 +0200 @@ -53,7 +53,7 @@ QGuiApplication.restoreOverrideCursor() QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) - return None + return None # __IGNORE_WARNING_M831__ class E5OverridenCursor(contextlib.AbstractContextManager): @@ -98,7 +98,7 @@ QGuiApplication.setOverrideCursor(self.__cursor) QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) - return None + return None # __IGNORE_WARNING_M831__ class E5OverrideCursorProcess(QProcess):
--- a/eric6/E5Network/E5NetworkProxyFactory.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/E5Network/E5NetworkProxyFactory.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,10 +7,10 @@ Module implementing a network proxy factory. """ +import os +import re -import os - -from PyQt5.QtCore import Qt, QUrl, QCoreApplication, QRegExp +from PyQt5.QtCore import QUrl, QCoreApplication from PyQt5.QtWidgets import QDialog from PyQt5.QtNetwork import ( QNetworkProxyFactory, QNetworkProxy, QNetworkProxyQuery @@ -99,7 +99,7 @@ .replace("*", ".*") .replace("?", ".") ) - self.__regExp = QRegExp(regexp, Qt.CaseInsensitive) + self.__regExp = re.compile(regexp, re.IGNORECASE) def pattern(self): """ @@ -122,7 +122,7 @@ if self.__regExp is None: return self.__pattern in host - return self.__regExp.indexIn(host) > -1 + return self.__regExp.search(host) is not None class E5NetworkProxyFactory(QNetworkProxyFactory):
--- a/eric6/E5Network/E5TldExtractor.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/E5Network/E5TldExtractor.py Sun Oct 11 17:54:52 2020 +0200 @@ -14,8 +14,9 @@ import collections import os +import re -from PyQt5.QtCore import QObject, QUrl, QFile, QFileInfo, QRegExp, qWarning +from PyQt5.QtCore import QObject, QUrl, QFile, QFileInfo, qWarning from E5Gui import E5MessageBox @@ -481,7 +482,7 @@ if not file.open(QFile.ReadOnly | QFile.Text): return False - testRegExp = QRegExp( + testRegExp = re.compile( "checkPublicSuffix\\(('([^']+)'|null), ('([^']+)'|null)\\);") allTestSuccess = True @@ -490,11 +491,11 @@ if not line or line.startswith("//"): continue - if testRegExp.indexIn(line) == -1: + match = testRegExp.search(line) + if match is None: allTestSuccess = False else: - hostName = testRegExp.cap(2) - registrableName = testRegExp.cap(4) + hostName, registrableName = match.group(2, 4) if not self.__checkPublicSuffix(hostName, registrableName): allTestSuccess = False
--- a/eric6/E5Utilities/E5MutexLocker.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/E5Utilities/E5MutexLocker.py Sun Oct 11 17:54:52 2020 +0200 @@ -47,4 +47,4 @@ """ self.__mutex.unlock() - return None + return None # __IGNORE_WARNING_M831__
--- a/eric6/HexEdit/HexEditGotoWidget.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/HexEdit/HexEditGotoWidget.py Sun Oct 11 17:54:52 2020 +0200 @@ -8,8 +8,8 @@ """ -from PyQt5.QtCore import pyqtSlot, Qt, QRegExp -from PyQt5.QtGui import QRegExpValidator +from PyQt5.QtCore import pyqtSlot, Qt, QRegularExpression +from PyQt5.QtGui import QRegularExpressionValidator from PyQt5.QtWidgets import QWidget from .Ui_HexEditGotoWidget import Ui_HexEditGotoWidget @@ -38,8 +38,10 @@ # keep this in sync with the logic in on_gotoButton_clicked() self.__formatAndValidators = { - "hex": (self.tr("Hex"), QRegExpValidator((QRegExp("[0-9a-f:]*")))), - "dec": (self.tr("Dec"), QRegExpValidator((QRegExp("[0-9]*")))), + "hex": (self.tr("Hex"), QRegularExpressionValidator( + QRegularExpression("[0-9a-f:]*"))), + "dec": (self.tr("Dec"), QRegularExpressionValidator( + QRegularExpression("[0-9]*"))), } formatOrder = ["hex", "dec"]
--- a/eric6/HexEdit/HexEditSearchReplaceWidget.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/HexEdit/HexEditSearchReplaceWidget.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,9 +7,8 @@ Module implementing a search and replace widget for the hex editor. """ - -from PyQt5.QtCore import pyqtSlot, Qt, QByteArray, QRegExp -from PyQt5.QtGui import QRegExpValidator +from PyQt5.QtCore import pyqtSlot, Qt, QByteArray, QRegularExpression +from PyQt5.QtGui import QRegularExpressionValidator from PyQt5.QtWidgets import QWidget from E5Gui.E5Action import E5Action @@ -42,10 +41,14 @@ # keep this in sync with the logic in __getContent() self.__formatAndValidators = { - "hex": (self.tr("Hex"), QRegExpValidator((QRegExp("[0-9a-f]*")))), - "dec": (self.tr("Dec"), QRegExpValidator((QRegExp("[0-9]*")))), - "oct": (self.tr("Oct"), QRegExpValidator((QRegExp("[0-7]*")))), - "bin": (self.tr("Bin"), QRegExpValidator((QRegExp("[01]*")))), + "hex": (self.tr("Hex"), QRegularExpressionValidator( + QRegularExpression("[0-9a-f]*"))), + "dec": (self.tr("Dec"), QRegularExpressionValidator( + QRegularExpression("[0-9]*"))), + "oct": (self.tr("Oct"), QRegularExpressionValidator( + QRegularExpression("[0-7]*"))), + "bin": (self.tr("Bin"), QRegularExpressionValidator( + QRegularExpression("[01]*"))), "iso-8859-1": (self.tr("Text"), None), # text as latin-1/iso-8859-1 "utf-8": (self.tr("UTF-8"), None),
--- a/eric6/PipInterface/PipPackagesWidget.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/PipInterface/PipPackagesWidget.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,11 +7,11 @@ Module implementing the pip packages management widget. """ - import textwrap import os +import re -from PyQt5.QtCore import pyqtSlot, Qt, QRegExp +from PyQt5.QtCore import pyqtSlot, Qt from PyQt5.QtWidgets import ( QWidget, QToolButton, QApplication, QHeaderView, QTreeWidgetItem, QInputDialog, QMenu, QDialog @@ -793,8 +793,8 @@ for queryTerm in self.__querySummary: if queryTerm.lower() in summary.lower(): - if QRegExp(r'\b{0}\b'.format(QRegExp.escape(queryTerm)), - Qt.CaseInsensitive).indexIn(summary) != -1: + if re.search(r'\b{0}\b'.format(re.escape(queryTerm)), + summary, re.IGNORECASE) is not None: # word match gets even higher score score += 2 else:
--- a/eric6/Plugins/PluginWizardQRegExp.py Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2007 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing the QRegExp wizard plugin. -""" - - -from PyQt5.QtCore import QObject -from PyQt5.QtWidgets import QDialog - -from E5Gui.E5Application import e5App -from E5Gui.E5Action import E5Action -from E5Gui import E5MessageBox - -import UI.Info - -# Start-Of-Header -name = "QRegExp Wizard Plugin" -author = "Detlev Offenbach <detlev@die-offenbachs.de>" -autoactivate = True -deactivateable = True -version = UI.Info.VersionOnly -className = "QRegExpWizard" -packageName = "__core__" -shortDescription = "Show the QRegExp wizard." -longDescription = """This plugin shows the QRegExp wizard.""" -pyqtApi = 2 -# End-Of-Header - -error = "" - - -class QRegExpWizard(QObject): - """ - Class implementing the QRegExp wizard plugin. - """ - def __init__(self, ui): - """ - Constructor - - @param ui reference to the user interface object (UI.UserInterface) - """ - super(QRegExpWizard, self).__init__(ui) - self.__ui = ui - - def activate(self): - """ - Public method to activate this plugin. - - @return tuple of None and activation status (boolean) - """ - self.__initAction() - self.__initMenu() - - return None, True - - def deactivate(self): - """ - Public method to deactivate this plugin. - """ - menu = self.__ui.getMenu("wizards") - if menu: - menu.removeAction(self.action) - self.__ui.removeE5Actions([self.action], 'wizards') - - def __initAction(self): - """ - Private method to initialize the action. - """ - self.action = E5Action( - self.tr('QRegExp Wizard'), - self.tr('Q&RegExp Wizard...'), 0, 0, self, - 'wizards_qregexp') - self.action.setStatusTip(self.tr('QRegExp Wizard')) - self.action.setWhatsThis(self.tr( - """<b>QRegExp Wizard</b>""" - """<p>This wizard opens a dialog for entering all the parameters""" - """ needed to create a QRegExp. The generated code is inserted""" - """ at the current cursor position.</p>""" - )) - self.action.triggered.connect(self.__handle) - - self.__ui.addE5Actions([self.action], 'wizards') - - def __initMenu(self): - """ - Private method to add the actions to the right menu. - """ - menu = self.__ui.getMenu("wizards") - if menu: - menu.addAction(self.action) - - def __callForm(self, editor): - """ - Private method to display a dialog and get the code. - - @param editor reference to the current editor - @return the generated code (string) - """ - from WizardPlugins.QRegExpWizard.QRegExpWizardDialog import ( - QRegExpWizardDialog - ) - dlg = QRegExpWizardDialog(None, True) - if dlg.exec() == QDialog.Accepted: - line, index = editor.getCursorPosition() - indLevel = editor.indentation(line) // editor.indentationWidth() - if editor.indentationsUseTabs(): - indString = '\t' - else: - indString = editor.indentationWidth() * ' ' - return (dlg.getCode(indLevel, indString), 1) - else: - return (None, False) - - def __handle(self): - """ - Private method to handle the wizards action. - """ - editor = e5App().getObject("ViewManager").activeWindow() - - if editor is None: - E5MessageBox.critical( - self.__ui, - self.tr('No current editor'), - self.tr('Please open or create a file first.')) - else: - code, ok = self.__callForm(editor) - if ok: - line, index = editor.getCursorPosition() - # It should be done on this way to allow undo - editor.beginUndoAction() - editor.insertAt(code, line, index) - editor.endUndoAction()
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,12 +7,12 @@ Module implementing a dialog to browse the log history. """ - import os import collections +import re from PyQt5.QtCore import ( - pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, QSize, QPoint, QFileInfo + pyqtSlot, Qt, QDate, QProcess, QTimer, QSize, QPoint, QFileInfo ) from PyQt5.QtGui import ( QColor, QPixmap, QPainter, QPen, QIcon, QTextCursor, QPalette @@ -1178,25 +1178,25 @@ txt = self.fieldCombo.itemData(self.fieldCombo.currentIndex()) if txt == "author": fieldIndex = self.AuthorColumn - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) elif txt == "committer": fieldIndex = self.CommitterColumn - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) elif txt == "commitId": fieldIndex = self.CommitIdColumn txt = self.rxEdit.text() if txt.startswith("^"): - searchRx = QRegExp(r"^\s*{0}".format(txt[1:]), - Qt.CaseInsensitive) + searchRx = re.compile(r"^\s*{0}".format(txt[1:]), + re.IGNORECASE) else: - searchRx = QRegExp(txt, Qt.CaseInsensitive) + searchRx = re.compile(txt, re.IGNORECASE) elif txt == "file": fieldIndex = self.__changesRole - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) indexIsRole = True else: fieldIndex = self.__subjectRole - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) indexIsRole = True return fieldIndex, searchRx, indexIsRole @@ -1229,7 +1229,7 @@ if ( topItem.text(self.DateColumn) <= to_ and topItem.text(self.DateColumn) >= from_ and - searchRx.indexIn(txt) > -1 + searchRx.search(txt) is not None ): topItem.setHidden(False) if topItem is currentItem: @@ -2043,7 +2043,7 @@ txt = topItem.data(0, self.__subjectRole) else: txt = topItem.text(fieldIndex) - if searchRx.indexIn(txt) > -1: + if searchRx.search(txt) is not None: self.logTree.setCurrentItem(self.logTree.topLevelItem(index)) break else:
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -8,8 +8,9 @@ """ import os +import re -from PyQt5.QtCore import pyqtSlot, Qt, QRegExp, QCoreApplication +from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication from PyQt5.QtWidgets import ( QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem ) @@ -230,20 +231,20 @@ searchRxText = self.rxEdit.text() filterTop = self.categoryCombo.currentText() == self.tr("Revision") if filterTop and searchRxText.startswith("^"): - searchRx = QRegExp( - r"^\s*{0}".format(searchRxText[1:]), Qt.CaseInsensitive) + searchRx = re.compile( + r"^\s*{0}".format(searchRxText[1:]), re.IGNORECASE) else: - searchRx = QRegExp(searchRxText, Qt.CaseInsensitive) + searchRx = re.compile(searchRxText, re.IGNORECASE) for topIndex in range(self.signaturesList.topLevelItemCount()): topLevelItem = self.signaturesList.topLevelItem(topIndex) if filterTop: topLevelItem.setHidden( - searchRx.indexIn(topLevelItem.text(0)) == -1) + searchRx.search(topLevelItem.text(0)) is None) else: visibleChildren = topLevelItem.childCount() for childIndex in range(topLevelItem.childCount()): childItem = topLevelItem.child(childIndex) - if searchRx.indexIn(childItem.text(0)) == -1: + if searchRx.search(childItem.text(0)) is None: childItem.setHidden(True) visibleChildren -= 1 else:
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py Sun Oct 11 17:54:52 2020 +0200 @@ -78,7 +78,10 @@ if bundle: args.append('--repository') args.append(bundle) - elif self.vcs.bundleFile and os.path.exists(self.vcs.bundleFile): + elif ( + self.vcs.bundleFile and + os.path.exists(self.vcs.bundleFile) + ): args.append('--repository') args.append(self.vcs.bundleFile)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -11,7 +11,7 @@ import re import collections -from PyQt5.QtCore import pyqtSlot, Qt, QDate, QRegExp, QSize, QPoint, QFileInfo +from PyQt5.QtCore import pyqtSlot, Qt, QDate, QSize, QPoint, QFileInfo from PyQt5.QtGui import ( QColor, QPixmap, QPainter, QPen, QBrush, QIcon, QTextCursor, QPalette ) @@ -1841,7 +1841,7 @@ (branch == self.__allBranchesFilter or topItem.text(self.BranchColumn) in [branch, closedBranch]) and - searchRx.indexIn(txt) > -1 + searchRx.search(txt) is not None ): topItem.setHidden(False) if topItem is currentItem: @@ -1866,25 +1866,25 @@ txt = self.fieldCombo.itemData(self.fieldCombo.currentIndex()) if txt == "author": fieldIndex = self.AuthorColumn - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) elif txt == "revision": fieldIndex = self.RevisionColumn txt = self.rxEdit.text() if txt.startswith("^"): - searchRx = QRegExp(r"^\s*{0}".format(txt[1:]), - Qt.CaseInsensitive) + searchRx = re.compile(r"^\s*{0}".format(txt[1:]), + re.IGNORECASE) else: - searchRx = QRegExp(txt, Qt.CaseInsensitive) + searchRx = re.compile(txt, re.IGNORECASE) elif txt == "file": fieldIndex = self.__changesRole - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) indexIsRole = True elif txt == "phase": fieldIndex = self.PhaseColumn - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) else: fieldIndex = self.__messageRole - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) indexIsRole = True return fieldIndex, searchRx, indexIsRole @@ -2430,7 +2430,7 @@ txt = "\n".join(topItem.data(0, self.__messageRole)) else: txt = topItem.text(fieldIndex) - if searchRx.indexIn(txt) > -1: + if searchRx.search(txt) is not None: self.logTree.setCurrentItem(self.logTree.topLevelItem(index)) break else:
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,12 +7,12 @@ Module implementing a dialog to browse the log history. """ - +import re import os import pysvn -from PyQt5.QtCore import Qt, QDate, QRegExp, pyqtSlot, QPoint +from PyQt5.QtCore import Qt, QDate, pyqtSlot, QPoint from PyQt5.QtWidgets import ( QHeaderView, QWidget, QApplication, QDialogButtonBox, QTreeWidgetItem ) @@ -567,18 +567,18 @@ txt = self.fieldCombo.currentText() if txt == self.tr("Author"): fieldIndex = 1 - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) elif txt == self.tr("Revision"): fieldIndex = 0 txt = self.rxEdit.text() if txt.startswith("^"): - searchRx = QRegExp( - r"^\s*{0}".format(txt[1:]), Qt.CaseInsensitive) + searchRx = re.compile( + r"^\s*{0}".format(txt[1:]), re.IGNORECASE) else: - searchRx = QRegExp(txt, Qt.CaseInsensitive) + searchRx = re.compile(txt, re.IGNORECASE) else: fieldIndex = 3 - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) currentItem = self.logTree.currentItem() for topIndex in range(self.logTree.topLevelItemCount()): @@ -586,7 +586,7 @@ if ( topItem.text(2) <= to_ and topItem.text(2) >= from_ and - searchRx.indexIn(topItem.text(fieldIndex)) > -1 + searchRx.search(topItem.text(fieldIndex)) is not None ): topItem.setHidden(False) if topItem is currentItem:
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnMergeDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnMergeDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,8 @@ Module implementing a dialog to enter the data for a merge operation. """ +import re -from PyQt5.QtCore import QRegExp from PyQt5.QtWidgets import QDialog, QDialogButtonBox from .Ui_SvnMergeDialog import Ui_SvnMergeDialog @@ -39,8 +39,8 @@ self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) self.okButton.setEnabled(False) - self.rx_url = QRegExp('(?:file:|svn:|svn+ssh:|http:|https:)//.+') - self.rx_rev = QRegExp('\\d+') + self.rx_url = re.compile('(?:file:|svn:|svn+ssh:|http:|https:)//.+') + self.rx_rev = re.compile('\\d+') self.tag1Combo.clear() self.tag1Combo.addItems(mergelist1) @@ -59,11 +59,12 @@ self.okButton.setDisabled( self.tag1Combo.currentText() == "" or self.tag2Combo.currentText() == "" or - not ((self.rx_url.exactMatch(self.tag1Combo.currentText()) and - self.rx_url.exactMatch(self.tag2Combo.currentText())) or - (self.rx_rev.exactMatch(self.tag1Combo.currentText()) and - self.rx_rev.exactMatch(self.tag2Combo.currentText())) - ) + not ( + (bool(self.rx_url.fullmatch(self.tag1Combo.currentText())) and + bool(self.rx_url.fullmatch(self.tag2Combo.currentText()))) or + (bool(self.rx_rev.fullmatch(self.tag1Combo.currentText())) and + bool(self.rx_rev.fullmatch(self.tag2Combo.currentText()))) + ) ) def on_tag1Combo_editTextChanged(self, text):
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnTagBranchListDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnTagBranchListDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,12 +7,12 @@ Module implementing a dialog to show a list of tags or branches. """ - +import re import os import pysvn -from PyQt5.QtCore import QRegExp, Qt +from PyQt5.QtCore import Qt from PyQt5.QtWidgets import ( QHeaderView, QLineEdit, QDialog, QInputDialog, QApplication, QDialogButtonBox, QTreeWidgetItem @@ -94,8 +94,9 @@ if self.vcs.otherData["standardLayout"]: # determine the base path of the project in the repository - rx_base = QRegExp('(.+)/(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+)/(trunk|tags|branches).*') + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self, self.tr("Subversion Error"), @@ -105,7 +106,7 @@ """ be aborted""")) return False - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) if tags: path = "{0}/tags".format(reposRoot)
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnUrlSelectionDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnUrlSelectionDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,9 @@ Module implementing a dialog to enter the URLs for the svn diff command. """ +import re -from PyQt5.QtCore import QRegExp, pyqtSlot +from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog from E5Gui.E5Application import e5App @@ -63,8 +64,9 @@ if self.vcs.otherData["standardLayout"]: # determine the base path of the project in the repository - rx_base = QRegExp('(.+/)(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+/)(trunk|tags|branches).*') + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self, self.tr("Subversion Error"), @@ -75,7 +77,7 @@ self.reject() return - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) self.repoRootLabel1.setText(reposRoot) self.repoRootLabel2.setText(reposRoot) else:
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,15 +7,13 @@ Module implementing the version control systems interface to Subversion. """ - +import re import os import shutil import time from urllib.parse import quote -from PyQt5.QtCore import ( - pyqtSignal, Qt, QRegExp, QDateTime, QCoreApplication -) +from PyQt5.QtCore import pyqtSignal, Qt, QDateTime, QCoreApplication from PyQt5.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication from E5Gui.E5Application import e5App @@ -918,7 +916,7 @@ @param noDialog flag indicating quiet operations @return flag indicating successfull operation (boolean) """ - rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+') + rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+') opts = self.options['global'] res = False @@ -936,14 +934,14 @@ if not target: return False - if not rx_prot.exactMatch(target): + if rx_prot.fullmatch(target) is None: isDir = os.path.isdir(name) else: isDir = False if accepted: client = self.getClient() - if rx_prot.exactMatch(target): + if rx_prot.fullmatch(target) is not None: target = self.__svnURL(target) log = "Moving {0} to {1}".format(name, target) else: @@ -969,7 +967,7 @@ if not noDialog: dlg.finish() dlg.exec() - if res and not rx_prot.exactMatch(target): + if res and rx_prot.fullmatch(target) is None: if target.startswith(project.getProjectPath()): if isDir: project.moveDirectory(name, target) @@ -1067,8 +1065,10 @@ return if self.otherData["standardLayout"]: - rx_base = QRegExp('(.+)/(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+)/(trunk|tags|branches).*') + + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self.__ui, self.tr("Subversion Error"), @@ -1078,7 +1078,7 @@ """ be aborted""")) return - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) if tagOp in [1, 4]: url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) elif tagOp in [2, 8]: @@ -1207,8 +1207,9 @@ return False if self.otherData["standardLayout"]: - rx_base = QRegExp('(.+)/(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+)/(trunk|tags|branches).*') + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self.__ui, self.tr("Subversion Error"), @@ -1218,7 +1219,7 @@ """ be aborted""")) return False - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) tn = tag if tagType == 1: url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) @@ -1273,12 +1274,12 @@ self.mergeList[1].remove(urlrev2) self.mergeList[1].insert(0, urlrev2) - rx_rev = QRegExp('\\d+|HEAD|head') + rx_rev = re.compile('\\d+|HEAD|head') cwd = os.getcwd() os.chdir(dname) recurse = "--non-recursive" not in opts - if rx_rev.exactMatch(urlrev1): + if bool(rx_rev.fullmatch(urlrev1)): if urlrev1 in ["HEAD", "head"]: revision1 = pysvn.Revision(pysvn.opt_revision_kind.head) rev1 = "HEAD" @@ -1817,14 +1818,14 @@ @return flag indicating successfull operation (boolean) """ from .SvnCopyDialog import SvnCopyDialog - rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+') + rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+') dlg = SvnCopyDialog(name) res = False if dlg.exec() == QDialog.Accepted: target, force = dlg.getData() client = self.getClient() - if rx_prot.exactMatch(target): + if bool(rx_prot.fullmatch(target)): target = self.__svnURL(target) log = "Copying {0} to {1}".format(name, target) else: @@ -1848,7 +1849,7 @@ dlg.exec() if ( res and - not rx_prot.exactMatch(target) and + not bool(rx_prot.fullmatch(target)) and target.startswith(project.getProjectPath()) ): if os.path.isdir(name):
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnChangeListsDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnChangeListsDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,10 +7,10 @@ Module implementing a dialog to browse the change lists. """ - +import re import os -from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QRegExp, QTimer +from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer from PyQt5.QtWidgets import ( QDialog, QDialogButtonBox, QListWidgetItem, QLineEdit ) @@ -48,12 +48,12 @@ self.process.readyReadStandardOutput.connect(self.__readStdout) self.process.readyReadStandardError.connect(self.__readStderr) - self.rx_status = QRegExp( + self.rx_status = re.compile( '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*') # flags (8 or 9 anything), revision, changed rev, author, path - self.rx_status2 = QRegExp('(.{8,9})\\s+(.+)\\s*') + self.rx_status2 = re.compile('(.{8,9})\\s+(.+)\\s*') # flags (8 or 9 anything), path - self.rx_changelist = QRegExp('--- \\S+ .([\\w\\s]+).:\\s+') + self.rx_changelist = re.compile('--- \\S+ .([\\w\\s]+).:\\s+') # three dashes, Changelist (translated), quote, # changelist name, quote, : @@ -186,32 +186,33 @@ s = str(self.process.readLine(), Preferences.getSystem("IOEncoding"), 'replace') - if ( - self.currentChangelist != "" and - self.rx_status.exactMatch(s) - ): - file = self.rx_status.cap(5).strip() - filename = file.replace(self.path + os.sep, "") - if filename not in self.changeListsDict[ - self.currentChangelist - ]: - self.changeListsDict[self.currentChangelist].append( - filename) - elif ( - self.currentChangelist != "" and - self.rx_status2.exactMatch(s) - ): - file = self.rx_status2.cap(2).strip() - filename = file.replace(self.path + os.sep, "") - if filename not in self.changeListsDict[ - self.currentChangelist - ]: - self.changeListsDict[self.currentChangelist].append( - filename) - elif self.rx_changelist.exactMatch(s): - self.currentChangelist = self.rx_changelist.cap(1) - if self.currentChangelist not in self.changeListsDict: - self.changeListsDict[self.currentChangelist] = [] + match = ( + self.rx_status.fullmatch(s) or + self.rx_status2.fullmatch(s) + ) + if self.currentChangelist != "" and match is not None: + if match.re is self.rx_status: + file = match.group(5).strip() + filename = file.replace(self.path + os.sep, "") + if filename not in self.changeListsDict[ + self.currentChangelist + ]: + self.changeListsDict[ + self.currentChangelist].append(filename) + else: + file = match.group(2).strip() + filename = file.replace(self.path + os.sep, "") + if filename not in self.changeListsDict[ + self.currentChangelist + ]: + self.changeListsDict[ + self.currentChangelist].append(filename) + else: + match = self.rx_changelist.fullmatch(s) + if match is not None: + self.currentChangelist = match.group(1) + if self.currentChangelist not in self.changeListsDict: + self.changeListsDict[self.currentChangelist] = [] def __readStderr(self): """
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnLogBrowserDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnLogBrowserDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,12 +7,10 @@ Module implementing a dialog to browse the log history. """ - +import re import os -from PyQt5.QtCore import ( - QTimer, QDate, QProcess, QRegExp, Qt, pyqtSlot, QPoint -) +from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QDate, QProcess, QPoint from PyQt5.QtWidgets import ( QHeaderView, QLineEdit, QWidget, QApplication, QDialogButtonBox, QTreeWidgetItem @@ -69,23 +67,23 @@ self.__process.readyReadStandardOutput.connect(self.__readStdout) self.__process.readyReadStandardError.connect(self.__readStderr) - self.rx_sep1 = QRegExp('\\-+\\s*') - self.rx_sep2 = QRegExp('=+\\s*') - self.rx_rev1 = QRegExp( + self.rx_sep1 = re.compile('\\-+\\s*') + self.rx_sep2 = re.compile('=+\\s*') + self.rx_rev1 = re.compile( r'rev ([0-9]+): ([^|]*) \| ([^|]*) \| ([0-9]+) .*') # "rev" followed by one or more decimals followed by a colon followed # anything up to " | " (twice) followed by one or more decimals # followed by anything - self.rx_rev2 = QRegExp( + self.rx_rev2 = re.compile( r'r([0-9]+) \| ([^|]*) \| ([^|]*) \| ([0-9]+) .*') # "r" followed by one or more decimals followed by " | " followed # anything up to " | " (twice) followed by one or more decimals # followed by anything - self.rx_flags1 = QRegExp( + self.rx_flags1 = re.compile( r""" ([ADM])\s(.*)\s+\(\w+\s+(.*):([0-9]+)\)\s*""") # three blanks followed by A or D or M followed by path followed by # path copied from followed by copied from revision - self.rx_flags2 = QRegExp(' ([ADM]) (.*)\\s*') + self.rx_flags2 = re.compile(' ([ADM]) (.*)\\s*') # three blanks followed by A or D or M followed by path self.flags = { @@ -383,37 +381,47 @@ log = {"message": []} changedPaths = [] for s in self.buf: - if self.rx_rev1.exactMatch(s): - log["revision"] = self.rx_rev.cap(1) - log["author"] = self.rx_rev.cap(2) - log["date"] = self.rx_rev.cap(3) + match = ( + self.rx_rev1.fullmatch(s) or + self.rx_rev2.fullmatch(s) or + self.rx_flags1.fullmatch(s) or + self.rx_flags2.fullmatch(s) or + self.rx_sep1.fullmatch(s) or + self.rx_sep2.fullmatch(s) + ) + if match is None: + if s.strip().endswith(":") or not s.strip(): + continue + else: + log["message"].append(s) + elif match.re is self.rx_rev1: + log["revision"] = match.group(1) + log["author"] = match.group(2) + log["date"] = match.group(3) # number of lines is ignored - elif self.rx_rev2.exactMatch(s): - log["revision"] = self.rx_rev2.cap(1) - log["author"] = self.rx_rev2.cap(2) - log["date"] = " ".join(self.rx_rev2.cap(3).split()[:2]) + elif match.re is self.rx_rev2: + log["revision"] = match.group(1) + log["author"] = match.group(2) + log["date"] = " ".join(match.group(3).split()[:2]) # number of lines is ignored - elif self.rx_flags1.exactMatch(s): + elif match.re is self.rx_flags1: changedPaths.append({ - "action": - self.rx_flags1.cap(1).strip(), - "path": - self.rx_flags1.cap(2).strip(), - "copyfrom_path": - self.rx_flags1.cap(3).strip(), - "copyfrom_revision": - self.rx_flags1.cap(4).strip(), + "action": match.group(1).strip(), + "path": match.group(2).strip(), + "copyfrom_path": match.group(3).strip(), + "copyfrom_revision": match.group(4).strip(), }) - elif self.rx_flags2.exactMatch(s): + elif match.re is self.rx_flags2: changedPaths.append({ - "action": - self.rx_flags2.cap(1).strip(), - "path": - self.rx_flags2.cap(2).strip(), + "action": match.group(1).strip(), + "path": match.group(2).strip(), "copyfrom_path": "", "copyfrom_revision": "", }) - elif self.rx_sep1.exactMatch(s) or self.rx_sep2.exactMatch(s): + elif ( + match.re is self.rx_sep1 or + match.re is self.rx_sep2 + ): if len(log) > 1: self.__generateLogItem( log["author"], log["date"], log["message"], @@ -433,11 +441,6 @@ noEntries += 1 log = {"message": []} changedPaths = [] - else: - if s.strip().endswith(":") or not s.strip(): - continue - else: - log["message"].append(s) self.__resizeColumnsLog() self.__resortLog() @@ -657,18 +660,18 @@ txt = self.fieldCombo.currentText() if txt == self.tr("Author"): fieldIndex = 1 - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) elif txt == self.tr("Revision"): fieldIndex = 0 txt = self.rxEdit.text() if txt.startswith("^"): - searchRx = QRegExp( - r"^\s*{0}".format(txt[1:]), Qt.CaseInsensitive) + searchRx = re.compile( + r"^\s*{0}".format(txt[1:]), re.IGNORECASE) else: - searchRx = QRegExp(txt, Qt.CaseInsensitive) + searchRx = re.compile(txt, re.IGNORECASE) else: fieldIndex = 3 - searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive) + searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE) currentItem = self.logTree.currentItem() for topIndex in range(self.logTree.topLevelItemCount()): @@ -676,7 +679,7 @@ if ( topItem.text(2) <= to_ and topItem.text(2) >= from_ and - searchRx.indexIn(topItem.text(fieldIndex)) > -1 + searchRx.match(topItem.text(fieldIndex)) is not None ): topItem.setHidden(False) if topItem is currentItem:
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnMergeDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnMergeDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,8 @@ Module implementing a dialog to enter the data for a merge operation. """ +import re -from PyQt5.QtCore import QRegExp from PyQt5.QtWidgets import QDialog, QDialogButtonBox from .Ui_SvnMergeDialog import Ui_SvnMergeDialog @@ -36,8 +36,8 @@ self.forceCheckBox.setChecked(force) - self.rx_url = QRegExp('(?:file:|svn:|svn+ssh:|http:|https:)//.+') - self.rx_rev = QRegExp('\\d+') + self.rx_url = re.compile('(?:file:|svn:|svn+ssh:|http:|https:)//.+') + self.rx_rev = re.compile('\\d+') self.tag1Combo.clear() self.tag1Combo.addItems(mergelist1) @@ -59,11 +59,12 @@ self.okButton.setDisabled( self.tag1Combo.currentText() != "" or self.tag2Combo.currentText() != "" or - not ((self.rx_url.exactMatch(self.tag1Combo.currentText()) and - self.rx_url.exactMatch(self.tag2Combo.currentText())) or - (self.rx_rev.exactMatch(self.tag1Combo.currentText()) and - self.rx_rev.exactMatch(self.tag2Combo.currentText())) - ) + not ( + (bool(self.rx_url.fullmatch(self.tag1Combo.currentText())) and + bool(self.rx_url.fullmatch(self.tag2Combo.currentText()))) or + (bool(self.rx_rev.fullmatch(self.tag1Combo.currentText())) and + bool(self.rx_rev.fullmatch(self.tag2Combo.currentText()))) + ) ) def on_tag1Combo_editTextChanged(self, text):
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnPropListDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnPropListDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -8,10 +8,9 @@ process. """ +import re -from PyQt5.QtCore import ( - pyqtSlot, QTimer, QProcess, QProcessEnvironment, QRegExp, Qt -) +from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QProcess, QProcessEnvironment from PyQt5.QtWidgets import ( QWidget, QHeaderView, QDialogButtonBox, QTreeWidgetItem ) @@ -59,8 +58,8 @@ self.process.readyReadStandardOutput.connect(self.__readStdout) self.process.readyReadStandardError.connect(self.__readStderr) - self.rx_path = QRegExp(r"Properties on '([^']+)':\s*") - self.rx_prop = QRegExp(r" (.*) *: *(.*)[\r\n]") + self.rx_path = re.compile(r"Properties on '([^']+)':\s*") + self.rx_prop = re.compile(r" (.*) *: *(.*)[\r\n]") def __resort(self): """ @@ -223,23 +222,24 @@ s = str(self.process.readLine(), Preferences.getSystem("IOEncoding"), 'replace') - if self.rx_path.exactMatch(s): + match = self.rx_path.fullmatch(s) or self.rx_prop.fullmatch(s) + if match is None: + self.propBuffer += ' ' + self.propBuffer += s + elif match.re is self.rx_path: if self.lastProp: self.__generateItem( self.lastPath, self.lastProp, self.propBuffer) - self.lastPath = self.rx_path.cap(1) + self.lastPath = match.group(1) self.lastProp = None self.propBuffer = "" - elif self.rx_prop.exactMatch(s): + elif match.re is self.rx_prop: if self.lastProp: self.__generateItem( self.lastPath, self.lastProp, self.propBuffer) - self.lastProp = self.rx_prop.cap(1) - self.propBuffer = self.rx_prop.cap(2) - else: - self.propBuffer += ' ' - self.propBuffer += s - + self.lastProp = match.group(1) + self.propBuffer = match.group(2) + def __readStderr(self): """ Private slot to handle the readyReadStandardError signal.
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnRepoBrowserDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnRepoBrowserDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,14 +7,13 @@ Module implementing the subversion repository browser dialog. """ - +import re import os +from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QProcess from PyQt5.QtWidgets import ( - QHeaderView, QLineEdit, QDialog, QApplication, QDialogButtonBox, - QTreeWidgetItem + QHeaderView, QLineEdit, QDialog, QDialogButtonBox, QTreeWidgetItem ) -from PyQt5.QtCore import QTimer, QProcess, QRegExp, Qt, pyqtSlot from E5Gui import E5MessageBox from E5Gui.E5OverrideCursor import E5OverrideCursorProcess @@ -68,10 +67,10 @@ self.__ignoreExpand = False self.intercept = False - self.__rx_dir = QRegExp( + self.__rx_dir = re.compile( r"""\s*([0-9]+)\s+(\w+)\s+""" r"""((?:\w+\s+\d+|[0-9.]+\s+\w+)\s+[0-9:]+)\s+(.+)\s*""") - self.__rx_file = QRegExp( + self.__rx_file = re.compile( r"""\s*([0-9]+)\s+(\w+)\s+([0-9]+)\s""" r"""((?:\w+\s+\d+|[0-9.]+\s+\w+)\s+[0-9:]+)\s+(.+)\s*""") @@ -402,26 +401,31 @@ s = str(self.__process.readLine(), Preferences.getSystem("IOEncoding"), 'replace') - if self.__rx_dir.exactMatch(s): - revision = self.__rx_dir.cap(1) - author = self.__rx_dir.cap(2) - date = self.__rx_dir.cap(3) - name = self.__rx_dir.cap(4).strip() + match = ( + self.__rx_dir.fullmatch(s) or + self.__rx_file.fullmatch(s) + ) + if match is None: + continue + elif match.re is self.__rx_dir: + revision = match.group(1) + author = match.group(2) + date = match.group(3) + name = match.group(4).strip() if name.endswith("/"): name = name[:-1] size = "" nodekind = "dir" if name == ".": continue - elif self.__rx_file.exactMatch(s): - revision = self.__rx_file.cap(1) - author = self.__rx_file.cap(2) - size = self.__rx_file.cap(3) - date = self.__rx_file.cap(4) - name = self.__rx_file.cap(5).strip() + elif match.re is self.__rx_file: + revision = match.group(1) + author = match.group(2) + size = match.group(3) + date = match.group(4) + name = match.group(5).strip() nodekind = "file" - else: - continue + url = "{0}/{1}".format(self.repoUrl, name) self.__generateItem( name, revision, author, size, date, nodekind, url)
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnStatusDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnStatusDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -8,10 +8,10 @@ process. """ - +import re import os -from PyQt5.QtCore import QTimer, QProcess, QRegExp, Qt, pyqtSlot +from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QProcess from PyQt5.QtWidgets import ( QWidget, QHeaderView, QLineEdit, QApplication, QMenu, QDialogButtonBox, QTreeWidgetItem @@ -196,12 +196,12 @@ '*': self.tr('no'), } - self.rx_status = QRegExp( + self.rx_status = re.compile( '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*') # flags (8 or 9 anything), revision, changed rev, author, path - self.rx_status2 = QRegExp('(.{8,9})\\s+(.+)\\s*') + self.rx_status2 = re.compile('(.{8,9})\\s+(.+)\\s*') # flags (8 or 9 anything), path - self.rx_changelist = QRegExp('--- \\S+ .([\\w\\s]+).:\\s+') + self.rx_changelist = re.compile('--- \\S+ .([\\w\\s]+).:\\s+') # three dashes, Changelist (translated), quote, # changelist name, quote, : @@ -507,26 +507,31 @@ s = str(self.process.readLine(), Preferences.getSystem("IOEncoding"), 'replace') - if self.rx_status.exactMatch(s): - flags = self.rx_status.cap(1) - rev = self.rx_status.cap(2) - change = self.rx_status.cap(3) - author = self.rx_status.cap(4) - path = self.rx_status.cap(5).strip() + match = ( + self.rx_status.fullmatch(s) or + self.rx_status2.fullmatch(s) or + self.rx_changelist.fullmatch(s) + ) + if match.re is self.rx_status: + flags = match.group(1) + rev = match.group(2) + change = match.group(3) + author = match.group(4) + path = match.group(5).strip() self.__generateItem(flags[0], flags[1], flags[2], flags[3], flags[4], flags[5], flags[-1], rev, change, author, path) - elif self.rx_status2.exactMatch(s): - flags = self.rx_status2.cap(1) - path = self.rx_status2.cap(2).strip() + elif match.re is self.rx_status2: + flags = match.group(1) + path = match.group(2).strip() if flags[-1] in self.uptodate: self.__generateItem(flags[0], flags[1], flags[2], flags[3], flags[4], flags[5], flags[-1], "", "", "", path) - elif self.rx_changelist.exactMatch(s): - self.currentChangelist = self.rx_changelist.cap(1) + elif match.re is self.rx_changelist: + self.currentChangelist = match.group(1) self.changelistFound = True def __readStderr(self):
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnStatusMonitorThread.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnStatusMonitorThread.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,9 @@ Module implementing the VCS status monitor thread class for Subversion. """ +import re -from PyQt5.QtCore import QRegExp, QProcess +from PyQt5.QtCore import QProcess from VCS.StatusMonitorThread import VcsStatusMonitorThread @@ -32,8 +33,8 @@ self.__ioEncoding = Preferences.getSystem("IOEncoding") - self.rx_status1 = QRegExp('(.{8,9})\\s+([0-9-]+)\\s+(.+)\\s*') - self.rx_status2 = QRegExp( + self.rx_status1 = re.compile('(.{8,9})\\s+([0-9-]+)\\s+(.+)\\s*') + self.rx_status2 = re.compile( '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*') def _performMonitor(self): @@ -76,14 +77,18 @@ self.__ioEncoding, 'replace') states = {} for line in output.splitlines(): - if self.rx_status1.exactMatch(line): - flags = self.rx_status1.cap(1) - path = self.rx_status1.cap(3).strip() - elif self.rx_status2.exactMatch(line): - flags = self.rx_status2.cap(1) - path = self.rx_status2.cap(5).strip() - else: + match = ( + self.rx_status1.fullmatch(line) or + self.rx_status2.fullmatch(line) + ) + if match is None: continue + elif match.re is self.rx_status1: + flags = match.group(1) + path = match.group(3).strip() + elif match.re is self.rx_status2: + flags = match.group(1) + path = match.group(5).strip() if ( flags[0] in "ACDMR" or (flags[0] == " " and flags[-1] == "*")
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnTagBranchListDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnTagBranchListDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,10 +7,10 @@ Module implementing a dialog to show a list of tags or branches. """ - +import re import os -from PyQt5.QtCore import QTimer, QProcess, QRegExp, Qt, pyqtSlot +from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QProcess from PyQt5.QtWidgets import ( QHeaderView, QLineEdit, QDialog, QInputDialog, QDialogButtonBox, QTreeWidgetItem @@ -54,7 +54,7 @@ self.process.readyReadStandardOutput.connect(self.__readStdout) self.process.readyReadStandardError.connect(self.__readStderr) - self.rx_list = QRegExp( + self.rx_list = re.compile( r"""\w*\s*(\d+)\s+(\w+)\s+\d*\s*""" r"""((?:\w+\s+\d+|[0-9.]+\s+\w+)\s+[0-9:]+)\s+(.+)/\s*""") @@ -119,8 +119,9 @@ if self.vcs.otherData["standardLayout"]: # determine the base path of the project in the repository - rx_base = QRegExp('(.+)/(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+)/(trunk|tags|branches).*') + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self, self.tr("Subversion Error"), @@ -130,7 +131,7 @@ """ be aborted""")) return - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) if tags: args.append("{0}/tags".format(reposRoot)) @@ -266,11 +267,12 @@ s = str(self.process.readLine(), Preferences.getSystem("IOEncoding"), 'replace') - if self.rx_list.exactMatch(s): - rev = "{0:6}".format(self.rx_list.cap(1)) - author = self.rx_list.cap(2) - date = self.rx_list.cap(3) - path = self.rx_list.cap(4) + match = self.rx_list.fullmatch(s) + if match is not None: + rev = "{0:6}".format(match.group(1)) + author = match.group(2) + date = match.group(3) + path = match.group(4) if path == ".": continue self.__generateItem(rev, author, date, path)
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,9 @@ Module implementing a dialog to enter the URLs for the svn diff command. """ +import re -from PyQt5.QtCore import QRegExp, pyqtSlot +from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog from E5Gui.E5Application import e5App @@ -61,8 +62,9 @@ if self.vcs.otherData["standardLayout"]: # determine the base path of the project in the repository - rx_base = QRegExp('(.+/)(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+/)(trunk|tags|branches).*') + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self, self.tr("Subversion Error"), @@ -73,7 +75,7 @@ self.reject() return - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) self.repoRootLabel1.setText(reposRoot) self.repoRootLabel2.setText(reposRoot) else:
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py Sun Oct 11 17:54:52 2020 +0200 @@ -13,7 +13,7 @@ import shutil from urllib.parse import quote -from PyQt5.QtCore import pyqtSignal, QProcess, QRegExp, QCoreApplication +from PyQt5.QtCore import pyqtSignal, QProcess, QCoreApplication from PyQt5.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication from E5Gui.E5Application import e5App @@ -99,9 +99,9 @@ self.logBrowser = None # regular expression object for evaluation of the status output - self.rx_status1 = QRegExp( + self.rx_status1 = re.compile( '(.{8})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)') - self.rx_status2 = QRegExp('(.{8})\\s+(.+)\\s*') + self.rx_status2 = re.compile('(.{8})\\s+(.+)\\s*') self.statusCache = {} self.__commitData = {} @@ -847,7 +847,7 @@ @param noDialog flag indicating quiet operations @return flag indicating successfull operation (boolean) """ - rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+') + rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+') opts = self.options['global'][:] force = '--force' in opts if force: @@ -868,7 +868,7 @@ if not target: return False - if not rx_prot.exactMatch(target): + if rx_prot.fullmatch(target) is None: isDir = os.path.isdir(name) else: isDir = False @@ -879,7 +879,7 @@ self.addArguments(args, opts) if force: args.append('--force') - if rx_prot.exactMatch(target): + if rx_prot.fullmatch(target) is not None: args.append('--message') args.append('Moving {0} to {1}'.format(name, target)) target = self.__svnURL(target) @@ -895,7 +895,7 @@ if res: dia.exec() res = dia.normalExit() - if res and not rx_prot.exactMatch(target): + if res and rx_prot.fullmatch(target) is None: if target.startswith(project.getProjectPath()): if isDir: project.moveDirectory(name, target) @@ -992,8 +992,9 @@ return if self.otherData["standardLayout"]: - rx_base = QRegExp('(.+)/(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+)/(trunk|tags|branches).*') + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self.__ui, self.tr("Subversion Error"), @@ -1003,7 +1004,7 @@ """ be aborted""")) return - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) if tagOp in [1, 4]: url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) elif tagOp in [2, 8]: @@ -1114,8 +1115,9 @@ return False if self.otherData["standardLayout"]: - rx_base = QRegExp('(.+)/(trunk|tags|branches).*') - if not rx_base.exactMatch(reposURL): + rx_base = re.compile('(.+)/(trunk|tags|branches).*') + match = rx_base.fullmatch(reposURL) + if match is None: E5MessageBox.critical( self.__ui, self.tr("Subversion Error"), @@ -1125,7 +1127,7 @@ """ be aborted""")) return False - reposRoot = rx_base.cap(1) + reposRoot = match.group(1) tn = tag if tagType == 1: url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) @@ -1184,7 +1186,7 @@ self.mergeList[1].remove(urlrev2) self.mergeList[1].insert(0, urlrev2) - rx_rev = QRegExp('\\d+|HEAD') + rx_rev = re.compile('\\d+|HEAD') args = [] args.append('merge') @@ -1194,7 +1196,7 @@ args.append('postpone') if force: args.append('--force') - if rx_rev.exactMatch(urlrev1): + if rx_rev.fullmatch(urlrev1) is not None: args.append('-r') args.append('{0}:{1}'.format(urlrev1, urlrev2)) if not target: @@ -1354,14 +1356,17 @@ output = str(process.readAllStandardOutput(), ioEncoding, 'replace') for line in output.splitlines(): - if self.rx_status1.exactMatch(line): - flags = str(self.rx_status1.cap(1)) - path = self.rx_status1.cap(5).strip() - elif self.rx_status2.exactMatch(line): - flags = str(self.rx_status2.cap(1)) - path = self.rx_status2.cap(2).strip() + match = self.rx_status1.fullmatch(line) + if match is not None: + flags = self.rx_status1.group(1) + path = self.rx_status1.group(5).strip() else: - continue + match = self.rx_status2.fullmatch(line) + if match is not None: + flags = self.rx_status2.group(1) + path = self.rx_status2.group(2).strip() + else: + continue name = os.path.normcase(path) if flags[0] not in "?I": if name in names: @@ -1420,14 +1425,17 @@ output = str(process.readAllStandardOutput(), ioEncoding, 'replace') for line in output.splitlines(): - if self.rx_status1.exactMatch(line): - flags = self.rx_status1.cap(1) - path = self.rx_status1.cap(5).strip() - elif self.rx_status2.exactMatch(line): - flags = self.rx_status2.cap(1) - path = self.rx_status2.cap(2).strip() + match = self.rx_status1.fullmatch(line) + if match is not None: + flags = self.rx_status1.group(1) + path = self.rx_status1.group(5).strip() else: - continue + match = self.rx_status2.fullmatch(line) + if match is not None: + flags = self.rx_status2.group(1) + path = self.rx_status2.group(2).strip() + else: + continue name = os.path.normcase(path) if flags[0] not in "?I": if name in names: @@ -1697,7 +1705,7 @@ @return flag indicating successfull operation (boolean) """ from .SvnCopyDialog import SvnCopyDialog - rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+') + rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+') dlg = SvnCopyDialog(name) res = False if dlg.exec() == QDialog.Accepted: @@ -1706,7 +1714,8 @@ args = [] args.append('copy') self.addArguments(args, self.options['global']) - if rx_prot.exactMatch(target): + match = rx_prot.fullmatch(target) + if match is not None: args.append('--message') args.append('Copying {0} to {1}'.format(name, target)) target = self.__svnURL(target) @@ -1721,7 +1730,7 @@ res = dia.normalExit() if ( res and - not rx_prot.exactMatch(target) and + match is None and target.startswith(project.getProjectPath()) ): if os.path.isdir(name): @@ -2262,7 +2271,7 @@ @return list of defined change list names (list of strings) """ changelists = [] - rx_changelist = QRegExp('--- \\S+ .([\\w\\s]+).:\\s*') + rx_changelist = re.compile('--- \\S+ .([\\w\\s]+).:\\s*') # three dashes, Changelist (translated), quote, # changelist name, quote, : @@ -2284,8 +2293,9 @@ 'replace') if output: for line in output.splitlines(): - if rx_changelist.exactMatch(line): - changelist = rx_changelist.cap(1) + match = rx_changelist.fullmatch(line) + if match is not None: + changelist = match.group(1) if changelist not in changelists: changelists.append(changelist)
--- a/eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardCharactersDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardCharactersDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,9 +7,8 @@ Module implementing a dialog for entering character classes. """ - -from PyQt5.QtCore import QRegExp -from PyQt5.QtGui import QRegExpValidator +from PyQt5.QtCore import QRegularExpression +from PyQt5.QtGui import QRegularExpressionValidator from PyQt5.QtWidgets import ( QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, QLineEdit, QPushButton, QDialog, QScrollArea, QComboBox, QVBoxLayout, QLabel @@ -60,9 +59,12 @@ self.singleComboItems.append(self.tr("Horizontal tabulator (\\t)")) self.singleComboItems.append(self.tr("Vertical tabulator (\\v)")) - self.charValidator = QRegExpValidator(QRegExp(".{0,1}"), self) - self.hexValidator = QRegExpValidator(QRegExp("[0-9a-fA-F]{0,4}"), self) - self.octValidator = QRegExpValidator(QRegExp("[0-3]?[0-7]{0,2}"), self) + self.charValidator = QRegularExpressionValidator( + QRegularExpression(".{0,1}"), self) + self.hexValidator = QRegularExpressionValidator( + QRegularExpression("[0-9a-fA-F]{0,4}"), self) + self.octValidator = QRegularExpressionValidator( + QRegularExpression("[0-3]?[0-7]{0,2}"), self) # generate dialog part for single characters self.singlesBoxLayout = QVBoxLayout(self.singlesBox)
--- a/eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,689 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2004 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog for entering character classes. -""" - - -from PyQt5.QtCore import QRegExp -from PyQt5.QtGui import QRegExpValidator -from PyQt5.QtWidgets import ( - QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, QLineEdit, QPushButton, - QDialog, QScrollArea, QComboBox, QVBoxLayout, QLabel -) - -from .Ui_QRegExpWizardCharactersDialog import Ui_QRegExpWizardCharactersDialog - - -class QRegExpWizardCharactersDialog(QDialog, Ui_QRegExpWizardCharactersDialog): - """ - Class implementing a dialog for entering character classes. - """ - RegExpMode = 0 - WildcardMode = 1 - W3CMode = 2 - - def __init__(self, mode=RegExpMode, parent=None): - """ - Constructor - - @param mode mode of the dialog (one of RegExpMode, WildcardMode, - W3CMode) - @param parent parent widget (QWidget) - """ - super(QRegExpWizardCharactersDialog, self).__init__(parent) - self.setupUi(self) - - self.__mode = mode - - if mode == QRegExpWizardCharactersDialog.WildcardMode: - self.predefinedBox.setEnabled(False) - self.predefinedBox.hide() - elif mode == QRegExpWizardCharactersDialog.RegExpMode: - self.w3cInitialIdentifierCheckBox.hide() - self.w3cNonInitialIdentifierCheckBox.hide() - self.w3cNmtokenCheckBox.hide() - self.w3cNonNmtokenCheckBox.hide() - elif mode == QRegExpWizardCharactersDialog.W3CMode: - self.__initCharacterSelectors() - - self.comboItems = [] - self.singleComboItems = [] # these are in addition to the above - self.comboItems.append((self.tr("Normal character"), "-c")) - if mode == QRegExpWizardCharactersDialog.RegExpMode: - self.comboItems.append((self.tr( - "Unicode character in hexadecimal notation"), "-h")) - self.comboItems.append((self.tr( - "ASCII/Latin1 character in octal notation"), "-o")) - self.singleComboItems.append(("---", "-i")) - self.singleComboItems.append( - (self.tr("Bell character (\\a)"), "\\a")) - self.singleComboItems.append( - (self.tr("Page break (\\f)"), "\\f")) - self.singleComboItems.append( - (self.tr("Line feed (\\n)"), "\\n")) - self.singleComboItems.append( - (self.tr("Carriage return (\\r)"), "\\r")) - self.singleComboItems.append( - (self.tr("Horizontal tabulator (\\t)"), "\\t")) - self.singleComboItems.append( - (self.tr("Vertical tabulator (\\v)"), "\\v")) - elif mode == QRegExpWizardCharactersDialog.W3CMode: - self.comboItems.append((self.tr( - "Unicode character in hexadecimal notation"), "-h")) - self.comboItems.append((self.tr( - "ASCII/Latin1 character in octal notation"), "-o")) - self.singleComboItems.append(("---", "-i")) - self.singleComboItems.append( - (self.tr("Line feed (\\n)"), "\\n")) - self.singleComboItems.append( - (self.tr("Carriage return (\\r)"), "\\r")) - self.singleComboItems.append( - (self.tr("Horizontal tabulator (\\t)"), "\\t")) - self.singleComboItems.append(("---", "-i")) - self.singleComboItems.append( - (self.tr("Character Category"), "-ccp")) - self.singleComboItems.append( - (self.tr("Character Block"), "-cbp")) - self.singleComboItems.append( - (self.tr("Not Character Category"), "-ccn")) - self.singleComboItems.append( - (self.tr("Not Character Block"), "-cbn")) - - self.charValidator = QRegExpValidator(QRegExp(".{0,1}"), self) - self.hexValidator = QRegExpValidator(QRegExp("[0-9a-fA-F]{0,4}"), self) - self.octValidator = QRegExpValidator(QRegExp("[0-3]?[0-7]{0,2}"), self) - - # generate dialog part for single characters - self.singlesBoxLayout = QVBoxLayout(self.singlesBox) - self.singlesBoxLayout.setObjectName("singlesBoxLayout") - self.singlesBoxLayout.setSpacing(6) - self.singlesBoxLayout.setContentsMargins(6, 6, 6, 6) - self.singlesBox.setLayout(self.singlesBoxLayout) - self.singlesView = QScrollArea(self.singlesBox) - self.singlesView.setObjectName("singlesView") - self.singlesBoxLayout.addWidget(self.singlesView) - - self.singlesItemsBox = QWidget(self) - self.singlesView.setWidget(self.singlesItemsBox) - self.singlesItemsBox.setObjectName("singlesItemsBox") - self.singlesItemsBox.setMinimumWidth(1000) - self.singlesItemsBoxLayout = QVBoxLayout(self.singlesItemsBox) - self.singlesItemsBoxLayout.setContentsMargins(6, 6, 6, 6) - self.singlesItemsBoxLayout.setSpacing(6) - self.singlesItemsBox.setLayout(self.singlesItemsBoxLayout) - self.singlesEntries = [] - self.__addSinglesLine() - - hlayout0 = QHBoxLayout() - hlayout0.setContentsMargins(0, 0, 0, 0) - hlayout0.setSpacing(6) - hlayout0.setObjectName("hlayout0") - self.moreSinglesButton = QPushButton( - self.tr("Additional Entries"), self.singlesBox) - self.moreSinglesButton.setObjectName("moreSinglesButton") - hlayout0.addWidget(self.moreSinglesButton) - hspacer0 = QSpacerItem( - 30, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - hlayout0.addItem(hspacer0) - self.singlesBoxLayout.addLayout(hlayout0) - self.moreSinglesButton.clicked.connect(self.__addSinglesLine) - - # generate dialog part for character ranges - self.rangesBoxLayout = QVBoxLayout(self.rangesBox) - self.rangesBoxLayout.setObjectName("rangesBoxLayout") - self.rangesBoxLayout.setSpacing(6) - self.rangesBoxLayout.setContentsMargins(6, 6, 6, 6) - self.rangesBox.setLayout(self.rangesBoxLayout) - self.rangesView = QScrollArea(self.rangesBox) - self.rangesView.setObjectName("rangesView") - self.rangesBoxLayout.addWidget(self.rangesView) - - self.rangesItemsBox = QWidget(self) - self.rangesView.setWidget(self.rangesItemsBox) - self.rangesItemsBox.setObjectName("rangesItemsBox") - self.rangesItemsBox.setMinimumWidth(1000) - self.rangesItemsBoxLayout = QVBoxLayout(self.rangesItemsBox) - self.rangesItemsBoxLayout.setContentsMargins(6, 6, 6, 6) - self.rangesItemsBoxLayout.setSpacing(6) - self.rangesItemsBox.setLayout(self.rangesItemsBoxLayout) - self.rangesEntries = [] - self.__addRangesLine() - - hlayout1 = QHBoxLayout() - hlayout1.setContentsMargins(0, 0, 0, 0) - hlayout1.setSpacing(6) - hlayout1.setObjectName("hlayout1") - self.moreRangesButton = QPushButton( - self.tr("Additional Entries"), self.rangesBox) - self.moreSinglesButton.setObjectName("moreRangesButton") - hlayout1.addWidget(self.moreRangesButton) - hspacer1 = QSpacerItem( - 30, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - hlayout1.addItem(hspacer1) - self.rangesBoxLayout.addLayout(hlayout1) - self.moreRangesButton.clicked.connect(self.__addRangesLine) - - def __initCharacterSelectors(self): - """ - Private method to initialize the W3C character selector entries. - """ - self.__characterCategories = ( - # display name code - (self.tr("Letter, Any"), "L"), - (self.tr("Letter, Uppercase"), "Lu"), - (self.tr("Letter, Lowercase"), "Ll"), - (self.tr("Letter, Titlecase"), "Lt"), - (self.tr("Letter, Modifier"), "Lm"), - (self.tr("Letter, Other"), "Lo"), - (self.tr("Mark, Any"), "M"), - (self.tr("Mark, Nonspacing"), "Mn"), - (self.tr("Mark, Spacing Combining"), "Mc"), - (self.tr("Mark, Enclosing"), "Me"), - (self.tr("Number, Any"), "N"), - (self.tr("Number, Decimal Digit"), "Nd"), - (self.tr("Number, Letter"), "Nl"), - (self.tr("Number, Other"), "No"), - (self.tr("Punctuation, Any"), "P"), - (self.tr("Punctuation, Connector"), "Pc"), - (self.tr("Punctuation, Dash"), "Pd"), - (self.tr("Punctuation, Open"), "Ps"), - (self.tr("Punctuation, Close"), "Pe"), - (self.tr("Punctuation, Initial Quote"), "Pi"), - (self.tr("Punctuation, Final Quote"), "Pf"), - (self.tr("Punctuation, Other"), "Po"), - (self.tr("Symbol, Any"), "S"), - (self.tr("Symbol, Math"), "Sm"), - (self.tr("Symbol, Currency"), "Sc"), - (self.tr("Symbol, Modifier"), "Sk"), - (self.tr("Symbol, Other"), "So"), - (self.tr("Separator, Any"), "Z"), - (self.tr("Separator, Space"), "Zs"), - (self.tr("Separator, Line"), "Zl"), - (self.tr("Separator, Paragraph"), "Zp"), - (self.tr("Other, Any"), "C"), - (self.tr("Other, Control"), "Cc"), - (self.tr("Other, Format"), "Cf"), - (self.tr("Other, Private Use"), "Co"), - (self.tr("Other, Not Assigned"), "Cn"), - ) - - self.__characterBlocks = ( - (self.tr("Basic Latin"), - "IsBasicLatin"), - (self.tr("Latin-1 Supplement"), - "IsLatin-1Supplement"), - (self.tr("Latin Extended-A"), - "IsLatinExtended-A"), - (self.tr("Latin Extended-B"), - "IsLatinExtended-B"), - (self.tr("IPA Extensions"), - "IsIPAExtensions"), - (self.tr("Spacing Modifier Letters"), - "IsSpacingModifierLetters"), - (self.tr("Combining Diacritical Marks"), - "IsCombiningDiacriticalMarks"), - (self.tr("Greek"), - "IsGreek"), - (self.tr("Cyrillic"), - "IsCyrillic"), - (self.tr("Armenian"), - "IsArmenian"), - (self.tr("Hebrew"), - "IsHebrew"), - (self.tr("Arabic"), - "IsArabic"), - (self.tr("Syriac"), - "IsSyriac"), - (self.tr("Thaana"), - "IsThaana"), - (self.tr("Devanagari"), - "IsDevanagari"), - (self.tr("Bengali"), - "IsBengali"), - (self.tr("Gurmukhi"), - "IsBengali"), - (self.tr("Gujarati"), - "IsGujarati"), - (self.tr("Oriya"), - "IsOriya"), - (self.tr("Tamil"), - "IsTamil"), - (self.tr("Telugu"), - "IsTelugu"), - (self.tr("Kannada"), - "IsKannada"), - (self.tr("Malayalam"), - "IsMalayalam"), - (self.tr("Sinhala"), - "IsSinhala"), - (self.tr("Thai"), - "IsThai"), - (self.tr("Lao"), - "IsLao"), - (self.tr("Tibetan"), - "IsTibetan"), - (self.tr("Myanmar"), - "IsMyanmar"), - (self.tr("Georgian"), - "IsGeorgian"), - (self.tr("Hangul Jamo"), - "IsHangulJamo"), - (self.tr("Ethiopic"), - "IsEthiopic"), - (self.tr("Cherokee"), - "IsCherokee"), - (self.tr("Unified Canadian Aboriginal Syllabics"), - "IsUnifiedCanadianAboriginalSyllabics"), - (self.tr("Ogham"), - "IsOgham"), - (self.tr("Runic"), - "IsRunic"), - (self.tr("Khmer"), - "IsKhmer"), - (self.tr("Mongolian"), - "IsMongolian"), - (self.tr("Latin Extended Additional"), - "IsLatinExtendedAdditional"), - (self.tr("Greek Extended"), - "IsGreekExtended"), - (self.tr("General Punctuation"), - "IsGeneralPunctuation"), - (self.tr("Superscripts and Subscripts"), - "IsSuperscriptsandSubscripts"), - (self.tr("Currency Symbols"), - "IsCurrencySymbols"), - (self.tr("Combining Marks for Symbols"), - "IsCombiningMarksforSymbols"), - (self.tr("Letterlike Symbols"), - "IsLetterlikeSymbols"), - (self.tr("Number Forms"), - "IsNumberForms"), - (self.tr("Arrows"), - "IsArrows"), - (self.tr("Mathematical Operators"), - "IsMathematicalOperators"), - (self.tr("Miscellaneous Technical"), - "IsMiscellaneousTechnical"), - (self.tr("Control Pictures"), - "IsControlPictures"), - (self.tr("Optical Character Recognition"), - "IsOpticalCharacterRecognition"), - (self.tr("Enclosed Alphanumerics"), - "IsEnclosedAlphanumerics"), - (self.tr("Box Drawing"), - "IsBoxDrawing"), - (self.tr("Block Elements"), - "IsBlockElements"), - (self.tr("Geometric Shapes"), - "IsGeometricShapes"), - (self.tr("Miscellaneous Symbols"), - "IsMiscellaneousSymbols"), - (self.tr("Dingbats"), - "IsDingbats"), - (self.tr("Braille Patterns"), - "IsBraillePatterns"), - (self.tr("CJK Radicals Supplement"), - "IsCJKRadicalsSupplement"), - (self.tr("KangXi Radicals"), - "IsKangXiRadicals"), - (self.tr("Ideographic Description Chars"), - "IsIdeographicDescriptionChars"), - (self.tr("CJK Symbols and Punctuation"), - "IsCJKSymbolsandPunctuation"), - (self.tr("Hiragana"), - "IsHiragana"), - (self.tr("Katakana"), - "IsKatakana"), - (self.tr("Bopomofo"), - "IsBopomofo"), - (self.tr("Hangul Compatibility Jamo"), - "IsHangulCompatibilityJamo"), - (self.tr("Kanbun"), - "IsKanbun"), - (self.tr("Bopomofo Extended"), - "IsBopomofoExtended"), - (self.tr("Enclosed CJK Letters and Months"), - "IsEnclosedCJKLettersandMonths"), - (self.tr("CJK Compatibility"), - "IsCJKCompatibility"), - (self.tr("CJK Unified Ideographs Extension A"), - "IsCJKUnifiedIdeographsExtensionA"), - (self.tr("CJK Unified Ideographs"), - "IsCJKUnifiedIdeographs"), - (self.tr("Yi Syllables"), - "IsYiSyllables"), - (self.tr("Yi Radicals"), - "IsYiRadicals"), - (self.tr("Hangul Syllables"), - "IsHangulSyllables"), - (self.tr("Private Use"), - "IsPrivateUse"), - (self.tr("CJK Compatibility Ideographs"), - "IsCJKCompatibilityIdeographs"), - (self.tr("Alphabetic Presentation Forms"), - "IsAlphabeticPresentationForms"), - (self.tr("Arabic Presentation Forms-A"), - "IsArabicPresentationForms-A"), - (self.tr("Combining Half Marks"), - "IsCombiningHalfMarks"), - (self.tr("CJK Compatibility Forms"), - "IsCJKCompatibilityForms"), - (self.tr("Small Form Variants"), - "IsSmallFormVariants"), - (self.tr("Arabic Presentation Forms-B"), - "IsArabicPresentationForms-B"), - (self.tr("Halfwidth and Fullwidth Forms"), - "IsHalfwidthandFullwidthForms"), - (self.tr("Specials"), - "IsSpecials"), - (self.tr("Old Italic"), - "IsOldItalic"), - (self.tr("Gothic"), - "IsGothic"), - (self.tr("Deseret"), - "IsDeseret"), - (self.tr("Byzantine Musical Symbols"), - "IsByzantineMusicalSymbols"), - (self.tr("Musical Symbols"), - "IsMusicalSymbols"), - (self.tr("Mathematical Alphanumeric Symbols"), - "IsMathematicalAlphanumericSymbols"), - (self.tr("CJK Unified Ideographic Extension B"), - "IsCJKUnifiedIdeographicExtensionB"), - (self.tr("CJK Compatapility Ideographic Supplement"), - "IsCJKCompatapilityIdeographicSupplement"), - (self.tr("Tags"), - "IsTags"), - ) - - def __populateCharTypeCombo(self, combo, isSingle): - """ - Private method to populate a given character type selection combo box. - - @param combo reference to the combo box to be populated (QComboBox) - @param isSingle flag indicating a singles combo (boolean) - """ - for txt, value in self.comboItems: - combo.addItem(txt, value) - if isSingle: - for txt, value in self.singleComboItems: - combo.addItem(txt, value) - - def __addSinglesLine(self): - """ - Private slot to add a line of entry widgets for single characters. - """ - hbox = QWidget(self.singlesItemsBox) - hboxLayout = QHBoxLayout(hbox) - hboxLayout.setContentsMargins(0, 0, 0, 0) - hboxLayout.setSpacing(6) - hbox.setLayout(hboxLayout) - cb1 = QComboBox(hbox) - cb1.setEditable(False) - self.__populateCharTypeCombo(cb1, True) - hboxLayout.addWidget(cb1) - le1 = QLineEdit(hbox) - le1.setValidator(self.charValidator) - hboxLayout.addWidget(le1) - cb1a = QComboBox(hbox) - cb1a.setEditable(False) - cb1a.setSizeAdjustPolicy(QComboBox.AdjustToContents) - hboxLayout.addWidget(cb1a) - cb1a.hide() - cb2 = QComboBox(hbox) - cb2.setEditable(False) - self.__populateCharTypeCombo(cb2, True) - hboxLayout.addWidget(cb2) - le2 = QLineEdit(hbox) - le2.setValidator(self.charValidator) - hboxLayout.addWidget(le2) - cb2a = QComboBox(hbox) - cb2a.setEditable(False) - cb2a.setSizeAdjustPolicy(QComboBox.AdjustToContents) - hboxLayout.addWidget(cb2a) - cb2a.hide() - self.singlesItemsBoxLayout.addWidget(hbox) - - cb1.activated[int].connect( - lambda i: self.__singlesCharTypeSelected(i, cb1)) - cb2.activated[int].connect( - lambda i: self.__singlesCharTypeSelected(i, cb2)) - hbox.show() - - self.singlesItemsBox.adjustSize() - - self.singlesEntries.append([cb1, le1, cb1a]) - self.singlesEntries.append([cb2, le2, cb2a]) - - def __addRangesLine(self): - """ - Private slot to add a line of entry widgets for character ranges. - """ - hbox = QWidget(self.rangesItemsBox) - hboxLayout = QHBoxLayout(hbox) - hboxLayout.setContentsMargins(0, 0, 0, 0) - hboxLayout.setSpacing(6) - hbox.setLayout(hboxLayout) - cb1 = QComboBox(hbox) - cb1.setEditable(False) - self.__populateCharTypeCombo(cb1, False) - hboxLayout.addWidget(cb1) - l1 = QLabel(self.tr("Between:"), hbox) - hboxLayout.addWidget(l1) - le1 = QLineEdit(hbox) - le1.setValidator(self.charValidator) - hboxLayout.addWidget(le1) - l2 = QLabel(self.tr("And:"), hbox) - hboxLayout.addWidget(l2) - le2 = QLineEdit(hbox) - le2.setValidator(self.charValidator) - hboxLayout.addWidget(le2) - self.rangesItemsBoxLayout.addWidget(hbox) - - cb1.activated[int].connect( - lambda i: self.__rangesCharTypeSelected(i, cb1)) - - hbox.show() - - self.rangesItemsBox.adjustSize() - - self.rangesEntries.append([cb1, le1, le2]) - - def __populateW3cCharacterCombo(self, combo, formatIdentifier): - """ - Private method to populate a W3C character selection combo. - - @param combo combo box to be populated (QComboBox) - @param formatIdentifier format identifier (one of "-ccp", "-ccn", - "-cbp", "-cbn") - """ - combo.clear() - - if formatIdentifier in ["-ccp", "-ccn"]: - comboLen = 0 - for txt, code in self.__characterCategories: - combo.addItem(txt, code) - comboLen = max(comboLen, len(txt)) - combo.setMinimumContentsLength(comboLen) - elif formatIdentifier in ["-cbp", "-cbn"]: - comboLen = 0 - for txt, code in self.__characterBlocks: - combo.addItem(txt, code) - comboLen = max(comboLen, len(txt)) - combo.setMinimumContentsLength(comboLen) - - def __performSelectedAction(self, formatIdentifier, lineedit, combo): - """ - Private method performing some actions depending on the input. - - @param formatIdentifier format of the selected entry (string) - @param lineedit line edit widget to act on (QLineEdit) - @param combo combo box widget to act on (QComboBox) - """ - if formatIdentifier == "-i": - return - - if formatIdentifier in ["-c", "-h", "-o"]: - lineedit.show() - lineedit.setEnabled(True) - if combo is not None: - combo.hide() - if formatIdentifier == "-c": - lineedit.setValidator(self.charValidator) - elif formatIdentifier == "-h": - lineedit.setValidator(self.hexValidator) - elif formatIdentifier == "-o": - lineedit.setValidator(self.octValidator) - elif formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn"]: - lineedit.setEnabled(False) - lineedit.hide() - if combo is not None: - combo.show() - self.__populateW3cCharacterCombo(combo, formatIdentifier) - else: - lineedit.setEnabled(False) - lineedit.hide() - if combo is not None: - combo.hide() - lineedit.clear() - - def __singlesCharTypeSelected(self, index, combo): - """ - Private slot to handle the activated(int) signal of the single chars - combo boxes. - - @param index selected list index - @type int - @param combo reference to the combo box - @type QComboBox - """ - for entriesList in self.singlesEntries: - if combo == entriesList[0]: - formatIdentifier = combo.itemData(index) - self.__performSelectedAction( - formatIdentifier, entriesList[1], entriesList[2]) - break - - def __rangesCharTypeSelected(self, index, combo): - """ - Private slot to handle the activated(int) signal of the char ranges - combo boxes. - - @param index selected list index - @type int - @param combo reference to the combo box - @type QComboBox - """ - for entriesList in self.rangesEntries: - if combo == entriesList[0]: - formatIdentifier = combo.itemData(index) - self.__performSelectedAction(formatIdentifier, entriesList[1], - None) - self.__performSelectedAction(formatIdentifier, entriesList[2], - None) - break - - def __formatCharacter(self, char, formatIdentifier): - """ - Private method to format the characters entered into the dialog. - - @param char character string entered into the dialog (string) - @param formatIdentifier string giving a special format (-c, -h, -i or - -o) or the already formatted character (string) - @return formatted character string (string) - """ - if formatIdentifier == "-c": - return char - elif formatIdentifier == "-i": - return "" - - if self.__mode in [QRegExpWizardCharactersDialog.RegExpMode, - QRegExpWizardCharactersDialog.W3CMode]: - if formatIdentifier == "-h": - return "\\x{0}".format(char.lower()) - elif formatIdentifier == "-o": - return "\\0{0}".format(char) - elif formatIdentifier in ["-ccp", "-cbp"]: - return "\\p{{{0}}}".format(char) - elif formatIdentifier in ["-ccn", "-cbn"]: - return "\\P{{{0}}}".format(char) - else: - return formatIdentifier - - return "" - - def getCharacters(self): - """ - Public method to return the character string assembled via the dialog. - - @return formatted string for character classes (string) - """ - regexp = "" - - # negative character range - if self.negativeCheckBox.isChecked(): - regexp += "^" - - # predefined character ranges - if self.wordCharCheckBox.isChecked(): - regexp += "\\w" - if self.nonWordCharCheckBox.isChecked(): - regexp += "\\W" - if self.digitsCheckBox.isChecked(): - regexp += "\\d" - if self.nonDigitsCheckBox.isChecked(): - regexp += "\\D" - if self.whitespaceCheckBox.isChecked(): - regexp += "\\s" - if self.nonWhitespaceCheckBox.isChecked(): - regexp += "\\S" - if self.w3cInitialIdentifierCheckBox.isChecked(): - regexp += "\\i" - if self.w3cNonInitialIdentifierCheckBox.isChecked(): - regexp += "\\I" - if self.w3cNmtokenCheckBox.isChecked(): - regexp += "\\c" - if self.w3cNonNmtokenCheckBox.isChecked(): - regexp += "\\C" - - # single characters - for entrieslist in self.singlesEntries: - formatIdentifier = entrieslist[0].itemData( - entrieslist[0].currentIndex()) - if formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn"]: - char = entrieslist[2].itemData(entrieslist[2].currentIndex()) - else: - char = entrieslist[1].text() - regexp += self.__formatCharacter(char, formatIdentifier) - - # character ranges - for entrieslist in self.rangesEntries: - if ( - not entrieslist[1].text() or - not entrieslist[2].text() - ): - continue - formatIdentifier = entrieslist[0].itemData( - entrieslist[0].currentIndex()) - char1 = entrieslist[1].text() - char2 = entrieslist[2].text() - regexp += "{0}-{1}".format( - self.__formatCharacter(char1, formatIdentifier), - self.__formatCharacter(char2, formatIdentifier)) - - if regexp: - if ( - (regexp.startswith("\\") and - regexp.count("\\") == 1 and - "-" not in regexp) or - len(regexp) == 1 - ): - return regexp - else: - return "[{0}]".format(regexp) - else: - return ""
--- a/eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.ui Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>QRegExpWizardCharactersDialog</class> - <widget class="QDialog" name="QRegExpWizardCharactersDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>850</width> - <height>500</height> - </rect> - </property> - <property name="windowTitle"> - <string>Editor for character sets</string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QCheckBox" name="negativeCheckBox"> - <property name="text"> - <string>The defined characters should not match</string> - </property> - </widget> - </item> - <item> - <widget class="QGroupBox" name="predefinedBox"> - <property name="title"> - <string>Predefined character ranges</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QCheckBox" name="wordCharCheckBox"> - <property name="text"> - <string>Word character</string> - </property> - </widget> - </item> - <item row="0" column="1" rowspan="2"> - <widget class="QCheckBox" name="digitsCheckBox"> - <property name="text"> - <string>Digits</string> - </property> - </widget> - </item> - <item row="0" column="2" rowspan="2"> - <widget class="QCheckBox" name="whitespaceCheckBox"> - <property name="text"> - <string>Whitespace characters</string> - </property> - </widget> - </item> - <item row="1" column="0" rowspan="2"> - <widget class="QCheckBox" name="nonWordCharCheckBox"> - <property name="text"> - <string>Non-word characters</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="nonDigitsCheckBox"> - <property name="text"> - <string>Non-digits</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QCheckBox" name="nonWhitespaceCheckBox"> - <property name="text"> - <string>Non-whitespace characters</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="w3cInitialIdentifierCheckBox"> - <property name="text"> - <string>Initial name character</string> - </property> - </widget> - </item> - <item row="3" column="1" colspan="2"> - <widget class="QCheckBox" name="w3cNmtokenCheckBox"> - <property name="text"> - <string>Name character</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QCheckBox" name="w3cNonInitialIdentifierCheckBox"> - <property name="text"> - <string>Non-initial name character</string> - </property> - </widget> - </item> - <item row="4" column="1" colspan="2"> - <widget class="QCheckBox" name="w3cNonNmtokenCheckBox"> - <property name="text"> - <string>Non-name character</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="singlesBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Single character</string> - </property> - </widget> - </item> - <item> - <widget class="QGroupBox" name="rangesBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Character ranges</string> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <tabstops> - <tabstop>negativeCheckBox</tabstop> - <tabstop>wordCharCheckBox</tabstop> - <tabstop>nonWordCharCheckBox</tabstop> - <tabstop>digitsCheckBox</tabstop> - <tabstop>nonDigitsCheckBox</tabstop> - <tabstop>whitespaceCheckBox</tabstop> - <tabstop>nonWhitespaceCheckBox</tabstop> - <tabstop>w3cInitialIdentifierCheckBox</tabstop> - <tabstop>w3cNonInitialIdentifierCheckBox</tabstop> - <tabstop>w3cNmtokenCheckBox</tabstop> - <tabstop>w3cNonNmtokenCheckBox</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>QRegExpWizardCharactersDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>80</x> - <y>482</y> - </hint> - <hint type="destinationlabel"> - <x>80</x> - <y>499</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>QRegExpWizardCharactersDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>229</x> - <y>480</y> - </hint> - <hint type="destinationlabel"> - <x>229</x> - <y>498</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,722 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2004 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing the QRegExp wizard dialog. -""" - - -import os - -from PyQt5.QtCore import QFileInfo, QRegExp, Qt, pyqtSlot -from PyQt5.QtGui import QClipboard, QTextCursor -from PyQt5.QtWidgets import ( - QWidget, QDialog, QApplication, QDialogButtonBox, QVBoxLayout, - QTableWidgetItem -) - -from E5Gui import E5MessageBox, E5FileDialog -from E5Gui.E5MainWindow import E5MainWindow - -from .Ui_QRegExpWizardDialog import Ui_QRegExpWizardWidget - -import UI.PixmapCache - -import Utilities -import Preferences - - -class QRegExpWizardWidget(QWidget, Ui_QRegExpWizardWidget): - """ - Class implementing the QRegExp wizard dialog. - """ - def __init__(self, parent=None, fromEric=True): - """ - Constructor - - @param parent parent widget (QWidget) - @param fromEric flag indicating a call from within eric6 - """ - super(QRegExpWizardWidget, self).__init__(parent) - self.setupUi(self) - - # initialize icons of the tool buttons - # regexp tool buttons - self.charButton.setIcon(UI.PixmapCache.getIcon("characters")) - self.anycharButton.setIcon(UI.PixmapCache.getIcon("anychar")) - self.repeatButton.setIcon(UI.PixmapCache.getIcon("repeat")) - self.nonGroupButton.setIcon(UI.PixmapCache.getIcon("nongroup")) - self.groupButton.setIcon(UI.PixmapCache.getIcon("group")) - self.altnButton.setIcon(UI.PixmapCache.getIcon("altn")) - self.beglineButton.setIcon(UI.PixmapCache.getIcon("begline")) - self.endlineButton.setIcon(UI.PixmapCache.getIcon("endline")) - self.wordboundButton.setIcon( - UI.PixmapCache.getIcon("wordboundary")) - self.nonwordboundButton.setIcon( - UI.PixmapCache.getIcon("nonwordboundary")) - self.poslookaheadButton.setIcon( - UI.PixmapCache.getIcon("poslookahead")) - self.neglookaheadButton.setIcon( - UI.PixmapCache.getIcon("neglookahead")) - self.undoButton.setIcon(UI.PixmapCache.getIcon("editUndo")) - self.redoButton.setIcon(UI.PixmapCache.getIcon("editRedo")) - # wildcard tool buttons - self.wildcardCharButton.setIcon( - UI.PixmapCache.getIcon("characters")) - self.wildcardAnycharButton.setIcon( - UI.PixmapCache.getIcon("anychar")) - self.wildcardRepeatButton.setIcon(UI.PixmapCache.getIcon("repeat")) - # W3C tool buttons - self.w3cCharButton.setIcon(UI.PixmapCache.getIcon("characters")) - self.w3cAnycharButton.setIcon(UI.PixmapCache.getIcon("anychar")) - self.w3cRepeatButton.setIcon(UI.PixmapCache.getIcon("repeat")) - self.w3cGroupButton.setIcon(UI.PixmapCache.getIcon("group")) - self.w3cAltnButton.setIcon(UI.PixmapCache.getIcon("altn")) - - # initialize the syntax pattern combo - self.syntaxCombo.addItem("RegExp", QRegExp.RegExp) - self.syntaxCombo.addItem("RegExp2", QRegExp.RegExp2) - self.syntaxCombo.addItem("Wildcard", QRegExp.Wildcard) - self.syntaxCombo.addItem("Unix Wildcard", QRegExp.WildcardUnix) - self.syntaxCombo.addItem("Fixed String", QRegExp.FixedString) - self.syntaxCombo.addItem("W3C XML Schema 1.1", QRegExp.W3CXmlSchema11) - self.syntaxCombo.setCurrentIndex(1) - - self.saveButton = self.buttonBox.addButton( - self.tr("Save"), QDialogButtonBox.ActionRole) - self.saveButton.setToolTip( - self.tr("Save the regular expression to a file")) - self.loadButton = self.buttonBox.addButton( - self.tr("Load"), QDialogButtonBox.ActionRole) - self.loadButton.setToolTip( - self.tr("Load a regular expression from a file")) - self.validateButton = self.buttonBox.addButton( - self.tr("Validate"), QDialogButtonBox.ActionRole) - self.validateButton.setToolTip( - self.tr("Validate the regular expression")) - self.executeButton = self.buttonBox.addButton( - self.tr("Execute"), QDialogButtonBox.ActionRole) - self.executeButton.setToolTip( - self.tr("Execute the regular expression")) - self.nextButton = self.buttonBox.addButton( - self.tr("Next match"), QDialogButtonBox.ActionRole) - self.nextButton.setToolTip( - self.tr("Show the next match of the regular expression")) - self.nextButton.setEnabled(False) - - if fromEric: - self.buttonBox.setStandardButtons( - QDialogButtonBox.Cancel | QDialogButtonBox.Ok) - self.copyButton = None - else: - self.copyButton = self.buttonBox.addButton( - self.tr("Copy"), QDialogButtonBox.ActionRole) - self.copyButton.setToolTip( - self.tr("Copy the regular expression to the clipboard")) - self.buttonBox.setStandardButtons(QDialogButtonBox.Close) - self.variableLabel.hide() - self.variableLineEdit.hide() - self.variableLine.hide() - self.regexpLineEdit.setFocus() - - @pyqtSlot(int) - def on_syntaxCombo_currentIndexChanged(self, index): - """ - Private slot handling the selection of a pattern syntax. - - @param index index of the selected entry (integer) - """ - syntax = self.syntaxCombo.itemData(index) - self.regexpButtonsFrame.setVisible(syntax in [ - QRegExp.RegExp, QRegExp.RegExp2]) - self.regexpButtonsFrame.setEnabled(syntax in [ - QRegExp.RegExp, QRegExp.RegExp2]) - self.wildcardButtonsFrame.setVisible(syntax in [ - QRegExp.Wildcard, QRegExp.WildcardUnix]) - self.wildcardButtonsFrame.setEnabled(syntax in [ - QRegExp.Wildcard, QRegExp.WildcardUnix]) - self.w3cButtonsFrame.setVisible(syntax in [QRegExp.W3CXmlSchema11]) - self.w3cButtonsFrame.setEnabled(syntax in [QRegExp.W3CXmlSchema11]) - - def __insertString(self, s, steps=0): - """ - Private method to insert a string into line edit and move cursor. - - @param s string to be inserted into the regexp line edit - (string) - @param steps number of characters to move the cursor (integer). - Negative steps moves cursor back, positives forward. - """ - self.regexpLineEdit.insert(s) - self.regexpLineEdit.cursorForward(False, steps) - - @pyqtSlot() - def on_anycharButton_clicked(self): - """ - Private slot to handle the any character toolbutton. - """ - self.__insertString(".") - - @pyqtSlot() - def on_nonGroupButton_clicked(self): - """ - Private slot to handle the non group toolbutton. - """ - self.__insertString("(?:)", -1) - - @pyqtSlot() - def on_groupButton_clicked(self): - """ - Private slot to handle the group toolbutton. - """ - self.__insertString("()", -1) - - @pyqtSlot() - def on_altnButton_clicked(self): - """ - Private slot to handle the alternatives toolbutton. - """ - self.__insertString("(|)", -2) - - @pyqtSlot() - def on_beglineButton_clicked(self): - """ - Private slot to handle the begin line toolbutton. - """ - self.__insertString("^") - - @pyqtSlot() - def on_endlineButton_clicked(self): - """ - Private slot to handle the end line toolbutton. - """ - self.__insertString("$") - - @pyqtSlot() - def on_wordboundButton_clicked(self): - """ - Private slot to handle the word boundary toolbutton. - """ - self.__insertString("\\b") - - @pyqtSlot() - def on_nonwordboundButton_clicked(self): - """ - Private slot to handle the non word boundary toolbutton. - """ - self.__insertString("\\B") - - @pyqtSlot() - def on_poslookaheadButton_clicked(self): - """ - Private slot to handle the positive lookahead toolbutton. - """ - self.__insertString("(?=)", -1) - - @pyqtSlot() - def on_neglookaheadButton_clicked(self): - """ - Private slot to handle the negative lookahead toolbutton. - """ - self.__insertString("(?!)", -1) - - @pyqtSlot() - def on_repeatButton_clicked(self): - """ - Private slot to handle the repeat toolbutton. - """ - from .QRegExpWizardRepeatDialog import QRegExpWizardRepeatDialog - dlg = QRegExpWizardRepeatDialog(self) - if dlg.exec() == QDialog.Accepted: - self.__insertString(dlg.getRepeat()) - - @pyqtSlot() - def on_charButton_clicked(self): - """ - Private slot to handle the characters toolbutton. - """ - from .QRegExpWizardCharactersDialog import ( - QRegExpWizardCharactersDialog - ) - dlg = QRegExpWizardCharactersDialog( - mode=QRegExpWizardCharactersDialog.RegExpMode, parent=self) - if dlg.exec() == QDialog.Accepted: - self.__insertString(dlg.getCharacters()) - - @pyqtSlot() - def on_wildcardCharButton_clicked(self): - """ - Private slot to handle the wildcard characters toolbutton. - """ - from .QRegExpWizardCharactersDialog import ( - QRegExpWizardCharactersDialog - ) - dlg = QRegExpWizardCharactersDialog( - mode=QRegExpWizardCharactersDialog.WildcardMode, parent=self) - if dlg.exec() == QDialog.Accepted: - self.__insertString(dlg.getCharacters()) - - @pyqtSlot() - def on_wildcardAnycharButton_clicked(self): - """ - Private slot to handle the wildcard any character toolbutton. - """ - self.__insertString("?") - - @pyqtSlot() - def on_wildcardRepeatButton_clicked(self): - """ - Private slot to handle the wildcard multiple characters toolbutton. - """ - self.__insertString("*") - - @pyqtSlot() - def on_w3cCharButton_clicked(self): - """ - Private slot to handle the wildcard characters toolbutton. - """ - from .QRegExpWizardCharactersDialog import ( - QRegExpWizardCharactersDialog - ) - dlg = QRegExpWizardCharactersDialog( - mode=QRegExpWizardCharactersDialog.W3CMode, parent=self) - if dlg.exec() == QDialog.Accepted: - self.__insertString(dlg.getCharacters()) - - @pyqtSlot() - def on_w3cAnycharButton_clicked(self): - """ - Private slot to handle the W3C any character toolbutton. - """ - self.__insertString(".") - - @pyqtSlot() - def on_w3cRepeatButton_clicked(self): - """ - Private slot to handle the W3C repeat toolbutton. - """ - from .QRegExpWizardRepeatDialog import QRegExpWizardRepeatDialog - dlg = QRegExpWizardRepeatDialog(self) - if dlg.exec() == QDialog.Accepted: - self.__insertString(dlg.getRepeat()) - - @pyqtSlot() - def on_w3cGroupButton_clicked(self): - """ - Private slot to handle the W3C group toolbutton. - """ - self.__insertString("()", -1) - - @pyqtSlot() - def on_w3cAltnButton_clicked(self): - """ - Private slot to handle the alternatives toolbutton. - """ - self.__insertString("(|)", -2) - - def on_buttonBox_clicked(self, button): - """ - Private slot called by a button of the button box clicked. - - @param button button that was clicked (QAbstractButton) - """ - if button == self.validateButton: - self.on_validateButton_clicked() - elif button == self.executeButton: - self.on_executeButton_clicked() - elif button == self.saveButton: - self.on_saveButton_clicked() - elif button == self.loadButton: - self.on_loadButton_clicked() - elif button == self.nextButton: - self.on_nextButton_clicked() - elif self.copyButton and button == self.copyButton: - self.on_copyButton_clicked() - - @pyqtSlot() - def on_saveButton_clicked(self): - """ - Private slot to save the regexp to a file. - """ - fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( - self, - self.tr("Save regular expression"), - "", - self.tr("RegExp Files (*.rx);;All Files (*)"), - None, - E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) - if fname: - ext = QFileInfo(fname).suffix() - if not ext: - ex = selectedFilter.split("(*")[1].split(")")[0] - if ex: - fname += ex - if QFileInfo(fname).exists(): - res = E5MessageBox.yesNo( - self, - self.tr("Save regular expression"), - self.tr("<p>The file <b>{0}</b> already exists." - " Overwrite it?</p>").format(fname), - icon=E5MessageBox.Warning) - if not res: - return - - syntax = self.syntaxCombo.itemData(self.syntaxCombo.currentIndex()) - try: - f = open( - Utilities.toNativeSeparators(fname), "w", encoding="utf-8") - f.write("syntax={0}\n".format(syntax)) - f.write(self.regexpLineEdit.text()) - f.close() - except IOError as err: - E5MessageBox.information( - self, - self.tr("Save regular expression"), - self.tr("""<p>The regular expression could not""" - """ be saved.</p><p>Reason: {0}</p>""") - .format(str(err))) - - @pyqtSlot() - def on_loadButton_clicked(self): - """ - Private slot to load a regexp from a file. - """ - fname = E5FileDialog.getOpenFileName( - self, - self.tr("Load regular expression"), - "", - self.tr("RegExp Files (*.rx);;All Files (*)")) - if fname: - try: - f = open( - Utilities.toNativeSeparators(fname), "r", encoding="utf-8") - regexp = f.read() - f.close() - if regexp.startswith("syntax="): - lines = regexp.splitlines() - syntax = int(lines[0].replace("syntax=", "")) - index = self.syntaxCombo.findData(syntax) - self.syntaxCombo.setCurrentIndex(index) - regexp = lines[1] - self.regexpLineEdit.setText(regexp) - except IOError as err: - E5MessageBox.information( - self, - self.tr("Save regular expression"), - self.tr("""<p>The regular expression could not""" - """ be saved.</p><p>Reason: {0}</p>""") - .format(str(err))) - - @pyqtSlot() - def on_copyButton_clicked(self): - """ - Private slot to copy the regexp string into the clipboard. - - This slot is only available, if not called from within eric6. - """ - escaped = self.regexpLineEdit.text() - if escaped: - escaped = escaped.replace("\\", "\\\\") - cb = QApplication.clipboard() - cb.setText(escaped, QClipboard.Clipboard) - if cb.supportsSelection(): - cb.setText(escaped, QClipboard.Selection) - - @pyqtSlot() - def on_validateButton_clicked(self): - """ - Private slot to validate the entered regexp. - """ - regex = self.regexpLineEdit.text() - if regex: - re = QRegExp(regex) - if self.caseSensitiveCheckBox.isChecked(): - re.setCaseSensitivity(Qt.CaseSensitive) - else: - re.setCaseSensitivity(Qt.CaseInsensitive) - re.setMinimal(self.minimalCheckBox.isChecked()) - re.setPatternSyntax( - self.syntaxCombo.itemData(self.syntaxCombo.currentIndex())) - if re.isValid(): - E5MessageBox.information( - self, - self.tr("Validation"), - self.tr("""The regular expression is valid.""")) - else: - E5MessageBox.critical( - self, - self.tr("Error"), - self.tr("""Invalid regular expression: {0}""") - .format(re.errorString())) - return - else: - E5MessageBox.critical( - self, - self.tr("Error"), - self.tr("""A regular expression must be given.""")) - - @pyqtSlot() - def on_executeButton_clicked(self, startpos=0): - """ - Private slot to execute the entered regexp on the test text. - - This slot will execute the entered regexp on the entered test - data and will display the result in the table part of the dialog. - - @param startpos starting position for the regexp matching - """ - regex = self.regexpLineEdit.text() - text = self.textTextEdit.toPlainText() - if regex and text: - re = QRegExp(regex) - if self.caseSensitiveCheckBox.isChecked(): - re.setCaseSensitivity(Qt.CaseSensitive) - else: - re.setCaseSensitivity(Qt.CaseInsensitive) - re.setMinimal(self.minimalCheckBox.isChecked()) - syntax = self.syntaxCombo.itemData(self.syntaxCombo.currentIndex()) - wildcard = syntax in [QRegExp.Wildcard, QRegExp.WildcardUnix] - re.setPatternSyntax(syntax) - if not re.isValid(): - E5MessageBox.critical( - self, - self.tr("Error"), - self.tr("""Invalid regular expression: {0}""") - .format(re.errorString())) - return - offset = re.indexIn(text, startpos) - captures = re.captureCount() - row = 0 - OFFSET = 5 - - self.resultTable.setColumnCount(0) - self.resultTable.setColumnCount(3) - self.resultTable.setRowCount(0) - self.resultTable.setRowCount(OFFSET) - self.resultTable.setItem( - row, 0, QTableWidgetItem(self.tr("Regexp"))) - self.resultTable.setItem(row, 1, QTableWidgetItem(regex)) - - if offset != -1: - self.lastMatchEnd = offset + re.matchedLength() - self.nextButton.setEnabled(True) - row += 1 - self.resultTable.setItem( - row, 0, QTableWidgetItem(self.tr("Offset"))) - self.resultTable.setItem( - row, 1, QTableWidgetItem("{0:d}".format(offset))) - - if not wildcard: - row += 1 - self.resultTable.setItem( - row, 0, QTableWidgetItem(self.tr("Captures"))) - self.resultTable.setItem( - row, 1, QTableWidgetItem("{0:d}".format(captures))) - row += 1 - self.resultTable.setItem( - row, 1, QTableWidgetItem(self.tr("Text"))) - self.resultTable.setItem( - row, 2, QTableWidgetItem(self.tr("Characters"))) - - row += 1 - self.resultTable.setItem( - row, 0, QTableWidgetItem(self.tr("Match"))) - self.resultTable.setItem( - row, 1, QTableWidgetItem(re.cap(0))) - self.resultTable.setItem( - row, 2, - QTableWidgetItem("{0:d}".format(re.matchedLength()))) - - if not wildcard: - for i in range(1, captures + 1): - if len(re.cap(i)) > 0: - row += 1 - self.resultTable.insertRow(row) - self.resultTable.setItem( - row, 0, - QTableWidgetItem( - self.tr("Capture #{0}").format(i))) - self.resultTable.setItem( - row, 1, - QTableWidgetItem(re.cap(i))) - self.resultTable.setItem( - row, 2, - QTableWidgetItem( - "{0:d}".format(len(re.cap(i))))) - else: - self.resultTable.setRowCount(3) - - # highlight the matched text - tc = self.textTextEdit.textCursor() - tc.setPosition(offset) - tc.setPosition(self.lastMatchEnd, QTextCursor.KeepAnchor) - self.textTextEdit.setTextCursor(tc) - else: - self.nextButton.setEnabled(False) - self.resultTable.setRowCount(2) - row += 1 - if startpos > 0: - self.resultTable.setItem( - row, 0, - QTableWidgetItem(self.tr("No more matches"))) - else: - self.resultTable.setItem( - row, 0, - QTableWidgetItem(self.tr("No matches"))) - - # remove the highlight - tc = self.textTextEdit.textCursor() - tc.setPosition(0) - self.textTextEdit.setTextCursor(tc) - - self.resultTable.resizeColumnsToContents() - self.resultTable.resizeRowsToContents() - self.resultTable.verticalHeader().hide() - self.resultTable.horizontalHeader().hide() - else: - E5MessageBox.critical( - self, - self.tr("Error"), - self.tr("""A regular expression and a text must""" - """ be given.""")) - - @pyqtSlot() - def on_nextButton_clicked(self): - """ - Private slot to find the next match. - """ - self.on_executeButton_clicked(self.lastMatchEnd) - - def on_regexpLineEdit_textChanged(self, txt): - """ - Private slot called when the regexp changes. - - @param txt the new text of the line edit (string) - """ - self.nextButton.setEnabled(False) - - def __getPatternSyntaxCode(self, syntaxValue): - """ - Private method to convert a pattern syntax value into a - pattern syntax string. - - @param syntaxValue pattern syntax value (integer) - @return pattern syntax string (string) - """ - syntax = "QRegExp." - if syntaxValue == QRegExp.RegExp: - syntax += "RegExp" - elif syntaxValue == QRegExp.RegExp2: - syntax += "RegExp2" - elif syntaxValue == QRegExp.Wildcard: - syntax += "Wildcard" - elif syntaxValue == QRegExp.WildcardUnix: - syntax += "WildcardUnix" - elif syntaxValue == QRegExp.FixedString: - syntax += "FixedString" - elif syntaxValue == QRegExp.W3CXmlSchema11: - syntax += "W3CXmlSchema11" - return syntax - - def getCode(self, indLevel, indString): - """ - Public method to get the source code. - - @param indLevel indentation level (int) - @param indString string used for indentation (space or tab) (string) - @return generated code (string) - """ - # calculate the indentation string - istring = indLevel * indString - estring = os.linesep + indLevel * indString - - # now generate the code - reVar = self.variableLineEdit.text() - if not reVar: - reVar = "regexp" - - regexp = self.regexpLineEdit.text() - - code = '{0} = QRegExp(r"""{1}"""){2}'.format( - reVar, regexp.replace('"', '\\"'), os.linesep) - if not self.caseSensitiveCheckBox.isChecked(): - code += '{0}{1}.setCaseSensitivity(Qt.CaseInsensitive){2}'.format( - istring, reVar, os.linesep) - if self.minimalCheckBox.isChecked(): - code += '{0}{1}.setMinimal(True){2}'.format( - istring, reVar, os.linesep) - syntax = self.syntaxCombo.itemData(self.syntaxCombo.currentIndex()) - needPatternSyntax = True - if syntax == QRegExp.RegExp2: - # default value selected - needPatternSyntax = False - if needPatternSyntax: - code += '{0}{1}.setPatternSyntax({2}){3}'.format( - istring, reVar, self.__getPatternSyntaxCode(syntax), - estring) - return code - - -class QRegExpWizardDialog(QDialog): - """ - Class for the dialog variant. - """ - def __init__(self, parent=None, fromEric=True): - """ - Constructor - - @param parent parent widget (QWidget) - @param fromEric flag indicating a call from within eric6 - """ - super(QRegExpWizardDialog, self).__init__(parent) - self.setModal(fromEric) - self.setSizeGripEnabled(True) - - self.__layout = QVBoxLayout(self) - self.__layout.setContentsMargins(0, 0, 0, 0) - self.setLayout(self.__layout) - - self.cw = QRegExpWizardWidget(self, fromEric) - size = self.cw.size() - self.__layout.addWidget(self.cw) - self.resize(size) - self.setWindowTitle(self.cw.windowTitle()) - - self.cw.buttonBox.accepted.connect(self.accept) - self.cw.buttonBox.rejected.connect(self.reject) - - def getCode(self, indLevel, indString): - """ - Public method to get the source code. - - @param indLevel indentation level (int) - @param indString string used for indentation (space or tab) (string) - @return generated code (string) - """ - return self.cw.getCode(indLevel, indString) - - -class QRegExpWizardWindow(E5MainWindow): - """ - Main window class for the standalone dialog. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super(QRegExpWizardWindow, self).__init__(parent) - self.cw = QRegExpWizardWidget(self, fromEric=False) - size = self.cw.size() - self.setCentralWidget(self.cw) - self.resize(size) - self.setWindowTitle(self.cw.windowTitle()) - - self.setStyle( - Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) - - self.cw.buttonBox.accepted.connect(self.close) - self.cw.buttonBox.rejected.connect(self.close)
--- a/eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardDialog.ui Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,621 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>QRegExpWizardWidget</class> - <widget class="QWidget" name="QRegExpWizardWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>749</width> - <height>600</height> - </rect> - </property> - <property name="windowTitle"> - <string>QRegExp Wizard</string> - </property> - <property name="sizeGripEnabled" stdset="0"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QLabel" name="variableLabel"> - <property name="text"> - <string>&Variable Name:</string> - </property> - <property name="buddy"> - <cstring>variableLineEdit</cstring> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="variableLineEdit"/> - </item> - </layout> - </item> - <item> - <widget class="Line" name="variableLine"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Pattern Syntax:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="syntaxCombo"> - <property name="toolTip"> - <string>Select the pattern syntax</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>16</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QToolButton" name="undoButton"> - <property name="toolTip"> - <string><b>Undo last edit</b></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="redoButton"> - <property name="toolTip"> - <string><b>Redo last edit</b></string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <widget class="QFrame" name="regexpButtonsFrame"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QToolButton" name="charButton"> - <property name="toolTip"> - <string><b>Single character of a range (e.g. [abcd])</b><p>Select a single character of a range via a specific dialog.</p></string> - </property> - <property name="whatsThis"> - <string><b>Single character of a range (e.g. [abcd])</b><p>Select a single character of a range via a specific dialog. This dialog will help to edit the range of characters and add some specific conditions.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="anycharButton"> - <property name="toolTip"> - <string><b>Any character: '.'</b> -<p>Select to insert a dot (.) in your regexp.</p></string> - </property> - <property name="whatsThis"> - <string><b>Any character: '.'</b> -<p>Select to insert a dot (.) in your regexp. The dot matches a single character, except line break characters (by default). -E.g. 'gr.y' matches 'gray', 'grey', 'gr%y', etc. Use the dot sparingly. Often, a character class or negated -character class is faster and more precise.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="repeatButton"> - <property name="toolTip"> - <string><b>Repeat contents</b> -<p>Select a repetition condition via a specific dialog. This dialog will help to specify the allowed range for repetitions.</p></string> - </property> - <property name="whatsThis"> - <string><b>Repeat contents</b> -<p>Select a repetition condition via a specific dialog. This dialog will help to specify the allowed range for repetitions.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="nonGroupButton"> - <property name="toolTip"> - <string><b>Non capturing parentheses: (?:)</b> -<p>Select to insert some non capturing brackets.</p></string> - </property> - <property name="whatsThis"> - <string><b>Non capturing parentheses: (?:)</b> -<p>Select to insert some non capturing brackets. It can be used to apply a regexp quantifier (eg. '?' or '+') to the entire -group of characters inside the brakets. E.g. the regex 'Set(?:Value)?' matches 'Set' or 'SetValue'. The '?:' inside the brakets -means that the content of the match (called the backreference) is not stored for further use.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="groupButton"> - <property name="toolTip"> - <string><b>Group: ()</b> -<p>Select to insert some capturing brackets.</p></string> - </property> - <property name="whatsThis"> - <string><b>Group: ()</b> -<p>Select to insert some capturing brackets. They can be used to apply a regexp quantifier (e.g. '?' or '+') to the entire group of -characters inside the brakets. E.g. the regex 'Set(Value)?' matches 'Set' or 'SetValue'. Contrary to non-capturing parentheses, -the backreference matched inside the brakets is stored for further use (i.e. 'Value' in the second example above). -One can access the backereference with the '\1' expression. </p> -<p>E.g. '([a-c])x\1x\1' will match 'axaxa', 'bxbxb' and 'cxcxc'.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="altnButton"> - <property name="toolTip"> - <string><b>Alternatives: '|'</b> -<p>Select to insert the alternation symbol '|'. </p></string> - </property> - <property name="whatsThis"> - <string><b>Alternatives: '|'</b> -<p>Select to insert the alternation symbol '|'. The alternation is used to match a single regular expression out of -several possible regular expressions. E.g. 'cat|dog|mouse|fish' matches words containing the word 'cat', 'dog','mouse' or 'fish'. -Be aware that in the above example, the alternatives refer to whole or part of words. If you want to match exactly the - words 'cat', 'dog', ... you should express the fact that you only want to match complete words: '\b(cat|dog|mouse|fish)\b'</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="beglineButton"> - <property name="toolTip"> - <string><b>Begin of line: '^'</b> -<p>Select to insert the start line character (^).</p></string> - </property> - <property name="whatsThis"> - <string><b>Begin of line: '^'</b> -<p>Select to insert the start line character (^). It is used to find some expressions at the begining of lines. -E.g. '^[A-Z]' match lines starting with a capitalized character. </p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="endlineButton"> - <property name="toolTip"> - <string><b>End of line: '$'</b> -<p>Select to insert the end of line character ($).</p></string> - </property> - <property name="whatsThis"> - <string><b>End of line: '$'</b> -<p>Select to insert the end of line character ($). It is used to find some expressions at the end of lines.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="wordboundButton"> - <property name="toolTip"> - <string><b>Word boundary</b> -<p>Select to insert the word boudary character (\b).</p></string> - </property> - <property name="whatsThis"> - <string><b>Word boundary</b> -<p>Select to insert the word boudary character (\b). This character is used to express the fact that word -must begin or end at this position. E.g. '\bcat\b' matches exactly the word 'cat' while 'concatenation' is ignored.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="nonwordboundButton"> - <property name="toolTip"> - <string><b>Non word boundary</b> -<p>Select to insert the word boudary character (\B). \B is the negated version of \b.</p></string> - </property> - <property name="whatsThis"> - <string><b>Non word boundary</b> -<p>Select to insert the word boudary character (\B). \B is the negated version of \b. \B matches at every position where \b -does not. Effectively, \B matches at any position between two word characters as well as at any position between two non-word characters.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="poslookaheadButton"> - <property name="toolTip"> - <string><b>Positive lookahead: (?=<i>regexpr</i>)</b> -<p>Select to insert the positive lookhead brackets.</p></string> - </property> - <property name="whatsThis"> - <string><b>Positive lookahead: (?=<i>regexpr</i>)</b> -<p>Select to insert the positive lookhead brackets. Basically, positive lookhead is used to match a character only if followed by another one. -Writting 'q(?=u)' means that you want to match the 'q' character only if it is followed by 'u'. In this statement 'u' is a trivial -regexp which may be replaced by a more complex expression; q(?=[abc])' will match a 'q' if followed by either 'a', 'b' or 'c'.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="neglookaheadButton"> - <property name="toolTip"> - <string><b>Negative lookahead: (?!<i>regexpr</i>)</b> -<p>Select to insert the negative lookhead brackets.</p></string> - </property> - <property name="whatsThis"> - <string><b>Negative lookahead: (?!<i>regexpr</i>)</b> -<p>Select to insert the negative lookhead brackets. Basically, negative lookhead is used to match a character only if it is not -followed by a another one. Writting 'q(?!u)' means that you want to match 'q' only if it is not followed by 'u'. In this statement, 'u' is a -trivial regexp which may be replaced by a more complex expression; 'q(?![abc])' will match a 'q' if it is followed by anything else than 'a', 'b' or 'c'.</p></string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>356</width> - <height>24</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QFrame" name="wildcardButtonsFrame"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QToolButton" name="wildcardCharButton"> - <property name="toolTip"> - <string><b>Single character of a range (e.g. [abcd])</b><p>Select a single character of a range via a specific dialog.</p></string> - </property> - <property name="whatsThis"> - <string><b>Single character of a range (e.g. [abcd])</b><p>Select a single character of a range via a specific dialog. This dialog will help to edit the range of characters and add some specific conditions.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="wildcardAnycharButton"> - <property name="toolTip"> - <string><b>Any character: '.'</b> -<p>Select to insert a question mark (?) in your regexp.</p></string> - </property> - <property name="whatsThis"> - <string><b>Any character: '.'</b> -<p>Select to insert a question mark (?) in your regexp. The question mark matches a single character. -E.g. 'gr?y' matches 'gray', 'grey', 'gr%y', etc.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="wildcardRepeatButton"> - <property name="toolTip"> - <string><b>Repeat contents</b> -<p>Inserts a repetition (*) character into the regexp.</p></string> - </property> - <property name="whatsThis"> - <string><b>Repeat contents</b> -<p>Inserts a repetition (*) character into the regexp. That will match zero or more of any character.</p></string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>635</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QFrame" name="w3cButtonsFrame"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QToolButton" name="w3cCharButton"> - <property name="toolTip"> - <string><b>Single character of a range (e.g. [abcd])</b><p>Select a single character of a range via a specific dialog.</p></string> - </property> - <property name="whatsThis"> - <string><b>Single character of a range (e.g. [abcd])</b><p>Select a single character of a range via a specific dialog. This dialog will help to edit the range of characters and add some specific conditions.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="w3cAnycharButton"> - <property name="toolTip"> - <string><b>Any character: '.'</b> -<p>Select to insert a dot (.) in your regexp.</p></string> - </property> - <property name="whatsThis"> - <string><b>Any character: '.'</b> -<p>Select to insert a dot (.) in your regexp. The dot matches a single character, except line break characters (by default). -E.g. 'gr.y' matches 'gray', 'grey', 'gr%y', etc. Use the dot sparingly. Often, a character class or negated -character class is faster and more precise.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="w3cRepeatButton"> - <property name="toolTip"> - <string><b>Repeat contents</b> -<p>Select a repetition condition via a specific dialog. This dialog will help to specify the allowed range for repetitions.</p></string> - </property> - <property name="whatsThis"> - <string><b>Repeat contents</b> -<p>Select a repetition condition via a specific dialog. This dialog will help to specify the allowed range for repetitions.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="w3cGroupButton"> - <property name="toolTip"> - <string><b>Group: ()</b> -<p>Select to insert some capturing brackets.</p></string> - </property> - <property name="whatsThis"> - <string><b>Group: ()</b> -<p>Select to insert some capturing brackets. They can be used to apply a regexp quantifier (e.g. '?' or '+') to the entire group of -characters inside the brakets. E.g. the regex 'Set(Value)?' matches 'Set' or 'SetValue'.</p></string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="w3cAltnButton"> - <property name="toolTip"> - <string><b>Alternatives: '|'</b> -<p>Select to insert the alternation symbol '|'. </p></string> - </property> - <property name="whatsThis"> - <string><b>Alternatives: '|'</b> -<p>Select to insert the alternation symbol '|'. The alternation is used to match a single regular expression out of -several possible regular expressions. E.g. 'cat|dog|mouse|fish' matches words containing the word 'cat', 'dog','mouse' or 'fish'.</p></string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>573</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QGridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="textLabel1"> - <property name="text"> - <string>&Regexp:</string> - </property> - <property name="buddy"> - <cstring>regexpLineEdit</cstring> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="textLabel2"> - <property name="text"> - <string>&Text:</string> - </property> - <property name="alignment"> - <set>Qt::AlignTop</set> - </property> - <property name="buddy"> - <cstring>textTextEdit</cstring> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="regexpLineEdit"/> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="textTextEdit"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QCheckBox" name="caseSensitiveCheckBox"> - <property name="text"> - <string>Case &Sensitive</string> - </property> - <property name="shortcut"> - <string>Alt+S</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="minimalCheckBox"> - <property name="text"> - <string>&Minimal</string> - </property> - <property name="shortcut"> - <string>Alt+M</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <widget class="QTableWidget" name="resultTable"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Close|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <tabstops> - <tabstop>variableLineEdit</tabstop> - <tabstop>syntaxCombo</tabstop> - <tabstop>undoButton</tabstop> - <tabstop>redoButton</tabstop> - <tabstop>charButton</tabstop> - <tabstop>anycharButton</tabstop> - <tabstop>repeatButton</tabstop> - <tabstop>nonGroupButton</tabstop> - <tabstop>groupButton</tabstop> - <tabstop>altnButton</tabstop> - <tabstop>beglineButton</tabstop> - <tabstop>endlineButton</tabstop> - <tabstop>wordboundButton</tabstop> - <tabstop>nonwordboundButton</tabstop> - <tabstop>poslookaheadButton</tabstop> - <tabstop>neglookaheadButton</tabstop> - <tabstop>wildcardCharButton</tabstop> - <tabstop>wildcardAnycharButton</tabstop> - <tabstop>wildcardRepeatButton</tabstop> - <tabstop>w3cCharButton</tabstop> - <tabstop>w3cAnycharButton</tabstop> - <tabstop>w3cRepeatButton</tabstop> - <tabstop>w3cGroupButton</tabstop> - <tabstop>w3cAltnButton</tabstop> - <tabstop>regexpLineEdit</tabstop> - <tabstop>textTextEdit</tabstop> - <tabstop>caseSensitiveCheckBox</tabstop> - <tabstop>minimalCheckBox</tabstop> - <tabstop>resultTable</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>undoButton</sender> - <signal>clicked()</signal> - <receiver>regexpLineEdit</receiver> - <slot>undo()</slot> - <hints> - <hint type="sourcelabel"> - <x>490</x> - <y>132</y> - </hint> - <hint type="destinationlabel"> - <x>487</x> - <y>163</y> - </hint> - </hints> - </connection> - <connection> - <sender>redoButton</sender> - <signal>clicked()</signal> - <receiver>regexpLineEdit</receiver> - <slot>redo()</slot> - <hints> - <hint type="sourcelabel"> - <x>526</x> - <y>132</y> - </hint> - <hint type="destinationlabel"> - <x>529</x> - <y>163</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardRepeatDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2004 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog for entering repeat counts. -""" - - -from PyQt5.QtCore import pyqtSlot -from PyQt5.QtWidgets import QDialog - -from .Ui_QRegExpWizardRepeatDialog import Ui_QRegExpWizardRepeatDialog - - -class QRegExpWizardRepeatDialog(QDialog, Ui_QRegExpWizardRepeatDialog): - """ - Class implementing a dialog for entering repeat counts. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent parent widget (QWidget) - """ - super(QRegExpWizardRepeatDialog, self).__init__(parent) - self.setupUi(self) - - self.unlimitedButton.setChecked(True) - - msh = self.minimumSizeHint() - self.resize(max(self.width(), msh.width()), msh.height()) - - @pyqtSlot(int) - def on_lowerSpin_valueChanged(self, value): - """ - Private slot to handle the lowerSpin valueChanged signal. - - @param value value of the spinbox (integer) - """ - if self.upperSpin.value() < value: - self.upperSpin.setValue(value) - - @pyqtSlot(int) - def on_upperSpin_valueChanged(self, value): - """ - Private slot to handle the upperSpin valueChanged signal. - - @param value value of the spinbox (integer) - """ - if self.lowerSpin.value() > value: - self.lowerSpin.setValue(value) - - def getRepeat(self): - """ - Public method to retrieve the dialog's result. - - @return ready formatted repeat string (string) - """ - if self.unlimitedButton.isChecked(): - return "*" - elif self.minButton.isChecked(): - reps = self.minSpin.value() - if reps == 1: - return "+" - else: - return "{{{0:d},}}".format(reps) - elif self.maxButton.isChecked(): - reps = self.maxSpin.value() - if reps == 1: - return "?" - else: - return "{{,{0:d}}}".format(reps) - elif self.exactButton.isChecked(): - reps = self.exactSpin.value() - return "{{{0:d}}}".format(reps) - elif self.betweenButton.isChecked(): - repsMin = self.lowerSpin.value() - repsMax = self.upperSpin.value() - return "{{{0:d},{1:d}}}".format(repsMin, repsMax) - - return ""
--- a/eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardRepeatDialog.ui Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,302 +0,0 @@ -<ui version="4.0" > - <class>QRegExpWizardRepeatDialog</class> - <widget class="QDialog" name="QRegExpWizardRepeatDialog" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>331</width> - <height>197</height> - </rect> - </property> - <property name="windowTitle" > - <string>Number of repetitions</string> - </property> - <property name="sizeGripEnabled" > - <bool>true</bool> - </property> - <layout class="QVBoxLayout" > - <item> - <widget class="QGroupBox" name="groupBox" > - <property name="title" > - <string/> - </property> - <property name="flat" > - <bool>true</bool> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <item row="2" column="2" > - <widget class="QLabel" name="textLabel1_6" > - <property name="text" > - <string>times</string> - </property> - </widget> - </item> - <item row="3" column="2" > - <widget class="QLabel" name="textLabel1_7" > - <property name="text" > - <string>times</string> - </property> - </widget> - </item> - <item row="1" column="2" > - <widget class="QLabel" name="textLabel1_5" > - <property name="text" > - <string>times</string> - </property> - </widget> - </item> - <item row="4" column="1" > - <widget class="QSpinBox" name="lowerSpin" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="alignment" > - <set>Qt::AlignRight</set> - </property> - <property name="value" > - <number>1</number> - </property> - </widget> - </item> - <item row="4" column="3" > - <widget class="QSpinBox" name="upperSpin" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="alignment" > - <set>Qt::AlignRight</set> - </property> - <property name="value" > - <number>1</number> - </property> - </widget> - </item> - <item row="4" column="2" > - <widget class="QLabel" name="textLabel6" > - <property name="text" > - <string>and</string> - </property> - </widget> - </item> - <item row="4" column="0" > - <widget class="QRadioButton" name="betweenButton" > - <property name="text" > - <string>Between</string> - </property> - </widget> - </item> - <item row="3" column="1" > - <widget class="QSpinBox" name="exactSpin" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="alignment" > - <set>Qt::AlignRight</set> - </property> - <property name="value" > - <number>1</number> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QRadioButton" name="exactButton" > - <property name="text" > - <string>Exactly</string> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QSpinBox" name="maxSpin" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="alignment" > - <set>Qt::AlignRight</set> - </property> - <property name="value" > - <number>1</number> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QRadioButton" name="maxButton" > - <property name="text" > - <string>Maximum</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QRadioButton" name="minButton" > - <property name="text" > - <string>Minimum</string> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QSpinBox" name="minSpin" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="alignment" > - <set>Qt::AlignRight</set> - </property> - <property name="value" > - <number>1</number> - </property> - </widget> - </item> - <item row="0" column="0" colspan="4" > - <widget class="QRadioButton" name="unlimitedButton" > - <property name="text" > - <string>Unlimited (incl. zero times)</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <tabstops> - <tabstop>unlimitedButton</tabstop> - <tabstop>minButton</tabstop> - <tabstop>minSpin</tabstop> - <tabstop>maxButton</tabstop> - <tabstop>maxSpin</tabstop> - <tabstop>exactButton</tabstop> - <tabstop>exactSpin</tabstop> - <tabstop>betweenButton</tabstop> - <tabstop>lowerSpin</tabstop> - <tabstop>upperSpin</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>minButton</sender> - <signal>toggled(bool)</signal> - <receiver>minSpin</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>53</x> - <y>43</y> - </hint> - <hint type="destinationlabel" > - <x>121</x> - <y>47</y> - </hint> - </hints> - </connection> - <connection> - <sender>maxButton</sender> - <signal>toggled(bool)</signal> - <receiver>maxSpin</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>58</x> - <y>68</y> - </hint> - <hint type="destinationlabel" > - <x>117</x> - <y>67</y> - </hint> - </hints> - </connection> - <connection> - <sender>exactButton</sender> - <signal>toggled(bool)</signal> - <receiver>exactSpin</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>53</x> - <y>99</y> - </hint> - <hint type="destinationlabel" > - <x>116</x> - <y>98</y> - </hint> - </hints> - </connection> - <connection> - <sender>betweenButton</sender> - <signal>toggled(bool)</signal> - <receiver>lowerSpin</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>52</x> - <y>126</y> - </hint> - <hint type="destinationlabel" > - <x>119</x> - <y>124</y> - </hint> - </hints> - </connection> - <connection> - <sender>betweenButton</sender> - <signal>toggled(bool)</signal> - <receiver>upperSpin</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>53</x> - <y>125</y> - </hint> - <hint type="destinationlabel" > - <x>282</x> - <y>125</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>QRegExpWizardRepeatDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel" > - <x>16</x> - <y>164</y> - </hint> - <hint type="destinationlabel" > - <x>16</x> - <y>185</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>QRegExpWizardRepeatDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel" > - <x>72</x> - <y>167</y> - </hint> - <hint type="destinationlabel" > - <x>72</x> - <y>181</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/eric6/Plugins/WizardPlugins/QRegExpWizard/__init__.py Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2004 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Package implementing the QRegExp wizard. -"""
--- a/eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,9 +7,8 @@ Module implementing a dialog for entering character classes. """ - -from PyQt5.QtCore import QRegExp -from PyQt5.QtGui import QRegExpValidator +from PyQt5.QtCore import QRegularExpression +from PyQt5.QtGui import QRegularExpressionValidator from PyQt5.QtWidgets import ( QWidget, QDialog, QVBoxLayout, QHBoxLayout, QScrollArea, QPushButton, QSpacerItem, QSizePolicy, QComboBox, QLineEdit, QLabel @@ -62,9 +61,12 @@ (self.tr("Not POSIX Named Set"), "-psn"), ]) - self.charValidator = QRegExpValidator(QRegExp(".{0,1}"), self) - self.hexValidator = QRegExpValidator(QRegExp("[0-9a-fA-F]{0,4}"), self) - self.octValidator = QRegExpValidator(QRegExp("[0-3]?[0-7]{0,2}"), self) + self.charValidator = QRegularExpressionValidator( + QRegularExpression(".{0,1}"), self) + self.hexValidator = QRegularExpressionValidator( + QRegularExpression("[0-9a-fA-F]{0,4}"), self) + self.octValidator = QRegularExpressionValidator( + QRegularExpression("[0-3]?[0-7]{0,2}"), self) # generate dialog part for single characters self.singlesBoxLayout = QVBoxLayout(self.singlesBox)
--- a/eric6/Preferences/ConfigurationPages/CooperationPage.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Preferences/ConfigurationPages/CooperationPage.py Sun Oct 11 17:54:52 2020 +0200 @@ -8,8 +8,8 @@ """ -from PyQt5.QtCore import pyqtSlot, QRegExp -from PyQt5.QtGui import QRegExpValidator, QValidator +from PyQt5.QtCore import pyqtSlot, QRegularExpression +from PyQt5.QtGui import QRegularExpressionValidator, QValidator from .ConfigurationPageBase import ConfigurationPageBase from .Ui_CooperationPage import Ui_CooperationPage @@ -29,10 +29,11 @@ self.setupUi(self) self.setObjectName("CooperationPage") - self.__bannedUserValidator = QRegExpValidator( - QRegExp(r"[a-zA-Z0-9.-]+@" - r"(?:(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})\.){3}" - r"(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})"), + self.__bannedUserValidator = QRegularExpressionValidator( + QRegularExpression( + r"[a-zA-Z0-9.-]+@" + r"(?:(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})\.){3}" + r"(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})"), self.bannedUserEdit) self.bannedUserEdit.setValidator(self.__bannedUserValidator)
--- a/eric6/Preferences/ConfigurationPages/DebuggerGeneralPage.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Preferences/ConfigurationPages/DebuggerGeneralPage.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,10 +7,10 @@ Module implementing the Debugger General configuration page. """ - +import re import socket -from PyQt5.QtCore import Qt, QAbstractItemModel, QModelIndex, QRegExp, pyqtSlot +from PyQt5.QtCore import pyqtSlot, Qt, QAbstractItemModel, QModelIndex from PyQt5.QtGui import QBrush, QColor from PyQt5.QtWidgets import QLineEdit, QInputDialog from PyQt5.QtNetwork import QNetworkInterface, QAbstractSocket, QHostAddress @@ -91,8 +91,7 @@ index = -1 for i in range(len(interfaces)): if ( - QRegExp(".*{0}.*".format(interface)) - .exactMatch(interfaces[i]) + re.fullmatch(".*{0}.*".format(interface), interfaces[i]) ): index = i break
--- a/eric6/Preferences/ShortcutsDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Preferences/ShortcutsDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -8,8 +8,9 @@ shortcuts. """ +import re -from PyQt5.QtCore import pyqtSignal, QRegExp, Qt, pyqtSlot +from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt from PyQt5.QtGui import QKeySequence from PyQt5.QtWidgets import QHeaderView, QDialog, QTreeWidgetItem @@ -462,6 +463,7 @@ @param txt text of the search edit (string) """ + rx = re.compile(re.escape(txt), re.IGNORECASE) for topIndex in range(self.shortcutsList.topLevelItemCount()): topItem = self.shortcutsList.topLevelItem(topIndex) childHiddenCount = 0 @@ -469,8 +471,7 @@ itm = topItem.child(index) if ( (self.actionButton.isChecked() and - not QRegExp(txt, Qt.CaseInsensitive).indexIn( - itm.text(0)) > -1) or + rx.search(itm.text(0)) is not None) or (self.shortcutButton.isChecked() and not txt.lower() in itm.text(1).lower() and not txt.lower() in itm.text(2).lower())
--- a/eric6/Project/CreateDialogCodeDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Project/CreateDialogCodeDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,14 +7,13 @@ Module implementing a dialog to generate code for a Qt5 dialog. """ - import sys import os import json from PyQt5.QtCore import ( - pyqtSlot, Qt, QMetaObject, QRegExp, QSortFilterProxyModel, QProcess, - QProcessEnvironment + pyqtSlot, Qt, QMetaObject, QRegularExpression, QSortFilterProxyModel, + QProcess, QProcessEnvironment ) from PyQt5.QtGui import QStandardItemModel, QStandardItem, QBrush, QColor from PyQt5.QtWidgets import QDialog, QDialogButtonBox @@ -591,8 +590,8 @@ @param text changed text (string) """ - re = QRegExp(text, Qt.CaseInsensitive, QRegExp.RegExp2) - self.proxyModel.setFilterRegExp(re) + rx = QRegularExpression(text, QRegularExpression.CaseInsensitiveOption) + self.proxyModel.setFilterRegularExpression(rx) @pyqtSlot() def on_newButton_clicked(self):
--- a/eric6/QScintilla/Editor.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/QScintilla/Editor.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,14 +7,13 @@ Module implementing the editor component of the eric6 IDE. """ - import os import re import difflib from PyQt5.QtCore import ( - QDir, QTimer, QModelIndex, QFileInfo, pyqtSignal, pyqtSlot, - QCryptographicHash, QEvent, QDateTime, QRegExp, Qt, QPoint + pyqtSignal, pyqtSlot, Qt, QDir, QTimer, QModelIndex, QFileInfo, + QCryptographicHash, QEvent, QDateTime, QPoint ) from PyQt5.QtGui import QPalette, QFont, QPixmap, QPainter from PyQt5.QtWidgets import ( @@ -3520,29 +3519,25 @@ @return tuple with start and end indexes of the word at the position (integer, integer) """ - text = self.text(line) - if self.caseSensitive(): - cs = Qt.CaseSensitive - else: - cs = Qt.CaseInsensitive wc = self.wordCharacters() if wc is None or not useWordChars: - regExp = QRegExp(r'[^\w_]', cs) + pattern = r"\b[\w_]+\b" else: wc = re.sub(r'\w', "", wc) - regExp = QRegExp(r'[^\w{0}]'.format(re.escape(wc)), cs) - start = regExp.lastIndexIn(text, index) + 1 - end = regExp.indexIn(text, index) - if start == end + 1 and index > 0: - # we are on a word boundary, try again - start = regExp.lastIndexIn(text, index - 1) + 1 - if start == -1: - start = 0 - if end == -1: - end = len(text) - - return (start, end) - + pattern = r"\b[\w{0}]+\b".format(re.escape(wc)) + if self.caseSensitive(): + rx = re.compile(pattern) + else: + rx = re.compile(pattern, re.IGNORECASE) + + text = self.text(line) + for match in rx.finditer(text): + start, end = match.span() + if start <= index <= end: + return (start, end) + + return (0, len(text)) + def getWord(self, line, index, direction=0, useWordChars=True): """ Public method to get the word at a position.
--- a/eric6/QScintilla/MiniEditor.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/QScintilla/MiniEditor.py Sun Oct 11 17:54:52 2020 +0200 @@ -4,15 +4,14 @@ # """ -Module implementing a minimalistic editor for simple editing tasks. +Module implementing an editor for simple editing tasks. """ - import os import re from PyQt5.QtCore import ( - QSignalMapper, QPoint, QTimer, QFileInfo, pyqtSignal, QSize, QRegExp, Qt, + pyqtSignal, Qt, QSignalMapper, QPoint, QTimer, QFileInfo, QSize, QCoreApplication ) from PyQt5.QtGui import QKeySequence, QPalette, QFont, QPixmap @@ -114,7 +113,7 @@ class MiniEditor(E5MainWindow): """ - Class implementing a minimalistic editor for simple editing tasks. + Class implementing an editor for simple editing tasks. @signal editorSaved() emitted after the file has been saved @signal languageChanged(str) emitted when the editors language was set. The @@ -3439,35 +3438,31 @@ """ Private method to get the word at a position. - @param line number of line to look at (int) - @param index position to look at (int) - @return the word at that position (string) + @param line number of line to look at + @type int + @param index position to look at + @type int + @return the word at that position + @rtype str """ - text = self.__textEdit.text(line) - if self.__textEdit.caseSensitive(): - cs = Qt.CaseSensitive - else: - cs = Qt.CaseInsensitive wc = self.__textEdit.wordCharacters() if wc is None: - regExp = QRegExp(r'[^\w_]', cs) + pattern = r"\b[\w_]+\b" else: wc = re.sub(r'\w', "", wc) - regExp = QRegExp(r'[^\w{0}]'.format(re.escape(wc)), cs) - start = regExp.lastIndexIn(text, index) + 1 - end = regExp.indexIn(text, index) - if start == end + 1 and index > 0: - # we are on a word boundary, try again - start = regExp.lastIndexIn(text, index - 1) + 1 - if start == -1: - start = 0 - if end == -1: - end = len(text) - if end > start: - word = text[start:end] + pattern = r"\b[\w{0}]+\b".format(re.escape(wc)) + if self.__textEdit.caseSensitive(): + rx = re.compile(pattern) else: - word = '' - return word + rx = re.compile(pattern, re.IGNORECASE) + + text = self.text(line) + for match in rx.finditer(text): + start, end = match.span() + if start <= index <= end: + return match.group() + + return "" def __getCurrentWord(self): """
--- a/eric6/QScintilla/TypingCompleters/CompleterPython.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/QScintilla/TypingCompleters/CompleterPython.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,15 +7,14 @@ Module implementing a typing completer for Python. """ - import re -from PyQt5.QtCore import QRegExp from PyQt5.Qsci import QsciLexerPython, QsciScintilla from .CompleterBase import CompleterBase import Preferences +from Utilities import rxIndex class CompleterPython(CompleterBase): @@ -31,27 +30,27 @@ """ super(CompleterPython, self).__init__(editor, parent) - self.__defRX = QRegExp(r"""^[ \t]*def \w+\(""") - self.__defSelfRX = QRegExp(r"""^[ \t]*def \w+\([ \t]*self[ \t]*[,)]""") - self.__defClsRX = QRegExp(r"""^[ \t]*def \w+\([ \t]*cls[ \t]*[,)]""") - self.__classRX = QRegExp(r"""^[ \t]*class \w+\(""") - self.__importRX = QRegExp(r"""^[ \t]*from [\w.]+ """) - self.__classmethodRX = QRegExp(r"""^[ \t]*@classmethod""") - self.__staticmethodRX = QRegExp(r"""^[ \t]*@staticmethod""") + self.__defRX = re.compile(r"^[ \t]*def \w+\(") + self.__defSelfRX = re.compile(r"^[ \t]*def \w+\([ \t]*self[ \t]*[,)]") + self.__defClsRX = re.compile(r"^[ \t]*def \w+\([ \t]*cls[ \t]*[,)]") + self.__classRX = re.compile(r"^[ \t]*class \w+\(") + self.__importRX = re.compile(r"^[ \t]*from [\w.]+ ") + self.__classmethodRX = re.compile(r"^[ \t]*@classmethod") + self.__staticmethodRX = re.compile(r"^[ \t]*@staticmethod") - self.__defOnlyRX = QRegExp(r"""^[ \t]*def """) + self.__defOnlyRX = re.compile(r"^[ \t]*def ") - self.__ifRX = QRegExp(r"""^[ \t]*if """) - self.__elifRX = QRegExp(r"""^[ \t]*elif """) - self.__elseRX = QRegExp(r"""^[ \t]*else:""") + self.__ifRX = re.compile(r"^[ \t]*if ") + self.__elifRX = re.compile(r"^[ \t]*elif ") + self.__elseRX = re.compile(r"^[ \t]*else:") - self.__tryRX = QRegExp(r"""^[ \t]*try:""") - self.__finallyRX = QRegExp(r"""^[ \t]*finally:""") - self.__exceptRX = QRegExp(r"""^[ \t]*except """) - self.__exceptcRX = QRegExp(r"""^[ \t]*except:""") + self.__tryRX = re.compile(r"^[ \t]*try:") + self.__finallyRX = re.compile(r"^[ \t]*finally:") + self.__exceptRX = re.compile(r"^[ \t]*except ") + self.__exceptcRX = re.compile(r"^[ \t]*except:") - self.__whileRX = QRegExp(r"""^[ \t]*while """) - self.__forRX = QRegExp(r"""^[ \t]*for """) + self.__whileRX = re.compile(r"^[ \t]*while ") + self.__forRX = re.compile(r"^[ \t]*for ") self.readSettings() @@ -114,7 +113,7 @@ txt = self.editor.text(line)[:col] if ( self.__insertSelf and - self.__defRX.exactMatch(txt) + self.__defRX.fullmatch(txt) is not None ): if self.__isClassMethodDef(): self.editor.insert('cls') @@ -127,8 +126,8 @@ self.editor.setCursorPosition(line, col + 4) if self.__insertClosingBrace: if ( - self.__defRX.exactMatch(txt) or - self.__classRX.exactMatch(txt) + self.__defRX.fullmatch(txt) is not None or + self.__classRX.fullmatch(txt) is not None ): self.editor.insert('):') else: @@ -148,18 +147,18 @@ # dedent def elif char == ' ': txt = self.editor.text(line)[:col] - if self.__insertImport and self.__importRX.exactMatch(txt): + if self.__insertImport and self.__importRX.fullmatch(txt): if self.__importBraceType: self.editor.insert('import ()') self.editor.setCursorPosition(line, col + 8) else: self.editor.insert('import ') self.editor.setCursorPosition(line, col + 7) - elif self.__dedentElse and self.__elifRX.exactMatch(txt): + elif self.__dedentElse and self.__elifRX.fullmatch(txt): self.__dedentToIf() - elif self.__dedentExcept and self.__exceptRX.exactMatch(txt): + elif self.__dedentExcept and self.__exceptRX.fullmatch(txt): self.__dedentExceptToTry(False) - elif self.__dedentDef and self.__defOnlyRX.exactMatch(txt): + elif self.__dedentDef and self.__defOnlyRX.fullmatch(txt): self.__dedentDefStatement() # comma @@ -203,11 +202,11 @@ self.editor.removeSelectedText() else: txt = text[:col] - if self.__dedentElse and self.__elseRX.exactMatch(txt): + if self.__dedentElse and self.__elseRX.fullmatch(txt): self.__dedentElseToIfWhileForTry() - elif self.__dedentExcept and self.__exceptcRX.exactMatch(txt): + elif self.__dedentExcept and self.__exceptcRX.fullmatch(txt): self.__dedentExceptToTry(True) - elif self.__dedentExcept and self.__finallyRX.exactMatch(txt): + elif self.__dedentExcept and self.__finallyRX.fullmatch(txt): self.__dedentFinallyToTry() # new line @@ -253,10 +252,10 @@ while ifLine >= 0: txt = self.editor.text(ifLine) edInd = self.editor.indentation(ifLine) - if self.__elseRX.indexIn(txt) == 0 and edInd <= indentation: + if rxIndex(self.__elseRX, txt) == 0 and edInd <= indentation: indentation = edInd - 1 - elif (self.__ifRX.indexIn(txt) == 0 or - self.__elifRX.indexIn(txt) == 0) and edInd <= indentation: + elif (rxIndex(self.__ifRX, txt) == 0 or + rxIndex(self.__elifRX, txt) == 0) and edInd <= indentation: self.editor.cancelList() self.editor.setIndentation(line, edInd) break @@ -275,19 +274,19 @@ while ifLine >= 0: txt = self.editor.text(ifLine) edInd = self.editor.indentation(ifLine) - if self.__elseRX.indexIn(txt) == 0 and edInd <= indentation: + if rxIndex(self.__elseRX, txt) == 0 and edInd <= indentation: indentation = edInd - 1 elif ( - self.__elifRX.indexIn(txt) == 0 and + rxIndex(self.__elifRX, txt) == 0 and edInd == indentation and edInd == prevInd ): indentation = edInd - 1 elif ( - (self.__ifRX.indexIn(txt) == 0 or - self.__whileRX.indexIn(txt) == 0 or - self.__forRX.indexIn(txt) == 0 or - self.__tryRX.indexIn(txt) == 0) and + (rxIndex(self.__ifRX, txt) == 0 or + rxIndex(self.__whileRX, txt) == 0 or + rxIndex(self.__forRX, txt) == 0 or + rxIndex(self.__tryRX, txt) == 0) and edInd <= indentation ): self.editor.cancelList() @@ -309,13 +308,13 @@ txt = self.editor.text(tryLine) edInd = self.editor.indentation(tryLine) if ( - (self.__exceptcRX.indexIn(txt) == 0 or - self.__finallyRX.indexIn(txt) == 0) and + (rxIndex(self.__exceptcRX, txt) == 0 or + rxIndex(self.__finallyRX, txt) == 0) and edInd <= indentation ): indentation = edInd - 1 - elif (self.__exceptRX.indexIn(txt) == 0 or - self.__tryRX.indexIn(txt) == 0) and edInd <= indentation: + elif (rxIndex(self.__exceptRX, txt) == 0 or + rxIndex(self.__tryRX, txt) == 0) and edInd <= indentation: self.editor.cancelList() self.editor.setIndentation(line, edInd) break @@ -332,12 +331,12 @@ while tryLine >= 0: txt = self.editor.text(tryLine) edInd = self.editor.indentation(tryLine) - if self.__finallyRX.indexIn(txt) == 0 and edInd <= indentation: + if rxIndex(self.__finallyRX, txt) == 0 and edInd <= indentation: indentation = edInd - 1 elif ( - (self.__tryRX.indexIn(txt) == 0 or - self.__exceptcRX.indexIn(txt) == 0 or - self.__exceptRX.indexIn(txt) == 0) and + (rxIndex(self.__tryRX, txt) == 0 or + rxIndex(self.__exceptcRX, txt) == 0 or + rxIndex(self.__exceptRX, txt) == 0) and edInd <= indentation ): self.editor.cancelList() @@ -357,9 +356,9 @@ txt = self.editor.text(tryLine) edInd = self.editor.indentation(tryLine) newInd = -1 - if self.__defRX.indexIn(txt) == 0 and edInd < indentation: + if rxIndex(self.__defRX, txt) == 0 and edInd < indentation: newInd = edInd - elif self.__classRX.indexIn(txt) == 0 and edInd < indentation: + elif rxIndex(self.__classRX, txt) == 0 and edInd < indentation: newInd = edInd + ( self.editor.indentationWidth() or self.editor.tabWidth() ) @@ -381,18 +380,18 @@ while curLine >= 0: txt = self.editor.text(curLine) if ( - (self.__defSelfRX.indexIn(txt) == 0 or - self.__defClsRX.indexIn(txt) == 0) and + (rxIndex(self.__defSelfRX, txt) == 0 or + rxIndex(self.__defClsRX, txt) == 0) and self.editor.indentation(curLine) == indentation ): return True elif ( - self.__classRX.indexIn(txt) == 0 and + rxIndex(self.__classRX, txt) == 0 and self.editor.indentation(curLine) < indentation ): return True elif ( - self.__defRX.indexIn(txt) == 0 and + rxIndex(self.__defRX, txt) == 0 and self.editor.indentation(curLine) <= indentation ): return False @@ -410,7 +409,7 @@ indentation = self.editor.indentation(line) curLine = line - 1 if ( - self.__classmethodRX.indexIn(self.editor.text(curLine)) == 0 and + rxIndex(self.__classmethodRX, self.editor.text(curLine)) == 0 and self.editor.indentation(curLine) == indentation ): return True @@ -427,7 +426,7 @@ indentation = self.editor.indentation(line) curLine = line - 1 if ( - self.__staticmethodRX.indexIn(self.editor.text(curLine)) == 0 and + rxIndex(self.__staticmethodRX, self.editor.text(curLine)) == 0 and self.editor.indentation(curLine) == indentation ): return True
--- a/eric6/QScintilla/TypingCompleters/CompleterRuby.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/QScintilla/TypingCompleters/CompleterRuby.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,10 +7,8 @@ Module implementing a typing completer for Ruby. """ - import re -from PyQt5.QtCore import QRegExp from PyQt5.Qsci import QsciLexerRuby, QsciScintilla from .CompleterBase import CompleterBase @@ -31,9 +29,9 @@ """ super(CompleterRuby, self).__init__(editor, parent) - self.__beginRX = QRegExp(r"""^=begin """) - self.__beginNlRX = QRegExp(r"""^=begin\r?\n""") - self.__hereRX = QRegExp(r"""<<-?['"]?(\w*)['"]?\r?\n""") + self.__beginRX = re.compile(r"""^=begin """) + self.__beginNlRX = re.compile(r"""^=begin\r?\n""") + self.__hereRX = re.compile(r"""<<-?['"]?(\w*)['"]?\r?\n""") self.readSettings() @@ -99,7 +97,7 @@ # complete inline documentation elif char == ' ': txt = self.editor.text(line)[:col] - if self.__insertInlineDoc and self.__beginRX.exactMatch(txt): + if self.__insertInlineDoc and self.__beginRX.fullmatch(txt): self.editor.insert('=end') # comma @@ -137,10 +135,10 @@ # indent to opening brace, complete inline documentation elif char == '\n': txt = self.editor.text(line - 1) - if self.__insertInlineDoc and self.__beginNlRX.exactMatch(txt): + if self.__insertInlineDoc and self.__beginNlRX.fullmatch(txt): self.editor.insert('=end') - elif self.__insertHereDoc and self.__hereRX.exactMatch(txt): - self.editor.insert(self.__hereRX.cap(1)) + elif self.__insertHereDoc and self.__hereRX.fullmatch(txt): + self.editor.insert(self.__hereRX.fullmatch(txt).group(1)) elif self.__indentBrace and re.search(":\r?\n", txt) is None: stxt = txt.strip() if stxt and stxt[-1] in ("(", "[", "{"):
--- a/eric6/Snapshot/SnapWidget.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Snapshot/SnapWidget.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,16 +7,16 @@ Module implementing the snapshot widget. """ - # # SnapWidget and its associated modules are PyQt5 ports of Ksnapshot. # import os +import re from PyQt5.QtCore import ( - pyqtSlot, QFile, QFileInfo, QTimer, QPoint, QMimeData, Qt, QRegExp, - QLocale, QStandardPaths + pyqtSlot, Qt, QFile, QFileInfo, QTimer, QPoint, QMimeData, QLocale, + QStandardPaths ) from PyQt5.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence from PyQt5.QtWidgets import QWidget, QApplication, QShortcut @@ -269,16 +269,18 @@ name = os.path.basename(self.__filename) # If the name contains a number, then increment it. - numSearch = QRegExp("(^|[^\\d])(\\d+)") + numSearch = re.compile("(^|[^\\d])(\\d+)") # We want to match as far left as possible, and when the number is # at the start of the name. # Does it have a number? - start = numSearch.lastIndexIn(name) - if start != -1: + matches = list(numSearch.finditer(name)) + if matches: # It has a number, increment it. - start = numSearch.pos(2) # Only the second group is of interest. - numAsStr = numSearch.capturedTexts()[2] + match = matches[-1] + start = match.start(2) + # Only the second group is of interest. + numAsStr = match.group(2) number = "{0:0{width}d}".format( int(numAsStr) + 1, width=len(numAsStr)) name = name[:start] + number + name[start + len(numAsStr):] @@ -287,10 +289,10 @@ start = name.rfind('.') if start != -1: # has a '.' somewhere, e.g. it has an extension - name = name[:start] + '1' + name[start:] + name = name[:start] + '-1' + name[start:] else: # no extension, just tack it on to the end - name += '1' + name += '-1' self.__filename = os.path.join(os.path.dirname(self.__filename), name) self.__updateCaption()
--- a/eric6/Tasks/TaskFilter.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Tasks/TaskFilter.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,8 @@ Module implementing a class to store task data. """ - -from PyQt5.QtCore import QRegExp +import fnmatch +import re from .Task import Task @@ -24,7 +24,7 @@ self.active = False self.summaryFilter = None - self.filenameFilter = None + self.filenameFilter = "" self.typeFilter = Task.TypeNone # task type @@ -55,7 +55,7 @@ if not filterStr: self.summaryFilter = None else: - self.summaryFilter = QRegExp(filterStr) + self.summaryFilter = re.compile(filterStr) def setFileNameFilter(self, filterStr): """ @@ -64,11 +64,7 @@ @param filterStr a wildcard expression for the filename filter to set (string) or None """ - if not filterStr: - self.filenameFilter = None - else: - self.filenameFilter = QRegExp(filterStr) - self.filenameFilter.setPatternSyntax(QRegExp.Wildcard) + self.filenameFilter = filterStr def setTypeFilter(self, taskType): """ @@ -111,7 +107,7 @@ """ return ( self.summaryFilter is not None or - self.filenameFilter is not None or + bool(self.filenameFilter) or self.typeFilter != Task.TypeNone or self.scopeFilter is not None or self.statusFilter is not None or @@ -130,13 +126,13 @@ if ( self.summaryFilter and - self.summaryFilter.indexIn(task.summary) == -1 + self.summaryFilter.search(task.summary) is None ): return False if ( self.filenameFilter and - not self.filenameFilter.exactMatch(task.filename) + not fnmatch.fnmatch(task.filename, self.filenameFilter) ): return False
--- a/eric6/Tasks/TaskFilterConfigDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Tasks/TaskFilterConfigDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,7 +7,6 @@ Module implementing the task filter configuration dialog. """ - from PyQt5.QtWidgets import QDialog from .Task import Task @@ -39,23 +38,20 @@ if ( taskFilter.summaryFilter is None or - not taskFilter.summaryFilter.pattern() + not taskFilter.summaryFilter.pattern ): self.summaryGroup.setChecked(False) self.summaryEdit.clear() else: self.summaryGroup.setChecked(True) - self.summaryEdit.setText(taskFilter.summaryFilter.pattern()) + self.summaryEdit.setText(taskFilter.summaryFilter.pattern) - if ( - taskFilter.filenameFilter is None or - not taskFilter.filenameFilter.pattern() - ): + if not taskFilter.filenameFilter: self.filenameGroup.setChecked(False) self.filenameEdit.clear() else: self.filenameGroup.setChecked(True) - self.filenameEdit.setText(taskFilter.filenameFilter.pattern()) + self.filenameEdit.setText(taskFilter.filenameFilter) if taskFilter.typeFilter == Task.TypeNone: self.typeGroup.setChecked(False) @@ -116,7 +112,7 @@ if self.filenameGroup.isChecked(): taskFilter.setFileNameFilter(self.filenameEdit.text()) else: - taskFilter.setFileNameFilter(None) + taskFilter.setFileNameFilter("") if self.typeGroup.isChecked(): taskFilter.setTypeFilter(
--- a/eric6/Templates/TemplatePropertiesDialog.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Templates/TemplatePropertiesDialog.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,9 +7,8 @@ Module implementing the templates properties dialog. """ - -from PyQt5.QtCore import QRegExp, Qt, pyqtSlot -from PyQt5.QtGui import QRegExpValidator +from PyQt5.QtCore import pyqtSlot, Qt, QRegularExpression +from PyQt5.QtGui import QRegularExpressionValidator from PyQt5.QtWidgets import QDialog from .Ui_TemplatePropertiesDialog import Ui_TemplatePropertiesDialog @@ -45,8 +44,8 @@ """ must only consist of letters (a-z and A-Z),""" """ digits (0-9) and underscores (_).</p>""" )) - self.__nameValidator = QRegExpValidator(QRegExp("[a-zA-Z0-9_]+"), - self.nameEdit) + self.__nameValidator = QRegularExpressionValidator( + QRegularExpression("[a-zA-Z0-9_]+"), self.nameEdit) self.nameEdit.setValidator(self.__nameValidator) import QScintilla.Lexers
--- a/eric6/Tools/TrayStarter.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Tools/TrayStarter.py Sun Oct 11 17:54:52 2020 +0200 @@ -92,7 +92,8 @@ self.__menu.addSeparator() self.__menu.addAction( - self.tr("QRegExp editor"), self.__startQRegExp) + self.tr("QRegularExpression editor"), + self.__startQRegularExpression) self.__menu.addAction( self.tr("Python re editor"), self.__startPyRe) self.__menu.addSeparator() @@ -365,11 +366,11 @@ """ self.__startProc("eric6_snap.py") - def __startQRegExp(self): + def __startQRegularExpression(self): """ - Private slot to start the eric6 QRegExp editor dialog. + Private slot to start the eric6 QRegularExpression editor dialog. """ - self.__startProc("eric6_qregexp.py") + self.__startProc("eric6_qregularexpression.py") def __startPyRe(self): """
--- a/eric6/UI/LogView.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/UI/LogView.py Sun Oct 11 17:54:52 2020 +0200 @@ -8,7 +8,7 @@ """ -from PyQt5.QtCore import pyqtSignal, Qt, QRegExp +from PyQt5.QtCore import pyqtSignal, Qt, QRegularExpression from PyQt5.QtGui import QBrush, QTextCursor, QTextDocument from PyQt5.QtWidgets import ( QTextEdit, QApplication, QMenu, QWidget, QHBoxLayout, QSizePolicy @@ -258,9 +258,11 @@ if wholeWord: flags |= QTextDocument.FindWholeWords if regexp: - ok = self.find(QRegExp( + ok = self.find(QRegularExpression( txt, - Qt.CaseSensitive if caseSensitive else Qt.CaseInsensitive), + QRegularExpression.NoPatternOption + if caseSensitive + else QRegularExpression.CaseInsensitiveOption), flags ) else: @@ -289,9 +291,11 @@ if wholeWord: flags |= QTextDocument.FindWholeWords if regexp: - ok = self.find(QRegExp( + ok = self.find(QRegularExpression( txt, - Qt.CaseSensitive if caseSensitive else Qt.CaseInsensitive), + QRegularExpression.NoPatternOption + if caseSensitive + else QRegularExpression.CaseInsensitiveOption), flags ) else:
--- a/eric6/Utilities/__init__.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/Utilities/__init__.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,7 +7,6 @@ Package implementing various functions/classes needed everywhere within eric6. """ - import os import sys import codecs @@ -43,8 +42,8 @@ from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF32 from PyQt5.QtCore import ( - QRegExp, QDir, QProcess, Qt, QByteArray, qVersion, PYQT_VERSION_STR, - QCoreApplication, QCryptographicHash + qVersion, PYQT_VERSION_STR, QDir, QProcess, QByteArray, QCoreApplication, + QCryptographicHash ) from PyQt5.Qsci import QSCINTILLA_VERSION_STR, QsciScintilla @@ -1365,7 +1364,7 @@ @param s option string (string or string) @return list of options (list of strings) """ - rx = QRegExp(r"""\s([\w=/-]*"[^"]+"|[\w=/-]*'[^']+'|[^\s]+)""") + rx = re.compile(r"""\s([\w=/-]*"[^"]+"|[\w=/-]*'[^']+'|[^\s]+)""") s = re.sub(r"%[A-Z%]", _percentReplacementFunc, s) return parseString(s, rx) @@ -1378,7 +1377,7 @@ @param s environment string (string) @return list of environment settings (list of strings) """ - rx = QRegExp(r"""\s(\w+\+?=[^\s]+|\w+="[^"]+"|\w+='[^']+')""") + rx = re.compile(r"""\s(\w+\+?=[^\s]+|\w+="[^"]+"|\w+='[^']+')""") return parseString(s, rx) @@ -1386,24 +1385,25 @@ """ Function used to convert a string into a list. - @param s string to be parsed (string) - @param rx regex defining the parse pattern (QRegExp) - @return list of parsed data (list of strings) + @param s string to be parsed + @type str + @param rx regular expression object defining the parse pattern + @type re.Pattern + @return list of parsed data + @rtype list of str """ olist = [] - if not s.startswith(' '): - # prepare the string to fit our pattern - s = ' ' + s + if s: + if not s.startswith(' '): + # prepare the string to fit our pattern + s = ' ' + s - pos = rx.indexIn(s) - while pos != -1: - cs = rx.cap(1) - if cs.startswith('"') or cs.startswith("'"): - cs = cs[1:-1] - olist.append(cs) - pos += rx.matchedLength() - pos = rx.indexIn(s, pos) - + for match in rx.finditer(s): + cs = match.group(1) + if cs.startswith('"') or cs.startswith("'"): + cs = cs[1:-1] + olist.append(cs) + return olist @@ -1662,6 +1662,25 @@ return pyVer +def rxIndex(rx, txt): + """ + Function to get the index (start position) of a regular expression match + within some text. + + @param rx regular expression object as created by re.compile() + @type re.Pattern + @param txt text to be scanned + @type str + @return start position of the match or -1 indicating no match was found + @rtype int + """ + match = rx.search(txt) + if match is None: + return -1 + else: + return match.start() + + ############################################################################### # functions for environment handling ############################################################################### @@ -1677,33 +1696,39 @@ @return the requested entry or the default value, if the entry wasn't found (string or None) """ - filterRe = QRegExp("^{0}[ \t]*=".format(key)) + pattern = "^{0}[ \t]*=".format(key) if isWindowsPlatform(): - filterRe.setCaseSensitivity(Qt.CaseInsensitive) + filterRe = re.compile(pattern, re.IGNORECASE) + else: + filterRe = re.compile(pattern) entries = [e for e in QProcess.systemEnvironment() - if filterRe.indexIn(e) != -1] + if filterRe.search(e) is not None] if not entries: return default # if there are multiple entries, just consider the first one - ename, val = entries[0].split("=", 1) - return val.strip() + ename, value = entries[0].split("=", 1) + return value.strip() def hasEnvironmentEntry(key): """ Module function to check, if the environment contains an entry. - @param key key of the requested environment entry (string) - @return flag indicating the presence of the requested entry (boolean) + @param key key of the requested environment entry + @type str + @return flag indicating the presence of the requested entry + @rtype bool """ - filterRe = QRegExp("^{0}[ \t]*=".format(key)) + pattern = "^{0}[ \t]*=".format(key) if isWindowsPlatform(): - filterRe.setCaseSensitivity(Qt.CaseInsensitive) + filterRe = re.compile(pattern, re.IGNORECASE) + else: + filterRe = re.compile(pattern) entries = [e for e in QProcess.systemEnvironment() - if filterRe.indexIn(e) != -1] + if filterRe.search(e) is not None] return len(entries) > 0 ###############################################################################
--- a/eric6/ViewManager/ViewManager.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/ViewManager/ViewManager.py Sun Oct 11 17:54:52 2020 +0200 @@ -4,15 +4,15 @@ # """ -Module implementing the viewmanager base class. +Module implementing the view manager base class. """ - +import re import os from PyQt5.QtCore import ( - pyqtSignal, pyqtSlot, QSignalMapper, QTimer, QFileInfo, QRegExp, Qt, - QCoreApplication, QPoint + pyqtSignal, pyqtSlot, Qt, QSignalMapper, QTimer, QFileInfo, QPoint, + QCoreApplication ) from PyQt5.QtGui import QColor, QKeySequence, QPalette, QPixmap from PyQt5.QtWidgets import ( @@ -89,10 +89,10 @@ class ViewManager(QWidget): """ - Base class inherited by all specific viewmanager classes. + Base class inherited by all specific view manager classes. It defines the interface to be implemented by specific - viewmanager classes and all common methods. + view manager classes and all common methods. @signal changeCaption(str) emitted if a change of the caption is necessary @signal editorChanged(str) emitted when the current editor has changed @@ -5925,12 +5925,14 @@ line, index = aw.getCursorPosition() text = aw.text(line) - reg = QRegExp(r'[^\w_]') - end = reg.indexIn(text, index) - if end > index: - ext = text[index:end] - txt += ext - self.quickFindtextCombo.lineEdit().setText(txt) + rx = re.compile(r'[^\w_]') + match = rx.search(text, index) + if match: + end = match.start() + if end > index: + ext = text[index:end] + txt += ext + self.quickFindtextCombo.lineEdit().setText(txt) def showSearchWidget(self): """ @@ -7187,12 +7189,12 @@ self.activeWindow().getFileName() ): ext = os.path.splitext(self.activeWindow().getFileName())[1] - rx = QRegExp(r".*\*\.{0}[ )].*".format(ext[1:])) + rx = re.compile(r".*\*\.{0}[ )].*".format(ext[1:])) import QScintilla.Lexers filters = QScintilla.Lexers.getOpenFileFiltersList() index = -1 for i in range(len(filters)): - if rx.exactMatch(filters[i]): + if rx.fullmatch(filters[i]): index = i break if index == -1:
--- a/eric6/WebBrowser/AdBlock/AdBlockRule.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/WebBrowser/AdBlock/AdBlockRule.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,12 +7,10 @@ Module implementing the AdBlock rule class. """ - import re - from enum import IntEnum -from PyQt5.QtCore import Qt, QRegExp +from PyQt5.QtCore import Qt from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInfo @@ -276,8 +274,10 @@ if parsedLine.startswith("/") and parsedLine.endswith("/"): parsedLine = parsedLine[1:-1] self.__type = AdBlockRuleType.RegExpMatchRule - self.__regExp = QRegExp(parsedLine, self.__caseSensitivity, - QRegExp.RegExp) + if self.__caseSensitivity: + self.__regExp = re.compile(parsedLine) + else: + self.__regExp = re.compile(parsedLine, re.IGNORECASE) self.__stringMatchers = self.__parseRegExpFilter(parsedLine) return @@ -302,12 +302,14 @@ return # If there is still a wildcard (*) or separator (^) or (|), - # the rule must be modified to comply with QRegExp. + # the rule must be modified to comply with re. if "*" in parsedLine or "^" in parsedLine or "|" in parsedLine: self.__type = AdBlockRuleType.RegExpMatchRule pattern = self.__convertPatternToRegExp(parsedLine) - self.__regExp = QRegExp(pattern, self.__caseSensitivity, - QRegExp.RegExp) + if self.__caseSensitivity: + self.__regExp = re.compile(pattern) + else: + self.__regExp = re.compile(pattern, re.IGNORECASE) self.__stringMatchers = self.__parseRegExpFilter(parsedLine) return @@ -505,7 +507,7 @@ if not self.__isMatchingRegExpStrings(encodedUrl): matched = False else: - matched = self.__regExp.indexIn(encodedUrl) != -1 + matched = self.__regExp.search(encodedUrl) is not None elif self.__type == AdBlockRuleType.MatchAllUrlsRule: matched = True @@ -1153,10 +1155,11 @@ @return tuple containing the regular expression and the list of string matchers - @rtype tuple of (QRegExp, list of str) + @rtype tuple of (re.Pattern, list of str) """ if self.__regExp is not None: - return (QRegExp(self.__regExp), self.__stringMatchers[:]) + return (re.compile(self.__regExp.pattern), + self.__stringMatchers[:]) else: return (None, [])
--- a/eric6/WebBrowser/Bookmarks/NsHtmlReader.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/WebBrowser/Bookmarks/NsHtmlReader.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,9 @@ Module implementing a class to read Netscape HTML bookmark files. """ +import re -from PyQt5.QtCore import QObject, QIODevice, QFile, QRegExp, Qt, QDateTime +from PyQt5.QtCore import QObject, QIODevice, QFile, QDateTime from .BookmarkNode import BookmarkNode @@ -27,32 +28,17 @@ """ super(NsHtmlReader, self).__init__() - self.__folderRx = QRegExp("<DT><H3(.*)>(.*)</H3>", Qt.CaseInsensitive) - self.__folderRx.setMinimal(True) - - self.__endFolderRx = QRegExp("</DL>", Qt.CaseInsensitive) - - self.__bookmarkRx = QRegExp("<DT><A(.*)>(.*)</A>", Qt.CaseInsensitive) - self.__bookmarkRx.setMinimal(True) - - self.__descRx = QRegExp("<DD>(.*)", Qt.CaseInsensitive) - - self.__separatorRx = QRegExp("<HR>", Qt.CaseInsensitive) - - self.__urlRx = QRegExp('HREF="(.*)"', Qt.CaseInsensitive) - self.__urlRx.setMinimal(True) - - self.__addedRx = QRegExp(r'ADD_DATE="(\d*)"', Qt.CaseInsensitive) - self.__addedRx.setMinimal(True) - - self.__modifiedRx = QRegExp( - r'LAST_MODIFIED="(\d*)"', Qt.CaseInsensitive) - self.__modifiedRx.setMinimal(True) - - self.__visitedRx = QRegExp(r'LAST_VISIT="(\d*)"', Qt.CaseInsensitive) - self.__visitedRx.setMinimal(True) - - self.__foldedRx = QRegExp("FOLDED", Qt.CaseInsensitive) + self.__folderRx = re.compile("<DT><H3(.*?)>(.*?)</H3>", re.IGNORECASE) + self.__endFolderRx = re.compile("</DL>", re.IGNORECASE) + self.__bookmarkRx = re.compile("<DT><A(.*?)>(.*?)</A>", re.IGNORECASE) + self.__descRx = re.compile("<DD>(.*)", re.IGNORECASE) + self.__separatorRx = re.compile("<HR>", re.IGNORECASE) + self.__urlRx = re.compile('HREF="(.*?)"', re.IGNORECASE) + self.__addedRx = re.compile(r'ADD_DATE="(\d*?)"', re.IGNORECASE) + self.__modifiedRx = re.compile(r'LAST_MODIFIED="(\d*?)"', + re.IGNORECASE) + self.__visitedRx = re.compile(r'LAST_VISIT="(\d*?)"', re.IGNORECASE) + self.__foldedRx = re.compile("FOLDED", re.IGNORECASE) def read(self, fileNameOrDevice): """ @@ -79,49 +65,64 @@ while not dev.atEnd(): line = str(dev.readLine(), encoding="utf-8").rstrip() - if self.__folderRx.indexIn(line) != -1: + match = ( + self.__folderRx.search(line) or + self.__endFolderRx.search(line) or + self.__bookmarkRx.search(line) or + self.__descRx.search(line) or + self.__separatorRx.search(line) + ) + if match is None: + continue + + if match.re is self.__folderRx: # folder definition - arguments = self.__folderRx.cap(1) - name = self.__folderRx.cap(2) + arguments = match.group(1) + name = match.group(2) node = BookmarkNode(BookmarkNode.Folder, folders[-1]) node.title = Utilities.html_udecode(name) - node.expanded = self.__foldedRx.indexIn(arguments) == -1 - if self.__addedRx.indexIn(arguments) != -1: + node.expanded = self.__foldedRx.search(arguments) is None + addedMatch = self.__addedRx.search(arguments) + if addedMatch is not None: node.added = QDateTime.fromTime_t( - int(self.__addedRx.cap(1))) + int(addedMatch.group(1))) folders.append(node) lastNode = node - elif self.__endFolderRx.indexIn(line) != -1: + elif match.re is self.__endFolderRx: # end of folder definition folders.pop() - elif self.__bookmarkRx.indexIn(line) != -1: + elif match.re is self.__bookmarkRx: # bookmark definition - arguments = self.__bookmarkRx.cap(1) - name = self.__bookmarkRx.cap(2) + arguments = match.group(1) + name = match.group(2) node = BookmarkNode(BookmarkNode.Bookmark, folders[-1]) node.title = Utilities.html_udecode(name) - if self.__urlRx.indexIn(arguments) != -1: - node.url = self.__urlRx.cap(1) - if self.__addedRx.indexIn(arguments) != -1: + match1 = self.__urlRx.search(arguments) + if match1 is not None: + node.url = match1.group(1) + match1 = self.__addedRx.search(arguments) + if match1 is not None: node.added = QDateTime.fromTime_t( - int(self.__addedRx.cap(1))) - if self.__modifiedRx.indexIn(arguments) != -1: + int(match1.group(1))) + match1 = self.__modifiedRx.search(arguments) + if match1 is not None: node.modified = QDateTime.fromTime_t( - int(self.__modifiedRx.cap(1))) - if self.__visitedRx.indexIn(arguments) != -1: + int(match1.group(1))) + match1 = self.__visitedRx.search(arguments) + if match1 is not None: node.visited = QDateTime.fromTime_t( - int(self.__visitedRx.cap(1))) + int(match1.group(1))) lastNode = node - elif self.__descRx.indexIn(line) != -1: + elif match.re is self.__descRx: # description if lastNode: lastNode.desc = Utilities.html_udecode( - self.__descRx.cap(1)) + match.group(1)) - elif self.__separatorRx.indexIn(line) != -1: + elif match.re is self.__separatorRx: # separator definition BookmarkNode(BookmarkNode.Separator, folders[-1])
--- a/eric6/WebBrowser/GreaseMonkey/GreaseMonkeyScript.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/WebBrowser/GreaseMonkey/GreaseMonkeyScript.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,10 +7,10 @@ Module implementing the GreaseMonkey script. """ +import re from PyQt5.QtCore import ( - pyqtSignal, pyqtSlot, QObject, QUrl, QRegExp, QByteArray, - QCryptographicHash + pyqtSignal, pyqtSlot, QObject, QUrl, QByteArray, QCryptographicHash ) from PyQt5.QtGui import QIcon, QPixmap, QImage from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply @@ -284,10 +284,13 @@ if self.__fileName not in self.__fileWatcher.files(): self.__fileWatcher.addPath(self.__fileName) - rx = QRegExp("// ==UserScript==(.*)// ==/UserScript==") - rx.indexIn(fileData) - metaDataBlock = rx.cap(1).strip() + rx = re.compile("// ==UserScript==(.*)// ==/UserScript==") + match = rx.search(fileData) + if match is None: + # invalid script file + return + metaDataBlock = match.group(1).strip() if metaDataBlock == "": # invalid script file return
--- a/eric6/WebBrowser/History/HistoryCompleter.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/WebBrowser/History/HistoryCompleter.py Sun Oct 11 17:54:52 2020 +0200 @@ -7,8 +7,9 @@ Module implementing a special completer for the history. """ +import re -from PyQt5.QtCore import Qt, QRegExp, QTimer, QSortFilterProxyModel +from PyQt5.QtCore import Qt, QTimer, QSortFilterProxyModel from PyQt5.QtWidgets import QTableView, QAbstractItemView, QCompleter from .HistoryModel import HistoryModel @@ -76,9 +77,8 @@ super(HistoryCompletionModel, self).__init__(parent) self.__searchString = "" - self.__searchMatcher = QRegExp( - "", Qt.CaseInsensitive, QRegExp.FixedString) - self.__wordMatcher = QRegExp("", Qt.CaseInsensitive) + self.__searchMatcher = None + self.__wordMatcher = None self.__isValid = False self.setDynamicSortFilter(True) @@ -115,20 +115,19 @@ """ return self.__searchString - def setSearchString(self, string): + def setSearchString(self, sstring): """ Public method to set the current search string. - @param string new search string (string) + @param sstring new search string (string) """ - if string == self.__searchString: - return - - self.__searchString = string - self.__searchMatcher.setPattern(self.__searchString) - self.__wordMatcher.setPattern( - "\\b" + QRegExp.escape(self.__searchString)) - self.invalidateFilter() + if sstring != self.__searchString: + self.__searchString = sstring + self.__searchMatcher = re.compile( + re.escape(self.__searchString), re.IGNORECASE) + self.__wordMatcher = re.compile( + r"\b" + re.escape(self.__searchString), re.IGNORECASE) + self.invalidateFilter() def isValid(self): """ @@ -161,18 +160,19 @@ @param sourceParent index of the source item (QModelIndex) @return flag indicating acceptance (boolean) """ - # Do a case-insensitive substring match against both the url and title. - # It's already ensured, that the user doesn't accidentally use regexp - # metacharacters (s. setSearchString()). - idx = self.sourceModel().index(sourceRow, 0, sourceParent) - - url = self.sourceModel().data(idx, HistoryModel.UrlStringRole) - if self.__searchMatcher.indexIn(url) != -1: - return True - - title = self.sourceModel().data(idx, HistoryModel.TitleRole) - if self.__searchMatcher.indexIn(title) != -1: - return True + if self.__searchMatcher is not None: + # Do a case-insensitive substring match against both the url and + # title. It's already ensured, that the user doesn't accidentally + # use regexp metacharacters (s. setSearchString()). + idx = self.sourceModel().index(sourceRow, 0, sourceParent) + + url = self.sourceModel().data(idx, HistoryModel.UrlStringRole) + if self.__searchMatcher.search(url) is not None: + return True + + title = self.sourceModel().data(idx, HistoryModel.TitleRole) + if self.__searchMatcher.search(title) is not None: + return True return False @@ -188,9 +188,12 @@ "www.phoronix.com" a bonus for "ph", it does NOT make sense to give "www.yadda.com/foo.php" the bonus. - @param left index of left item (QModelIndex) - @param right index of right item (QModelIndex) - @return true, if left is less than right (boolean) + @param left index of left item + @type QModelIndex + @param right index of right item + @type QModelIndex + @return true, if left is less than right + @rtype bool """ frequency_L = self.sourceModel().data( left, HistoryFilterModel.FrequencyRole) @@ -198,8 +201,9 @@ title_L = self.sourceModel().data(left, HistoryModel.TitleRole) if ( - self.__wordMatcher.indexIn(url_L) != -1 or - self.__wordMatcher.indexIn(title_L) != -1 + self.__wordMatcher is not None and + (bool(self.__wordMatcher.search(url_L)) or + bool(self.__wordMatcher.search(title_L))) ): frequency_L *= 2 @@ -209,8 +213,9 @@ title_R = self.sourceModel().data(right, HistoryModel.TitleRole) if ( - self.__wordMatcher.indexIn(url_R) != -1 or - self.__wordMatcher.indexIn(title_R) != -1 + self.__wordMatcher is not None and + (bool(self.__wordMatcher.search(url_R)) or + bool(self.__wordMatcher.search(title_R))) ): frequency_R *= 2
--- a/eric6/WebBrowser/Network/NetworkUrlInterceptor.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/WebBrowser/Network/NetworkUrlInterceptor.py Sun Oct 11 17:54:52 2020 +0200 @@ -91,8 +91,10 @@ Private method to load the Network Manager settings. """ with E5MutexLocker(self.__mutex): - self.__doNotTrack = Preferences.getWebBrowser("DoNotTrack") - self.__sendReferer = Preferences.getWebBrowser("RefererSendReferer") + self.__doNotTrack = Preferences.getWebBrowser( + "DoNotTrack") + self.__sendReferer = Preferences.getWebBrowser( + "RefererSendReferer") self.__refererDefaultPolicy = Preferences.getWebBrowser( "RefererDefaultPolicy") self.__refererTrimmingPolicy = Preferences.getWebBrowser(
--- a/eric6/WebBrowser/Session/SessionManager.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/WebBrowser/Session/SessionManager.py Sun Oct 11 17:54:52 2020 +0200 @@ -453,7 +453,8 @@ # restore additional windows for data in sessionData["Windows"]: window = ( - WebBrowserWindow.mainWindow().newWindow(restoreSession=True) + WebBrowserWindow.mainWindow().newWindow( + restoreSession=True) ) window.tabWidget().loadFromSessionData(data) if "WindowGeometry" in data:
--- a/eric6/eric6_qregexp.py Sat Oct 10 16:03:53 2020 +0200 +++ b/eric6/eric6_qregexp.py Sun Oct 11 17:54:52 2020 +0200 @@ -12,7 +12,7 @@ version of the integrated QRegExp wizard. """ - +# TODO: delete deprecated QRegExp wizard or move to external plug-in import sys import os
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eric6/icons/breeze-dark/callTraceStop.svg Sun Oct 11 17:54:52 2020 +0200 @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> + <style type="text/css">.ColorScheme-Text { + color:#eff0f1; + }</style> + <path class="ColorScheme-Text" d="m3 3h16v16h-16z" fill="currentColor"/> +</svg>
--- a/eric6/icons/breeze-dark/callTraveStop.svg Sat Oct 10 16:03:53 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> - <style type="text/css">.ColorScheme-Text { - color:#eff0f1; - }</style> - <path class="ColorScheme-Text" d="m3 3h16v16h-16z" fill="currentColor"/> -</svg>
--- a/scripts/install.py Sat Oct 10 16:03:53 2020 +0200 +++ b/scripts/install.py Sun Oct 11 17:54:52 2020 +0200 @@ -717,11 +717,10 @@ for name in ["eric6_compare", "eric6_configure", "eric6_diff", "eric6_editor", "eric6_hexeditor", "eric6_iconeditor", "eric6_plugininstall", "eric6_pluginrepository", - "eric6_pluginuninstall", "eric6_qregexp", - "eric6_qregularexpression", "eric6_re", "eric6_snap", - "eric6_sqlbrowser", "eric6_tray", "eric6_trpreviewer", - "eric6_uipreviewer", "eric6_unittest", "eric6_browser", - "eric6_shell", "eric6"]: + "eric6_pluginuninstall", "eric6_qregularexpression", + "eric6_re", "eric6_snap", "eric6_sqlbrowser", "eric6_tray", + "eric6_trpreviewer", "eric6_uipreviewer", "eric6_unittest", + "eric6_browser", "eric6_shell", "eric6"]: wnames.append(createPyWrapper(cfg['ericDir'], name, scriptsDir)) # set install prefix, if not None
--- a/setup.py Sat Oct 10 16:03:53 2020 +0200 +++ b/setup.py Sun Oct 11 17:54:52 2020 +0200 @@ -342,7 +342,6 @@ "eric6_plugininstall = eric6.eric6_plugininstall:main", "eric6_pluginrepository = eric6.eric6_pluginrepository:main", "eric6_pluginuninstall = eric6.eric6_pluginuninstall:main", - "eric6_qregexp = eric6.eric6_qregexp:main", "eric6_qregularexpression = eric6.eric6_qregularexpression:main", "eric6_re = eric6.eric6_re:main", "eric6_shell = eric6.eric6_shell:main",