4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to enter the data for the 'loaddata' command. |
7 Module implementing a dialog to enter the data for the 'loaddata' command. |
8 """ |
8 """ |
|
9 |
|
10 import contextlib |
9 |
11 |
10 from PyQt5.QtCore import pyqtSlot |
12 from PyQt5.QtCore import pyqtSlot |
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
12 |
14 |
13 from E5Gui import E5FileDialog |
15 from E5Gui import E5FileDialog |
27 Constructor |
29 Constructor |
28 |
30 |
29 @param project reference to the Django project object |
31 @param project reference to the Django project object |
30 @param parent reference to the parent widget (QWidget) |
32 @param parent reference to the parent widget (QWidget) |
31 """ |
33 """ |
32 super(DjangoRunTestServerDataDialog, self).__init__(parent) |
34 super().__init__(parent) |
33 self.setupUi(self) |
35 self.setupUi(self) |
34 |
36 |
35 self.fixtureFileButton.setIcon(UI.PixmapCache.getIcon("open")) |
37 self.fixtureFileButton.setIcon(UI.PixmapCache.getIcon("open")) |
36 |
38 |
37 self.__project = project |
39 self.__project = project |
54 def on_fixtureFileButton_clicked(self): |
56 def on_fixtureFileButton_clicked(self): |
55 """ |
57 """ |
56 Private slot to select a fixture file via a file selection dialog. |
58 Private slot to select a fixture file via a file selection dialog. |
57 """ |
59 """ |
58 fileFilters = self.tr("JSON Files (*.json);;XML Files (*.xml);;") |
60 fileFilters = self.tr("JSON Files (*.json);;XML Files (*.xml);;") |
59 try: |
61 with contextlib.suppress(ImportError): |
60 import yaml # __IGNORE_WARNING__ |
62 import yaml # __IGNORE_WARNING__ |
61 fileFilters += self.tr("YAML Files (*.yaml);;") |
63 fileFilters += self.tr("YAML Files (*.yaml);;") |
62 except ImportError: |
|
63 pass |
|
64 fileFilters += self.tr("All Files (*)") |
64 fileFilters += self.tr("All Files (*)") |
65 |
65 |
66 fixtureFiles = E5FileDialog.getOpenFileNames( |
66 fixtureFiles = E5FileDialog.getOpenFileNames( |
67 self, |
67 self, |
68 self.tr("Select fixture file"), |
68 self.tr("Select fixture file"), |