Sat, 23 Mar 2013 19:41:38 +0100
Continued porting the Django project plug-in from eric4.
# -*- coding: utf-8 -*- # Copyright (c) 2013 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing a dialog to enter the data for the 'dumpdata' command. """ from PyQt4.QtGui import QDialog from .Ui_DjangoDumpdataDataDialog import Ui_DjangoDumpdataDataDialog class DjangoDumpdataDataDialog(QDialog, Ui_DjangoDumpdataDataDialog): """ Class implementing a dialog to enter the data for the 'dumpdata' command. """ def __init__(self, project, parent=None): """ Constructor @param project reference to the Django project object @param parent reference to the parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) self.__project = project if self.__project.getDjangoVersion() < (1, 0): self.excludeGroup.setEnabled(False) apps = self.__project.getRecentApplications() self.applicationsCombo.addItems(apps) self.excludeCombo.addItems(apps) self.excludeCombo.setEditText("") self.formatCombo.addItem(self.trUtf8("JSON"), "json") self.formatCombo.addItem(self.trUtf8("XML"), "xml") try: import yaml # __IGNORE_WARNING__ self.formatCombo.addItem(self.trUtf8("YAML"), "yaml") except ImportError: pass def getData(self): """ Public method to get the data entered into the dialog. @return tuple of two lists of strings, a string and an integer giving the list of applications to work on, the list of applications to exclude, the dump format and the indentation level """ applStr = self.applicationsCombo.currentText() if applStr: self.__project.setMostRecentApplication(applStr) appls = applStr.split() else: appls = [] exclStr = self.excludeCombo.currentText() if exclStr: excl = exclStr.split() else: excl = [] format = self.formatCombo.itemData(self.formatCombo.currentIndex()) return appls, excl, format, self.indentationSpinBox.value()