ProjectDjango/DjangoDumpdataDataDialog.py

changeset 2
1e97424fda0c
child 9
8fe581309106
equal deleted inserted replaced
1:13a0cced0c6e 2:1e97424fda0c
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for the 'dumpdata' command.
8 """
9
10 from PyQt4.QtGui import QDialog
11
12 from .Ui_DjangoDumpdataDataDialog import Ui_DjangoDumpdataDataDialog
13
14
15 class DjangoDumpdataDataDialog(QDialog, Ui_DjangoDumpdataDataDialog):
16 """
17 Class implementing a dialog to enter the data for the 'dumpdata' command.
18 """
19 def __init__(self, project, parent=None):
20 """
21 Constructor
22
23 @param project reference to the Django project object
24 @param parent reference to the parent widget (QWidget)
25 """
26 super().__init__(parent)
27 self.setupUi(self)
28
29 self.__project = project
30 if self.__project.getDjangoVersion() < (1, 0):
31 self.excludeGroup.setEnabled(False)
32
33 apps = self.__project.getRecentApplications()
34 self.applicationsCombo.addItems(apps)
35 self.excludeCombo.addItems(apps)
36 self.excludeCombo.setEditText("")
37
38 self.formatCombo.addItem(self.trUtf8("JSON"), "json")
39 self.formatCombo.addItem(self.trUtf8("XML"), "xml")
40 try:
41 import yaml # __IGNORE_WARNING__
42 self.formatCombo.addItem(self.trUtf8("YAML"), "yaml")
43 except ImportError:
44 pass
45
46 def getData(self):
47 """
48 Public method to get the data entered into the dialog.
49
50 @return tuple of two lists of strings, a string and an integer giving
51 the list of applications to work on, the list of applications to
52 exclude, the dump format and the indentation level
53 """
54 applStr = self.applicationsCombo.currentText()
55 if applStr:
56 self.__project.setMostRecentApplication(applStr)
57 appls = applStr.split()
58 else:
59 appls = []
60
61 exclStr = self.excludeCombo.currentText()
62 if exclStr:
63 excl = exclStr.split()
64 else:
65 excl = []
66
67 format = self.formatCombo.itemData(self.formatCombo.currentIndex())
68
69 return appls, excl, format, self.indentationSpinBox.value()

eric ide

mercurial