eric6/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py

Wed, 29 May 2019 22:14:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 29 May 2019 22:14:02 +0200
branch
Variables Viewer
changeset 7030
73779c4c135a
parent 7005
342819f05839
child 7192
a22eee00b052
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.

6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
3 # Copyright (c) 2013 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the setup.py wizard dialog.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 try:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 str = unicode # __IGNORE_WARNING__
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 except NameError:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 pass
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import os
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import sys
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import datetime
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
20 from PyQt5.QtCore import pyqtSlot, Qt, QUrl
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem, \
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 QListWidgetItem, QApplication
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
23 from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 from E5Gui.E5Application import e5App
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from E5Gui import E5MessageBox, E5FileDialog
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 from E5Gui.E5Completers import E5DirCompleter
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 from .Ui_SetupWizardDialog import Ui_SetupWizardDialog
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import UI.PixmapCache
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 import Utilities
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 import Preferences
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 class SetupWizardDialog(QDialog, Ui_SetupWizardDialog):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Class implementing the setup.py wizard dialog.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 It displays a dialog for entering the parameters
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 for the E5MessageBox code generator.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
43 ClassifiersUrl = "https://pypi.org/pypi?%3Aaction=list_classifiers"
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
44
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 def __init__(self, parent=None):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 Constructor
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 @param parent reference to the parent widget (QWidget)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 super(SetupWizardDialog, self).__init__(parent)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.setupUi(self)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
54 self.__replies = []
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
55
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.dataTabWidget.setCurrentIndex(0)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__packageDirCompleter = E5DirCompleter(self.packageEdit)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__packageRootDirCompleter = E5DirCompleter(self.packageRootEdit)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__sourceDirCompleter = E5DirCompleter(self.sourceDirectoryEdit)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.packageRootDirButton.setIcon(UI.PixmapCache.getIcon("open.png"))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.packageDirButton.setIcon(UI.PixmapCache.getIcon("open.png"))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.sourceDirectoryButton.setIcon(UI.PixmapCache.getIcon("open.png"))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.variantComboBox.addItem(self.tr("distutils"), "distutils.core")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.variantComboBox.addItem(self.tr("setuptools"), "setuptools")
6940
12ed1a714527 SetupWizardDialog: change setup default method to 'setuptools' and fixed an issue causing an exception, if no classifiers were selected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
68 self.variantComboBox.setCurrentIndex(1)
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__mandatoryStyleSheet = "QLineEdit {border: 2px solid;}"
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 for lineEdit in [self.nameEdit, self.versionEdit,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.homePageUrlEdit, self.authorEdit,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.authorEmailEdit, self.maintainerEdit,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.maintainerEmailEdit]:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 lineEdit.setStyleSheet(self.__mandatoryStyleSheet)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
77 self.__loadClassifiersFromPyPI()
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__okButton.setEnabled(False)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 projectOpen = e5App().getObject("Project").isOpen()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.projectButton.setEnabled(projectOpen)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.autodiscoverPackagesButton.setEnabled(projectOpen)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.homePageUrlEdit.textChanged.connect(self.__enableOkButton)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.nameEdit.textChanged.connect(self.__enableOkButton)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.versionEdit.textChanged.connect(self.__enableOkButton)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.authorEdit.textChanged.connect(self.__enableOkButton)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.authorEmailEdit.textChanged.connect(self.__enableOkButton)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.maintainerEdit.textChanged.connect(self.__enableOkButton)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.maintainerEmailEdit.textChanged.connect(self.__enableOkButton)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def __enableOkButton(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 Private slot to set the state of the OK button.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 enable = (
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 bool(self.nameEdit.text()) and
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 bool(self.versionEdit.text()) and
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 bool(self.homePageUrlEdit.text()) and
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 ((bool(self.authorEdit.text()) and
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 bool(self.authorEmailEdit.text())) or
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 (bool(self.maintainerEdit.text()) and
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 bool(self.maintainerEmailEdit.text()))) and
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.homePageUrlEdit.text().startswith(("http://", "https://"))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 )
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.__okButton.setEnabled(enable)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
111 def __loadClassifiersFromPyPI(self):
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
112 """
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
113 Private method to populate the classifiers list with data retrieved
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
114 from PyPI.
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
115 """
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
116 request = QNetworkRequest(QUrl(SetupWizardDialog.ClassifiersUrl))
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
117 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
118 QNetworkRequest.AlwaysNetwork)
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
119 reply = e5App().getObject("UserInterface").networkAccessManager().get(
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
120 request)
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
121 reply.finished.connect(lambda: self.__classifiersDownloadDone(reply))
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
122 self.__replies.append(reply)
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
123
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
124 @pyqtSlot()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
125 def __classifiersDownloadDone(self, reply):
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
126 """
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
127 Private slot called, after the classifiers file has been downloaded
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
128 from the internet.
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
129
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
130 @param reply reference to the network reply
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
131 @type QNetworkReply
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
132 """
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
133 reply.deleteLater()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
134 if reply in self.__replies:
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
135 self.__replies.remove(reply)
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
136 if reply.error() == QNetworkReply.NoError:
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
137 ioEncoding = Preferences.getSystem("IOEncoding")
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
138 lines = str(reply.readAll(), ioEncoding, 'replace').splitlines()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
139
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
140 self.__populateClassifiers(lines)
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
141
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
142 reply.close()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
143
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
144 @pyqtSlot()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
145 def on_localClassifiersButton_clicked(self):
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 Private method to populate lists from the Trove list file.
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
148
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
149 Note: The trove list file was created from querying
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
150 "https://pypi.org/pypi?%3Aaction=list_classifiers".
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 filename = os.path.join(os.path.dirname(__file__),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 "data", "trove_classifiers.txt")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 try:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 f = open(filename, "r")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 lines = f.readlines()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 f.close()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 except (IOError, OSError) as err:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 E5MessageBox.warning(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 self.tr("Reading Trove Classifiers"),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.tr("""<p>The Trove Classifiers file <b>{0}</b>"""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """ could not be read.</p><p>Reason: {1}</p>""")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 .format(filename, str(err)))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 return
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
167 self.__populateClassifiers(lines)
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
168
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
169 def __populateClassifiers(self, classifiers):
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
170 """
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
171 Private method to populate the classifiers.
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
172
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
173 @param classifiers list of classifiers read from a local file or
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
174 retrieved from PyPI
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
175 @type list of str
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
176 """
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
177 self.licenseClassifierComboBox.clear()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
178 self.classifiersList.clear()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
179 self.developmentStatusComboBox.clear()
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
180
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
181 self.developmentStatusComboBox.addItem("", "")
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
182
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.__classifiersDict = {}
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
184 for line in classifiers:
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 line = line.strip()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 if line.startswith("License "):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.licenseClassifierComboBox.addItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 "/".join(line.split(" :: ")[1:]),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 line
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 )
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 elif line.startswith("Development Status "):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 self.developmentStatusComboBox.addItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 line.split(" :: ")[1], line)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.__addClassifierEntry(line)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self.__classifiersDict = {}
7005
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
197
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
198 self.licenseClassifierComboBox.setCurrentIndex(
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
199 self.licenseClassifierComboBox.findText(
342819f05839 setup.py Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
200 "(GPLv3)", Qt.MatchContains | Qt.MatchCaseSensitive))
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 def __addClassifierEntry(self, line):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 Private method to add a new entry to the list of trove classifiers.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @param line line containing the data for the entry (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 itm = None
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 pitm = None
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 dataList = line.split(" :: ")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 for index in range(len(dataList)):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 key = " :: ".join(dataList[:index + 1])
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 if key not in self.__classifiersDict:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 if pitm is None:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 itm = QTreeWidgetItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.classifiersList, [dataList[index]])
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 pitm = itm
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 itm = QTreeWidgetItem(pitm, [dataList[index]])
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 itm.setExpanded(True)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 self.__classifiersDict[key] = itm
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 pitm = self.__classifiersDict[key]
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 itm.setCheckState(0, Qt.Unchecked)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 itm.setData(0, Qt.UserRole, line)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 def __getLicenseText(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 Private method to get the license text.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 @return license text (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 if not self.licenseClassifierCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 return self.licenseEdit.text()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 lic = self.licenseClassifierComboBox.currentText()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 if "(" in lic:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 lic = lic.rsplit("(", 1)[1].split(")", 1)[0]
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 return lic
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 def getCode(self, indLevel, indString):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 Public method to get the source code.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 @param indLevel indentation level (int)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 @param indString string used for indentation (space or tab) (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 @return generated code (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 # Note: all paths are created with '/'; setup will do the right thing
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 # calculate our indentation level and the indentation string
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 il = indLevel + 1
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 istring = il * indString
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 i1string = (il + 1) * indString
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 i2string = (il + 2) * indString
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 estring = os.linesep + indLevel * indString
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 # now generate the code
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 if self.introCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 code = "#!/usr/bin/env python{0}{1}".format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 sys.version_info[0], os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 code += "# -*- coding: utf-8 -*-{0}{0}".format(os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 code = ""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 if self.metaDataCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 code += '# metadata{0}'.format(os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 code += '"{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 self.summaryEdit.text() or "Setup routine",
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 os.linesep
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 )
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 code += '__version__ = "{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 self.versionEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 code += '__license__ = "{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 self.__getLicenseText(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 code += '__author__ = "{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 self.authorEdit.text() or self.maintainerEdit.text(),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 code += '__email__ = "{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 self.authorEmailEdit.text() or self.maintainerEmailEdit.text(),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 code += '__url__ = "{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 self.homePageUrlEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 code += '__date__ = "{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 datetime.datetime.now().isoformat().split('.')[0], os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 code += '__prj__ = "{0}"{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 self.nameEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 code += os.linesep
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 if self.descriptionFromFilesCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 code += "from __future__ import with_statement{0}".format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 if self.importCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 variant = self.variantComboBox.itemData(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 self.variantComboBox.currentIndex())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 if variant == "setuptools":
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 additionalImport = ", find_packages"
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 additionalImport = ""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 code += "from {0} import setup{1}{2}".format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 variant, additionalImport, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 if code:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 code += "{0}{0}".format(os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 if self.descriptionFromFilesCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 code += 'def get_long_description():{0}'.format(os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 code += '{0}descr = []{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 code += '{0}for fname in "{1}":{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 istring,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 '", "'.join(self.descriptionEdit.toPlainText().splitlines()),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 code += '{0}{0}with open(fname) as f:{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 code += '{0}{0}{0}descr.append(f.read()){1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 code += '{0}return "\\n\\n".join(descr){1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 code += "{0}{0}".format(os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 code += 'setup({0}'.format(os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 code += '{0}name="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 istring, self.nameEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 code += '{0}version="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 istring, self.versionEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 if self.summaryEdit.text():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 code += '{0}description="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 istring, self.summaryEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 if self.descriptionFromFilesCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 code += '{0}long_description=get_long_description(),{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 elif self.descriptionEdit.toPlainText():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 code += '{0}long_description="""{1}""",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 istring, self.descriptionEdit.toPlainText(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 if self.authorEdit.text():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 code += '{0}author="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 istring, self.authorEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 code += '{0}author_email="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 istring, self.authorEmailEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 if self.maintainerEdit.text():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 code += '{0}maintainer="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 istring, self.maintainerEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 code += '{0}maintainer_email="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 istring, self.maintainerEmailEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 code += '{0}url="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 istring, self.homePageUrlEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 if self.downloadUrlEdit.text():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 code += '{0}download_url="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 istring, self.downloadUrlEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 classifiers = []
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 if not self.licenseClassifierCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 code += '{0}license="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 istring, self.licenseEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 classifiers.append(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 self.licenseClassifierComboBox.itemData(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 self.licenseClassifierComboBox.currentIndex()))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 platforms = self.platformsEdit.toPlainText().splitlines()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 if platforms:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 code += '{0}platforms=[{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 code += '{0}"{1}"{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 i1string,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 '",{0}{1}"'.format(os.linesep, i1string).join(platforms),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 code += '{0}],{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 if self.developmentStatusComboBox.currentIndex() != 0:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 classifiers.append(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 self.developmentStatusComboBox.itemData(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 self.developmentStatusComboBox.currentIndex()))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 itm = self.classifiersList.topLevelItem(0)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 while itm:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 itm.setExpanded(True)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 if itm.checkState(0) == Qt.Checked:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 classifiers.append(itm.data(0, Qt.UserRole))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 itm = self.classifiersList.itemBelow(itm)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385
6940
12ed1a714527 SetupWizardDialog: change setup default method to 'setuptools' and fixed an issue causing an exception, if no classifiers were selected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
386 # cleanup classifiers list - remove all invalid entries
12ed1a714527 SetupWizardDialog: change setup default method to 'setuptools' and fixed an issue causing an exception, if no classifiers were selected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
387 classifiers = [c for c in classifiers if bool(c)]
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 if classifiers:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 code += '{0}classifiers=[{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 code += '{0}"{1}"{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 i1string,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 '",{0}{1}"'.format(os.linesep, i1string).join(classifiers),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 code += '{0}],{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 del classifiers
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 if self.keywordsEdit.text():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 code += '{0}keywords="{1}",{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 istring, self.keywordsEdit.text(), os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 if self.variantComboBox.currentIndex() == 0:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 # distutils
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 packages = []
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 for row in range(self.packagesList.count()):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 packages.append(self.packagesList.item(row).text())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 if packages:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 code += '{0}packages=[{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 code += '{0}"{1}"{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 i1string,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 '",{0}{1}"'.format(os.linesep, i1string).join(packages),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 code += '{0}],{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 del packages
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 elif self.variantComboBox.currentIndex() == 1:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 # setuptools
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 code += '{0}packages=find_packages('.format(istring)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 src = Utilities.fromNativeSeparators(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 self.sourceDirectoryEdit.text())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 excludePatterns = []
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 for row in range(self.excludePatternList.count()):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 excludePatterns.append(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 self.excludePatternList.item(row).text())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 if src:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 code += '{0}{1}"{2}"'.format(os.linesep, i1string, src)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 if excludePatterns:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 code += ','
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 code += '{0}{1}'.format(os.linesep, istring)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 if excludePatterns:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 code += '{0}{1}exclude=[{0}'.format(os.linesep, i1string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 code += '{0}"{1}"{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 i2string,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 '",{0}{1}"'.format(os.linesep, i2string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 .join(excludePatterns),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 code += '{0}]{1}{2}'.format(i1string, os.linesep, istring)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 code += '),{0}'.format(os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 if self.includePackageDataCheckBox.isChecked():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 code += '{0}include_package_data = True,{1}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 modules = []
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 for row in range(self.modulesList.count()):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 modules.append(self.modulesList.item(row).text())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 if modules:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 code += '{0}py_modules=[{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 code += '{0}"{1}"{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 i1string,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 '",{0}{1}"'.format(os.linesep, i1string).join(modules),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 code += '{0}],{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 del modules
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 scripts = []
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 for row in range(self.scriptsList.count()):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 scripts.append(self.scriptsList.item(row).text())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 if scripts:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 code += '{0}scripts=[{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 code += '{0}"{1}"{2}'.format(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 i1string,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 '",{0}{1}"'.format(os.linesep, i1string).join(scripts),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 code += '{0}],{1}'.format(istring, os.linesep)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 del scripts
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 code += "){0}".format(estring)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 return code
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 def on_projectButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 Private slot to populate some fields with data retrieved from the
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 current project.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 project = e5App().getObject("Project")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 self.nameEdit.setText(project.getProjectName())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 try:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 self.versionEdit.setText(project.getProjectVersion())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 self.authorEdit.setText(project.getProjectAuthor())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 self.authorEmailEdit.setText(project.getProjectAuthorEmail())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 description = project.getProjectDescription()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 except AttributeError:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 self.versionEdit.setText(project.pdata["VERSION"][0])
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 self.authorEdit.setText(project.pdata["AUTHOR"][0])
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 self.authorEmailEdit.setText(project.pdata["EMAIL"][0])
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 description = project.pdata["DESCRIPTION"][0]
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 summary = description.split(".", 1)[0]\
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 .replace("\r", "").replace("\n", "") + "."
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 self.summaryEdit.setText(summary)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 self.descriptionEdit.setPlainText(description)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 self.packageRootEdit.setText(project.getProjectPath())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 # prevent overwriting of entries by disabling the button
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 self.projectButton.setEnabled(False)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 def on_packagesList_itemSelectionChanged(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 Private slot to handle a change of selected items of the
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 packages list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 self.deletePackageButton.setEnabled(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 len(self.packagesList.selectedItems()) > 0)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 def on_deletePackageButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 Private slot to delete the selected package items.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 for itm in self.packagesList.selectedItems():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 self.packagesList.takeItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 self.packagesList.row(itm))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 del itm
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 def on_addPackageButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 Private slot to add a package to the list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 pkg = Utilities.toNativeSeparators(self.packageEdit.text())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 self.__addPackage(pkg)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 def on_packageEdit_returnPressed(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 Private slot handling a press of the return button of the
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 package edit.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 self.on_addPackageButton_clicked()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 @pyqtSlot(str)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 def on_packageEdit_textChanged(self, txt):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 Private slot to handle a change of the package text.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 @param txt text of the line edit (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 self.addPackageButton.setEnabled(bool(txt))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 def on_packageDirButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 Private slot to select a package directory via a directory
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 selection dialog.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 startDir = self.packageEdit.text()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 if not startDir:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 startDir = self.packageRootEdit.text() or self.__getStartDir()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 packageDir = E5FileDialog.getExistingDirectory(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 self.tr("Package Directory"),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 Utilities.fromNativeSeparators(startDir))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 if packageDir:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 self.packageEdit.setText(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 Utilities.toNativeSeparators(packageDir))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 def on_autodiscoverPackagesButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 Private slot to discover packages automatically.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 self.autodiscoverPackagesButton.setEnabled(False)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 QApplication.setOverrideCursor(Qt.WaitCursor)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 startDir = self.packageRootEdit.text() or self.__getStartDir()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 if startDir:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 self.packagesList.clear()
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
571 for dirpath, _dirnames, filenames in os.walk(startDir):
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 if "__init__.py" in filenames:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 self.__addPackage(dirpath)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 self.autodiscoverPackagesButton.setEnabled(True)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 QApplication.restoreOverrideCursor()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 def on_packageRootDirButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 Private slot to select the packages root directory via a
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 directory selection dialog.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 startDir = self.packageRootEdit.text()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 if not startDir:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 startDir = self.__getStartDir()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 packagesRootDir = E5FileDialog.getExistingDirectory(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588 self.tr("Packages Root Directory"),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 Utilities.fromNativeSeparators(startDir),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 if packagesRootDir:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 self.packageRootEdit.setText(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 Utilities.toNativeSeparators(packagesRootDir))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 @pyqtSlot(str)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 def on_packageRootEdit_textChanged(self, txt):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 Private slot handling the entering of a packages root.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 @param txt text of the line edit (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602 projectOpen = e5App().getObject("Project").isOpen()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603 validPackagesRoot = bool(txt) and os.path.exists(txt)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 self.autodiscoverPackagesButton.setEnabled(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 projectOpen or validPackagesRoot)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 def __addPackage(self, pkgDir):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 Private method to add a package to the list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 @param pkgDir name of the package directory (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 if pkgDir:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 if "\\" in pkgDir or "/" in pkgDir:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 # It is a directory. Check for an __init__.py file.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616 if os.path.isabs(pkgDir):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 prefix = ""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 prefix = self.packageRootEdit.text()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 initName = os.path.join(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 prefix,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 Utilities.toNativeSeparators(pkgDir),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 "__init__.py")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 if not os.path.exists(initName):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 res = E5MessageBox.information(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 self.tr("Add Package"),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 self.tr("""<p>The directory <b>{0}</b> is not"""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 """ a Python package.</p>""")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 .format(pkgDir),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 E5MessageBox.StandardButtons(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 E5MessageBox.Ignore |
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 E5MessageBox.Ok))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 if res == E5MessageBox.Ok:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 return
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 pkg = pkgDir.replace(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 Utilities.toNativeSeparators(self.packageRootEdit.text()), "")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 if pkg.startswith(("\\", "/")):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 pkg = pkg[1:]
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 if pkg:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 QListWidgetItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 pkg.replace("\\", ".").replace("/", "."),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 self.packagesList)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 self.packageEdit.clear()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 def __getStartDir(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 Private method to get the start directory for selection dialogs.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 @return start directory (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 return (Preferences.getMultiProject("Workspace") or
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 Utilities.getHomeDir())
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 def on_scriptsList_itemSelectionChanged(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 Private slot to handle a change of selected items of the
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 scripts list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 self.deleteScriptButton.setEnabled(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 len(self.scriptsList.selectedItems()) > 0)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 def on_deleteScriptButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 Private slot to delete the selected script items.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 for itm in self.scriptsList.selectedItems():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 self.scriptsList.takeItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 self.scriptsList.row(itm))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 del itm
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 def on_addScriptButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 Private slot to add scripts to the list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 startDir = self.packageRootEdit.text() or self.__getStartDir()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 scriptsList = E5FileDialog.getOpenFileNames(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 self.tr("Add Scripts"),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 startDir,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685 self.tr("Python Files (*.py);;All Files(*)"))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 for script in scriptsList:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 script = script.replace(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 Utilities.toNativeSeparators(startDir), "")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
689 if script.startswith(("\\", "/")):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 script = script[1:]
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691 if script:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 QListWidgetItem(Utilities.fromNativeSeparators(script),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 self.scriptsList)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 def on_modulesList_itemSelectionChanged(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698 Private slot to handle a change of selected items of the
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 modules list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 self.deleteModuleButton.setEnabled(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 len(self.modulesList.selectedItems()) > 0)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705 def on_deleteModuleButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 Private slot to delete the selected script items.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 for itm in self.modulesList.selectedItems():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 self.modulesList.takeItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 self.modulesList.row(itm))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 del itm
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 def on_addModuleButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 Private slot to add Python modules to the list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 startDir = self.packageRootEdit.text() or self.__getStartDir()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 modulesList = E5FileDialog.getOpenFileNames(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 self.tr("Add Python Modules"),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 startDir,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 self.tr("Python Files (*.py)"))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 for module in modulesList:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 module = module.replace(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 Utilities.toNativeSeparators(startDir), "")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 if module.startswith(("\\", "/")):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 module = module[1:]
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 if module:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 QListWidgetItem(os.path.splitext(module)[0]
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 .replace("\\", ".").replace("/", "."),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 self.modulesList)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 @pyqtSlot(int)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 def on_variantComboBox_currentIndexChanged(self, index):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 Private slot handling a change of the setup variant.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 @param index index of the selected entry (integer)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 self.packagesStackedWidget.setCurrentIndex(index)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 def on_excludePatternList_itemSelectionChanged(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 Private slot to handle a change of selected items of the
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 exclude pattern list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 self.deleteExcludePatternButton.setEnabled(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 len(self.excludePatternList.selectedItems()) > 0)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 def on_deleteExcludePatternButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 Private slot to delete the selected exclude pattern items.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 for itm in self.excludePatternList.selectedItems():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 self.excludePatternList.takeItem(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 self.excludePatternList.row(itm))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 del itm
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 def on_addExludePatternButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 Private slot to add an exclude pattern to the list.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 pattern = self.excludePatternEdit.text()\
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 .replace("\\", ".").replace("/", ".")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 if not self.excludePatternList.findItems(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 pattern, Qt.MatchExactly | Qt.MatchCaseSensitive):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 QListWidgetItem(pattern, self.excludePatternList)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 @pyqtSlot(str)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 def on_excludePatternEdit_textChanged(self, txt):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 Private slot to handle a change of the exclude pattern text.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 @param txt text of the line edit (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 self.addExludePatternButton.setEnabled(bool(txt))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 def on_excludePatternEdit_returnPressed(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 Private slot handling a press of the return button of the
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 exclude pattern edit.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 self.on_addExludePatternButton_clicked()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791 @pyqtSlot()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 def on_sourceDirectoryButton_clicked(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 Private slot to select the packages root directory via a
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 directory selection dialog.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 startDir = self.sourceDirectoryEdit.text() or self.__getStartDir()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 sourceDirectory = E5FileDialog.getExistingDirectory(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 self.tr("Source Directory"),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 Utilities.fromNativeSeparators(startDir),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 if sourceDirectory:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 self.sourceDirectoryEdit.setText(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 Utilities.toNativeSeparators(sourceDirectory))

eric ide

mercurial