-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiagnoseEmptyOverwriteWithAModPage.py
102 lines (73 loc) · 3.55 KB
/
DiagnoseEmptyOverwriteWithAModPage.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
97
98
99
100
101
102
import sys
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtWidgets import QFileDialog
if "mobase" not in sys.modules:
import mock_mobase as mobase
class DiagnoseEmptyOverwrite(mobase.IPluginDiagnose, mobase.IPluginModPage):
def __init__(self):
super(DiagnoseEmptyOverwrite, self).__init__()
mobase.IPluginModPage.__init__(self)
self.__organizer = None
def init(self, organizer):
self.__organizer = organizer
# Python doesn't like multi-line anonymous functions
organizer.modList().onModStateChanged(lambda modName, modState : self._invalidate() if modName == "Overwrite" or modName == u"Overwrite" else None)
return True
def name(self):
return "Empty Overwrite Diagnosis... with a mod page!"
def author(self):
return "AnyOldName3"
def description(self):
return self.__tr("Complains and bitches if your overwrite directory is empty... and adds a nearly useless mod page!")
def version(self):
return mobase.VersionInfo(2, 0, 0, mobase.ReleaseType.final)
def isActive(self):
return True
def settings(self):
return []
def activeProblems(self):
overwrite = self.__organizer.overwritePath()
if os.listdir(overwrite) == []:
return [0]
else:
return []
def shortDescription(self, key):
return self.__tr("Empty Overwrite directory")
def fullDescription(self, key):
return self.__tr("You've got nothing in your Overwrite directory. No human has any need to be <i>that</i> tidy. Press 'Fix' to create a blank file in the Overwrite directory.")
def hasGuidedFix(self, key):
return True
def startGuidedFix(self, key):
open(os.path.join(self.__organizer.overwritePath(), "blank file.txt"), 'a').close()
self.__organizer.refreshModList()
QMessageBox.information(None, self.__tr("File Created"), self.__tr("A blank file has been created in your Overwrite directory"))
def displayName(self):
#QMessageBox.information(None, "displayName", "displayName")
return "Probably TES Alliance"
def icon(self):
#QMessageBox.information(None, "icon", "icon")
return QIcon()
def pageURL(self):
#QMessageBox.information(None, "pageURL", "pageURL")
return QUrl("http://tesalliance.org")
def useIntegratedBrowser(self):
#QMessageBox.information(None, "useIntegratedBrowser", "useIntegratedBrowser")
return True
def handlesDownload(self, pageURL, downloadURL, fileInfo):
QMessageBox.information(None, "handlesDownload", "handlesDownload")
import re
if not re.match(r"https?://tesalliance.org/forums/index.php\?/files/download/([0-9]+)-([^/]+)/", pageURL.toString()):
return False
if not re.match(r"https?://tesalliance.org/forums/index.php\?/files/getdownload/([0-9]+)-([^/]+)/", downloadURL.toString()):
return False
# We now need to set the fields of fileInfo
return True
def setParentWidget(self, widget):
#QMessageBox.information(None, "setParentWidget", "setParentWidget")
pass
def __tr(self, str):
return QCoreApplication.translate("DiagnoseEmptyOverwrite", str)
def createPlugin():
return DiagnoseEmptyOverwrite()