Commit 867247ad authored by jkotan's avatar jkotan
Browse files

New upstream version 2.1.0

parent 5da3aa7c
Metadata-Version: 1.2
Name: nxsconfigtool
Version: 2.0.6
Version: 2.1.0
Summary: Configuration tool for creating components
Home-page: https://github.com/nexdatas/configtool/
Author: Jan Kotanski, Eugen Wintersberger , Halil Pasic
......
Metadata-Version: 1.2
Name: nxsconfigtool
Version: 2.0.6
Version: 2.1.0
Summary: Configuration tool for creating components
Home-page: https://github.com/nexdatas/configtool/
Author: Jan Kotanski, Eugen Wintersberger , Halil Pasic
......
......@@ -21,7 +21,8 @@
""" widget for different types of datasources """
from PyQt5.QtCore import (Qt, )
from PyQt5.QtCore import (Qt, QRegExp)
from PyQt5.QtGui import (QFontMetrics, QSyntaxHighlighter)
from PyQt5.QtWidgets import (QMessageBox, QTableWidgetItem)
from PyQt5.QtXml import (QDomDocument)
from PyQt5 import uic
......@@ -55,6 +56,161 @@ if sys.version_info > (3,):
unicode = str
class FormatRule(object):
__slots__ = 'expression', 'fmt', 'index'
def __init__(self, expression, fmt, index=0):
self.expression = expression
self.fmt = fmt
self.index = index
class SectionFormatRule(object):
__slots__ = 'startExp', 'endExp', 'fmt', 'state', 'index'
def __init__(self, startExp, endExp, fmt, state=-1, index=-1):
self.startExp = startExp
self.endExp = endExp
self.fmt = fmt
self.state = state
self.index = index
def reset(self):
self.index = -1
def nextStart(self, text, start=None):
if start is not None:
if start < self.index:
return self.index
self.index = self.startExp.indexIn(text, start)
else:
self.index = self.startExp.indexIn(text)
return self.index
class PyEvalHighlighter(QSyntaxHighlighter):
def __init__(self, document):
QSyntaxHighlighter.__init__(self, document)
keywords = [
'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del',
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from',
'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal',
'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'with',
'while', 'yield', 'None', 'True', 'False', 'self'
]
operators = [
'\\^', '\\|', '\\&', '\\~', '>>', '<<', '\\%', '\\*\\*', '\\+=',
'-=', '\\*=', '/=', '\\%=', '=', '==', '!=', '<', '<=', '>',
'>=', '\\+', '-', '\\*', '/', '//', '\\.'
]
self.rules = []
self.rules.extend(
[FormatRule(QRegExp(r'\b%s\b' % kw), Qt.blue)
for kw in keywords])
self.rules.extend(
[FormatRule(QRegExp(r'%s' % op), Qt.darkGreen)
for op in operators])
self.rules.extend(
[FormatRule(QRegExp(r'\bdef\b\s*(\w+)'), Qt.darkBlue, 1),
FormatRule(QRegExp(r'\bclass\b\s*(\w+)'), Qt.darkBlue, 1)])
# numeric
self.rules.extend(
[FormatRule(QRegExp(r'\b[+-]?[0-9]+[lL]?\b'), Qt.darkBlue),
FormatRule(QRegExp(r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b'),
Qt.darkBlue),
FormatRule(QRegExp(
r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b'),
Qt.darkBlue)])
# datasources
self.rules.append(
FormatRule(
QRegExp(r'\bds.[A-Za-z\(\)\.\$\_]+\b'), Qt.magenta))
self.sectionrules = []
# comments
self.sectionrules.append(
SectionFormatRule(QRegExp(r'#[^\n]*'), None, Qt.gray, 1))
# multi-line strings
self.sectionrules.extend(
[SectionFormatRule(
QRegExp(r'"""'), QRegExp(r'"""'), Qt.darkMagenta, 2),
SectionFormatRule(
QRegExp(r"'''"), QRegExp(r"'''"), Qt.darkMagenta, 3)])
# strings
self.sectionrules.extend(
[SectionFormatRule(
QRegExp(r'"[^"\\]*(\\.[^"\\]*)*"'), None, Qt.darkMagenta, 4),
SectionFormatRule(
QRegExp(r"'[^'\\]*(\\.[^'\\]*)*'"), None, Qt.darkMagenta, 5)])
def highlightBlock(self, text):
for rule in self.rules:
index = rule.expression.indexIn(text)
while index >= 0:
index = rule.expression.pos(rule.index)
length = len(str(rule.expression.cap(rule.index)))
self.setFormat(index, length, rule.fmt)
index = rule.expression.indexIn(text, index + length)
self.setCurrentBlockState(0)
for scrule in self.sectionrules:
scrule.reset()
state = self.previousBlockState()
size = 0
currentrule = None
if self.previousBlockState() > 0:
start = 0
else:
state = -1
start = -1
for scrule in self.sectionrules:
rlstart = scrule.nextStart(text)
if rlstart >= 0 and (start < 0 or rlstart < start):
start = rlstart
size = scrule.startExp.matchedLength()
state = scrule.state
while start >= 0 and state > 0:
currentrule = self.sectionrules[state - 1]
if currentrule.endExp is not None:
end = currentrule.endExp.indexIn(text, start + size)
if end >= size:
length = end - start + size + \
currentrule.endExp.matchedLength()
self.setCurrentBlockState(0)
else:
length = len(str(text)) - start + size
self.setCurrentBlockState(state)
else:
length = len(str(currentrule.startExp.cap(0)))
self.setCurrentBlockState(0)
self.setFormat(start, length, currentrule.fmt)
state = -1
newstart = -1
for scrule in self.sectionrules:
rlstart = scrule.nextStart(text, start + length)
if rlstart >= 0 and (newstart < 0 or rlstart < newstart):
start = rlstart
newstart = rlstart
size = scrule.startExp.matchedLength()
state = scrule.state
if state < 0:
start = -1
# CLIENT dialog impementation
class ClientSource(object):
# allowed subitems
......@@ -753,7 +909,18 @@ class PyEvalSource(object):
# connects the dialog actions
def connectWidgets(self):
pass
self.ui.peInputLineEdit.setStyleSheet("color: magenta")
self.ui.peResultLineEdit.setStyleSheet("color: magenta")
font = self.ui.peScriptTextEdit.font()
metrics = QFontMetrics(font)
tabStop = 4
if hasattr(self.ui.peScriptTextEdit, "setTabStopDistance"):
self.ui.peScriptTextEdit.setTabStopDistance(
tabStop * metrics.width(' '))
else:
self.ui.peScriptTextEdit.setTabStopWidth(
tabStop * metrics.width(' '))
self.highlighter = PyEvalHighlighter(self.ui.peScriptTextEdit)
# sets the tab order of subframe
# \param first first widget from the parent dialog
......@@ -828,6 +995,7 @@ class PyEvalSource(object):
if hasattr(self.ui, "dQueryLineEdit"):
self.ui.dQueryLineEdit.setFocus()
return
script = script.replace('\t', ' ')
datasource.var['PYEVAL'].script = script
# creates datasource nodes
......@@ -847,7 +1015,8 @@ class PyEvalSource(object):
datasource.var['PYEVAL'].script if (
len(datasource.var['PYEVAL'].script) > 0 and
datasource.var['PYEVAL'].script[0] == '\n') else (
"\n" + datasource.var['PYEVAL'].script)))
"\n" + datasource.var['PYEVAL'].script))
.replace("\t", " "))
res.appendChild(script)
elem.appendChild(res)
if datasource.var['PYEVAL'].input:
......
......@@ -20,4 +20,4 @@
""" release version module """
#: version number
__version__ = "2.0.6"
__version__ = "2.1.0"
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>412</width>
<height>354</height>
<width>527</width>
<height>372</height>
</rect>
</property>
<property name="windowTitle">
......@@ -96,7 +96,16 @@
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="margin">
<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 row="0" column="1">
......@@ -137,6 +146,12 @@
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
......@@ -144,6 +159,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
......@@ -152,6 +173,12 @@
</property>
</widget>
<widget class="QFrame" name="docFrame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
......@@ -169,6 +196,18 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="docLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>&amp;Doc:</string>
</property>
......@@ -178,7 +217,20 @@
</widget>
</item>
<item>
<widget class="QTextEdit" name="docTextEdit"/>
<widget class="QTextEdit" name="docTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
......@@ -195,7 +247,16 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<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 row="0" column="0">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment