-
Notifications
You must be signed in to change notification settings - Fork 0
/
sres.py
102 lines (83 loc) · 3.3 KB
/
sres.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import *
import os
import sharedFun
import webbrowser
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class SreS(QtGui.QWidget):
def __init__(self, sResult, lang, lines):
QMainWindow.__init__(self)
self.buttonsStack = []
self.searchTheStuff(sResult, lang, lines)
self.setObjectName(_fromUtf8("self"))
self.resize(500, 880)
self.label = QtGui.QLabel(self)
self.label.setGeometry(QtCore.QRect(20, 10, 321, 21))
font = QtGui.QFont()
font.setPointSize(11)
self.label.setFont(font)
self.label.setObjectName(_fromUtf8("label"))
self.pushButton = QtGui.QPushButton(self)
self.pushButton.setGeometry(QtCore.QRect(420, 830, 75, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton.clicked.connect(self.close)
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
def retranslateUi(self):
self.setWindowTitle(_translate("self", "Search Results", None))
self.label.setText(_translate("self", "Search Results:", None))
self.pushButton.setText(_translate("self", "Ok", None))
self.setFont()
def setFont(self):
font = QtGui.QFont()
font.setPointSize(8)
font.setBold(True)
self.pushButton.setFont(font)
def closeEvent(self,event):
self.close()
def searchTheStuff(self,sResult, lang, lines):
found = 0
data = sResult
Yinc = 25
path = sharedFun.selLang(lang, lines)
path = path.replace("\n","")
Y = 40
X = 20
results = 0
for path, dirs, files in os.walk(path, topdown=True):
for name in files:
if name.endswith('.txt'):
fullpath = os.path.join(path, name)
mail = self.open_close(fullpath)
if mail.find(data) != -1 and results < 64:
found = 1
self.buttonsStack.append(QtGui.QPushButton(self))
command = lambda checked, path=fullpath: webbrowser.open(path)
self.buttonsStack[results].clicked.connect(command)
self.buttonsStack[results].setText(_translate("self", name, None))
self.buttonsStack[results].setGeometry(QtCore.QRect(X, Y, 220, 20))
results = results+1
if results == 33:
X = 260
Y = 15
Y = Y + Yinc
if found == 0:
self.label = QtGui.QLabel(self)
self.label.setGeometry(QtCore.QRect(20, 40, 321, 21))
self.label.setText(_translate("self", "No templates have been found:", None))
def open_close(self,fullpath):
f1 = open(fullpath, 'r')
mail = f1.read()
f1.close()
return mail