def testPathExists(self): """Test if a path exists""" path = common.GetDataFilePath(u'test_read_utf8.txt') fail = common.GetDataFilePath(u'fake_file.txt') # Test regular file paths self.assertTrue(ebmlib.PathExists(path)) self.assertFalse(ebmlib.PathExists(fail)) # Test URI path = u"file://" + path fail = u"file://" + fail self.assertTrue(ebmlib.PathExists(path)) self.assertFalse(ebmlib.PathExists(fail))
def ImportProject(self): """Prompt the user to import an existing project""" cbuf = wx.GetApp().GetCurrentBuffer() if cbuf and hasattr(cbuf, 'GetFileName'): fname = cbuf.GetFileName() dname = os.path.dirname(fname) # TODO: Enhancement - support loading/import other project types (i.e pydev) dlg = wx.DirDialog(self.MainWindow, _("Import Project Directory"), dname) if dlg.ShowModal() == wx.ID_OK: proj = dlg.Path projName = os.path.basename(proj) pxml = ProjectXml.ProjectXml(name=projName) # Write out the new project file ppath = os.path.join(proj, u"%s.psp" % projName) if ebmlib.PathExists(ppath): result = wx.MessageBox(_( "The project '%s' already exists.\nDo you wish to overwrite it?" ) % projName, _("Project Exists"), style=wx.ICON_WARNING | wx.YES_NO) if result == wx.ID_NO: return pfile = ProjectFile.ProjectFile(pxml, ppath) pfile.Save(force=True) self.Tree.LoadProject(pfile) # Load the view
def EditCommand(self, cmd): """Perform an edit related command @param cmd: command string to execute """ # e fname: edit file cmd = cmd[1:].strip() frame = self.GetTopLevelParent() cmd = ebmlib.GetPathFromURI(cmd) if not os.path.isabs(cmd): cmd = os.path.join(self._curdir, cmd) if ebmlib.PathExists(cmd): frame.DoOpen(ed_glob.ID_COMMAND_LINE_OPEN, cmd) else: frame.nb.OpenPage(ebmlib.GetPathName(cmd), ebmlib.GetFileName(cmd))