def _create_init(self): item = self.currentItem() if item.parent() is None: pathFolder = item.path else: pathFolder = os.path.join(item.path, str(item.text(0))) try: file_manager.create_init_file_complete(pathFolder) except file_manager.NinjaFileExistsException, ex: QMessageBox.information(self, self.tr("Create INIT fail"), ex.message)
def _create_init(self): item = self.currentItem() if item.parent() is None: pathFolder = item.path else: pathFolder = os.path.join(item.path, str(item.text(0))) try: file_manager.create_init_file_complete(pathFolder) except file_manager.NinjaFileExistsException as ex: QMessageBox.information(self, _translate("TreeProjectsWidget", "Create INIT fail"), ex.message) self._refresh_project(item)
def create_plugin_class(self, page, path, plugin_dict): module = plugin_dict['module'] className = plugin_dict['class'] completed = False # Start the template content = TEMPLATE_PLUGIN_BEGIN % className if page.checkEditorS.checkState() == Qt.Checked: content += TEMPLATE_EDITOR_S completed = True if page.checkToolbarS.checkState() == Qt.Checked: content += TEMPLATE_TOOLBAR_S completed = True if page.checkMenuPluginS.checkState() == Qt.Checked: content += TEMPLATE_MENU_S completed = True if page.checkMiscS.checkState() == Qt.Checked: content += TEMPLATE_MISC_S completed = True if page.checkExplorerS.checkState() == Qt.Checked: content += TEMPLATE_EXPLORER_S completed = True if not completed: content += TEMPLATE_PASS_STATMENT content += TEMPLATE_PLUGIN_FINISH content = content # Create the folder file_manager.create_folder(os.path.join(path, module)) # Create the file fileName = os.path.join(os.path.join(path, module), module + '.py') # Write to the file file_manager.store_file_content(fileName, content) # Create the __init__.py with the imports! file_manager.create_init_file_complete(os.path.join(path, module))