def _create_file(self): DEBUG("Creating a file...") dialog = NewFileDialog(self) data = dialog.data if data: current_item = self.currentItem() filename, ftype = data['filename'], data['type'] filename = os.path.join(current_item.path, filename) if os.path.exists(filename): # El archivo ya existe QMessageBox.information(self, self.tr("Información"), self.tr("Ya existe un archivo con ese" " nombre"), QMessageBox.Ok) DEBUG("A file already exists...") return if ftype == 1: # Header file preprocessor = os.path.splitext(os.path.basename(filename))[0] content = "#ifndef %s_H_\n#define %s_H\n\n#endif" % \ (preprocessor.upper(), preprocessor.upper()) else: content = "" # Agrego a la lista de archivos fuente self._sources.append(filename) # Creo el archivo file_manager.write_file(filename, content) if isinstance(current_item, EdisItem): parent = current_item.child(ftype) else: parent = current_item # Agrego el ítem al árbol new_item = TreeItem(parent, [data['filename']]) new_item.path = filename editor_container = Edis.get_component("principal") editor_container.open_file(filename)
def _create_file(self): DEBUG("Creating a file...") dialog = NewFileDialog(self) data = dialog.data if data: current_item = self.currentItem() filename, ftype = data["filename"], data["type"] filename = os.path.join(current_item.path, filename) if os.path.exists(filename): # El archivo ya existe QMessageBox.information( self, self.tr("Información"), self.tr("Ya existe un archivo con ese" " nombre"), QMessageBox.Ok ) DEBUG("A file already exists...") return if ftype == 1: # Header file preprocessor = os.path.splitext(os.path.basename(filename))[0] content = "#ifndef %s_H_\n#define %s_H\n\n#endif" % (preprocessor.upper(), preprocessor.upper()) else: content = "" # Agrego a la lista de archivos fuente self._sources.append(filename) # Creo el archivo file_manager.write_file(filename, content) if isinstance(current_item, EdisItem): parent = current_item.child(ftype) else: parent = current_item # Agrego el ítem al árbol new_item = TreeItem(parent, [data["filename"]]) new_item.path = filename editor_container = Edis.get_component("principal") editor_container.open_file(filename)
def _create_main_file(self): """ Crea el archivo y la función main y lo agrega al árbol""" DEBUG("Creating main file...") current_item = self.currentItem() item_path = os.path.join(current_item.path, 'main.c') if os.path.exists(item_path): # El archivo ya existe QMessageBox.information(self, self.tr("Información"), self.tr("El archivo <b>main.c</b> " "ya existe."), QMessageBox.Yes) DEBUG("File aready exists...") return # Creo el archivo file_manager.write_file(item_path, templates.MAIN_TEMPLATE) # Agrego el ítem, 0 = sources_item item = TreeItem(current_item.child(0), ['main.c']) item.path = item_path self._sources.append(item_path) # Abro el archivo editor_container = Edis.get_component("principal") editor_container.open_file(item_path)
def _create_main_file(self): """ Crea el archivo y la función main y lo agrega al árbol""" DEBUG("Creating main file...") current_item = self.currentItem() item_path = os.path.join(current_item.path, "main.c") if os.path.exists(item_path): # El archivo ya existe QMessageBox.information( self, self.tr("Información"), self.tr("El archivo <b>main.c</b> " "ya existe."), QMessageBox.Yes ) DEBUG("File aready exists...") return # Creo el archivo file_manager.write_file(item_path, templates.MAIN_TEMPLATE) # Agrego el ítem, 0 = sources_item item = TreeItem(current_item.child(0), ["main.c"]) item.path = item_path self._sources.append(item_path) # Abro el archivo editor_container = Edis.get_component("principal") editor_container.open_file(item_path)