eric6/PipInterface/PipFileSelectionDialog.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 6942
2602857055c5
child 7229
53054eb5b15a
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.

6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6619
diff changeset
3 # Copyright (c) 2015 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 Module implementing a dialog to enter a file to be processed.
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from __future__ import unicode_literals
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import os
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from PyQt5.QtCore import pyqtSlot
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from E5Gui.E5PathPicker import E5PathPickerModes
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from .Ui_PipFileSelectionDialog import Ui_PipFileSelectionDialog
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Utilities
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class PipFileSelectionDialog(QDialog, Ui_PipFileSelectionDialog):
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing a dialog to enter a file to be processed.
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
6342
c79ecba9cde7 pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6327
diff changeset
29 def __init__(self, pip, mode, install=True, parent=None):
6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Constructor
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
6342
c79ecba9cde7 pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6327
diff changeset
33 @param pip reference to the pip object
c79ecba9cde7 pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6327
diff changeset
34 @type Pip
6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param mode mode of the dialog
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type str
6327
a1716d9210f4 pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6301
diff changeset
37 @param install flag indicating an install action
a1716d9210f4 pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6301
diff changeset
38 @type bool
6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param parent reference to the parent widget
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @type QWidget
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 super(PipFileSelectionDialog, self).__init__(parent)
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.setupUi(self)
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 if mode == "requirements":
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.fileLabel.setText(self.tr("Enter requirements file:"))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.filePicker.setMode(E5PathPickerModes.OpenFileMode)
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.filePicker.setToolTip(self.tr(
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 "Press to select the requirements file through a file"
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 " selection dialog."))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.filePicker.setFilters(
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.tr("Text Files (*.txt);;All Files (*)"))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 elif mode == "package":
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.fileLabel.setText(self.tr("Enter package file:"))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.filePicker.setMode(E5PathPickerModes.OpenFileMode)
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.filePicker.setToolTip(self.tr(
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 "Press to select the package file through a file"
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 " selection dialog."))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.filePicker.setFilters(
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.tr("Python Wheel (*.whl);;"
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 "Archive Files (*.tar.gz *.zip);;"
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 "All Files (*)"))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 else:
6295
79bfd24e2fee Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6294
diff changeset
64 self.fileLabel.setText(self.tr("Enter file name:"))
6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.filePicker.setMode(E5PathPickerModes.OpenFileMode)
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.filePicker.setToolTip(self.tr(
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 "Press to select a file through a file selection dialog."))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.filePicker.setFilters(self.tr("All Files (*)"))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.filePicker.setDefaultDirectory(os.path.expanduser("~"))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
6327
a1716d9210f4 pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6301
diff changeset
73 self.userCheckBox.setVisible(install)
a1716d9210f4 pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6301
diff changeset
74
6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 msh = self.minimumSizeHint()
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.resize(max(self.width(), msh.width()), msh.height())
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @pyqtSlot(str)
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 def on_filePicker_textChanged(self, txt):
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 Private slot to handle entering the name of a file.
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param txt name of the file
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @type str
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 bool(txt) and
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 os.path.exists(Utilities.toNativeSeparators(txt))
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 )
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 def getData(self):
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 """
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 Public method to get the entered data.
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6782
diff changeset
95 @return tuple with the name of the selected file and a flag indicating
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6782
diff changeset
96 to install to the user install directory
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6782
diff changeset
97 @rtype tuple of (str, bool)
6294
58f82c179d2b pip Interface: added an action to install a locally available package/wheel
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
6342
c79ecba9cde7 pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6327
diff changeset
99 return (
c79ecba9cde7 pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6327
diff changeset
100 self.filePicker.text(),
c79ecba9cde7 pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6327
diff changeset
101 self.userCheckBox.isChecked()
c79ecba9cde7 pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6327
diff changeset
102 )

eric ide

mercurial