-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
81 lines (70 loc) · 2.26 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from PyQt5 import QtCore
class PandasModel(QtCore.QAbstractTableModel):
"""
Class to populate a table view with a pandas dataframe
"""
def __init__(self, data, parent=None):
QtCore.QAbstractTableModel.__init__(self, parent)
self._data = data
def rowCount(self, parent=None):
return len(self._data.values)
def columnCount(self, parent=None):
return self._data.columns.size
def data(self, index, role=QtCore.Qt.DisplayRole):
if index.isValid():
if role == QtCore.Qt.DisplayRole:
return str(self._data.values[index.row()][index.column()])
return None
def headerData(self, col, orientation, role):
if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
return self._data.columns[col]
return None
def iterator2dataframes(iterator, chunk_size: int):
records = []
frames = []
for i, record in enumerate(iterator):
records.append(record)
if i % chunk_size == chunk_size - 1:
frames.append(pd.DataFrame(records))
records = []
if records:
frames.append(pd.DataFrame(records))
return pd.concat(frames)
keywords = [
"use", "select", "as", "then", "case", "end",
"from", "where", "group by", "order by", "desc", "asc",
"distinct", "on", "left join", "right join", "count",
"sum", "max", "min","distinct", "and", "in", "or",
"date","NOW", "like",
]
# Python operators
operators = [
"&&", "between", "binary", "&",
"\\^", "=", ">=", ">",
"is null", "null", "<=", "<",
" like ", "regexp", "not", ";",",",
]
# Python braces
braces = [
'\{', '\}', '\(', '\)', '\[', '\]',
]
"""
void MyWidget::paintEvent(QPaintEvent* /*event*/) {
QColor backgroundColor = palette().light().color();
backgroundColor.setAlpha(200);
QPainter customPainter(this);
customPainter.fillRect(rect(),backgroundColor);
}
"""
"""
def keyPressEvent(self, event):
key = event.key()
if key == Qt.Key_Enter:
#For Enter of keyboard number
print("key Enter press")
self.updateUi()
if key == Qt.Key_Return:
#For Enter of keyboard
print("key Enter press")
self.updateUi()
"""