ProjectDjango/DjangoDumpdataDataDialog.py

branch
eric7
changeset 180
64339135bd61
parent 175
30cb5e553e7e
child 190
f394b11f9f31
equal deleted inserted replaced
179:8413c2429808 180:64339135bd61
16 16
17 class DjangoDumpdataDataDialog(QDialog, Ui_DjangoDumpdataDataDialog): 17 class DjangoDumpdataDataDialog(QDialog, Ui_DjangoDumpdataDataDialog):
18 """ 18 """
19 Class implementing a dialog to enter the data for the 'dumpdata' command. 19 Class implementing a dialog to enter the data for the 'dumpdata' command.
20 """ 20 """
21
21 def __init__(self, project, parent=None): 22 def __init__(self, project, parent=None):
22 """ 23 """
23 Constructor 24 Constructor
24 25
25 @param project reference to the Django project object 26 @param project reference to the Django project object
26 @type Project 27 @type Project
27 @param parent reference to the parent widget 28 @param parent reference to the parent widget
28 @type QWidget 29 @type QWidget
29 """ 30 """
30 super().__init__(parent) 31 super().__init__(parent)
31 self.setupUi(self) 32 self.setupUi(self)
32 33
33 self.__project = project 34 self.__project = project
34 35
35 apps = self.__project.getRecentApplications() 36 apps = self.__project.getRecentApplications()
36 self.applicationsCombo.addItems(apps) 37 self.applicationsCombo.addItems(apps)
37 self.excludeCombo.addItems(apps) 38 self.excludeCombo.addItems(apps)
38 self.excludeCombo.setEditText("") 39 self.excludeCombo.setEditText("")
39 40
40 self.formatCombo.addItem(self.tr("JSON"), "json") 41 self.formatCombo.addItem(self.tr("JSON"), "json")
41 self.formatCombo.addItem(self.tr("XML"), "xml") 42 self.formatCombo.addItem(self.tr("XML"), "xml")
42 with contextlib.suppress(ImportError): 43 with contextlib.suppress(ImportError):
43 import yaml # __IGNORE_WARNING__ 44 import yaml # __IGNORE_WARNING__
45
44 self.formatCombo.addItem(self.tr("YAML"), "yaml") 46 self.formatCombo.addItem(self.tr("YAML"), "yaml")
45 47
46 msh = self.minimumSizeHint() 48 msh = self.minimumSizeHint()
47 self.resize(max(self.width(), msh.width()), msh.height()) 49 self.resize(max(self.width(), msh.width()), msh.height())
48 50
49 def getData(self): 51 def getData(self):
50 """ 52 """
51 Public method to get the data entered into the dialog. 53 Public method to get the data entered into the dialog.
52 54
53 @return tuple giving the list of applications to work on, the list of 55 @return tuple giving the list of applications to work on, the list of
54 applications to exclude, the dump format and the indentation level 56 applications to exclude, the dump format and the indentation level
55 @rtype tuple of (list of str, list of str, str, int) 57 @rtype tuple of (list of str, list of str, str, int)
56 """ 58 """
57 applStr = self.applicationsCombo.currentText() 59 applStr = self.applicationsCombo.currentText()
58 if applStr: 60 if applStr:
59 self.__project.setMostRecentApplication(applStr) 61 self.__project.setMostRecentApplication(applStr)
60 appls = applStr.split() 62 appls = applStr.split()
61 else: 63 else:
62 appls = [] 64 appls = []
63 65
64 exclStr = self.excludeCombo.currentText() 66 exclStr = self.excludeCombo.currentText()
65 excl = exclStr.split() if exclStr else [] 67 excl = exclStr.split() if exclStr else []
66 68
67 dumpFormat = self.formatCombo.itemData(self.formatCombo.currentIndex()) 69 dumpFormat = self.formatCombo.itemData(self.formatCombo.currentIndex())
68 70
69 return appls, excl, dumpFormat, self.indentationSpinBox.value() 71 return appls, excl, dumpFormat, self.indentationSpinBox.value()

eric ide

mercurial