def create_new_project(self): """Create new project.""" self.unmaximize() active_project = self.current_active_project dlg = ProjectDialog(self, project_types=self.get_project_types()) result = dlg.exec_() data = dlg.project_data root_path = data.get("root_path", None) project_type = data.get("project_type", EmptyProject.ID) if result: # A project was not open before if active_project is None: if self.get_option('visible_if_project_open'): self.show_explorer() else: # We are switching projects. # TODO: Don't emit sig_project_closed when we support # multiple workspaces. self.sig_project_closed.emit(active_project.root_path) self._create_project(root_path, project_type_id=project_type) self.sig_pythonpath_changed.emit() self.restart_consoles() dlg.close()
def create_new_project(self): """Create new project""" active_project = self.current_active_project dlg = ProjectDialog(self) dlg.sig_project_creation_requested.connect(self._create_project) dlg.sig_project_creation_requested.connect(self.sig_project_created) if dlg.exec_(): if (active_project is None and self.get_option('visible_if_project_open')): self.show_explorer() self.sig_pythonpath_changed.emit() self.restart_consoles()
def create_new_project(self): """Create new project""" self.switch_to_plugin() active_project = self.current_active_project dlg = ProjectDialog(self) dlg.sig_project_creation_requested.connect(self._create_project) dlg.sig_project_creation_requested.connect(self.sig_project_created) if dlg.exec_(): if (active_project is None and self.get_option('visible_if_project_open')): self.show_explorer() self.sig_pythonpath_changed.emit() self.restart_consoles()
def create_new_project(self): """Create new project.""" self.unmaximize() dlg = ProjectDialog(self.get_widget(), project_types=self.get_project_types()) result = dlg.exec_() data = dlg.project_data root_path = data.get("root_path", None) project_type = data.get("project_type", EmptyProject.ID) if result: self._create_project(root_path, project_type_id=project_type) dlg.close()
def create_new_project(self): """Create new project""" self.unmaximize() active_project = self.current_active_project dlg = ProjectDialog(self) dlg.sig_project_creation_requested.connect(self._create_project) dlg.sig_project_creation_requested.connect(self.sig_project_created) if dlg.exec_(): # A project was not open before if active_project is None: if self.get_option('visible_if_project_open'): self.show_explorer() else: # We are switching projects. # TODO: Don't emit sig_project_closed when we support # multiple workspaces. self.sig_project_closed.emit(active_project.root_path) self.sig_pythonpath_changed.emit() self.restart_consoles()
def test_projectdialog_location(monkeypatch): """Test that select_location normalizes delimiters and updates the path.""" dlg = ProjectDialog(None, {'Empty project': EmptyProject}) mock_getexistingdirectory = Mock() monkeypatch.setattr( 'spyder.plugins.projects.widgets.projectdialog' + '.getexistingdirectory', mock_getexistingdirectory) mock_getexistingdirectory.return_value = r"c:\a/b\\c/d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\\a//b\\c//d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\a\b\c/d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:/a/b/c\d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\\a\\b\\c//d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\AaA/bBB1\\c-C/d2D" dlg.select_location() assert dlg.location == r"c:\AaA\bBB1\c-C\d2D" mock_getexistingdirectory.return_value = r"c:\\a_a_1//Bbbb\2345//d-6D" dlg.select_location() assert dlg.location == r"c:\a_a_1\Bbbb\2345\d-6D"
def projects_dialog(qtbot): """Set up ProjectDialog.""" dlg = ProjectDialog(None, {'Empty project': EmptyProject}) qtbot.addWidget(dlg) dlg.show() return dlg
def setup_projects_dialog(qtbot): """Set up ProjectDialog.""" dlg = ProjectDialog(None) qtbot.addWidget(dlg) return dlg
def test_projectdialog_location(monkeypatch): """Test that select_location normalizes delimiters and updates the path.""" dlg = ProjectDialog(None) mock_getexistingdirectory = Mock() monkeypatch.setattr('spyder.plugins.projects.widgets.projectdialog' + '.getexistingdirectory', mock_getexistingdirectory) mock_getexistingdirectory.return_value = r"c:\a/b\\c/d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\\a//b\\c//d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\a\b\c/d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:/a/b/c\d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\\a\\b\\c//d" dlg.select_location() assert dlg.location == r"c:\a\b\c\d" mock_getexistingdirectory.return_value = r"c:\AaA/bBB1\\c-C/d2D" dlg.select_location() assert dlg.location == r"c:\AaA\bBB1\c-C\d2D" mock_getexistingdirectory.return_value = r"c:\\a_a_1//Bbbb\2345//d-6D" dlg.select_location() assert dlg.location == r"c:\a_a_1\Bbbb\2345\d-6D"