def test_basename(self): """Test the utils.basename function.""" self.assertEqual(utils.basename("bar"), "bar") self.assertEqual(utils.basename("/bar"), "bar") self.assertEqual(utils.basename("/bar "), "bar ") self.assertEqual(utils.basename("foo/bar"), "bar") self.assertEqual(utils.basename("/foo/bar"), "bar") self.assertEqual(utils.basename("foo/foo/bar"), "bar") self.assertEqual(utils.basename("/foo/foo/bar"), "bar") self.assertEqual(utils.basename("/foo/foo//bar"), "bar") self.assertEqual(utils.basename("////foo //foo//bar"), "bar")
def test_basename(self): """Test the utils.basename function.""" self.assertEqual(utils.basename('bar'), 'bar') self.assertEqual(utils.basename('/bar'), 'bar') self.assertEqual(utils.basename('/bar '), 'bar ') self.assertEqual(utils.basename('foo/bar'), 'bar') self.assertEqual(utils.basename('/foo/bar'), 'bar') self.assertEqual(utils.basename('foo/foo/bar'), 'bar') self.assertEqual(utils.basename('/foo/foo/bar'), 'bar') self.assertEqual(utils.basename('/foo/foo//bar'), 'bar') self.assertEqual(utils.basename('////foo //foo//bar'), 'bar')
def branch_item_changed(self, *rest): """This callback is called when the branch selection changes""" # When the branch selection changes then we should update # the "Revision Expression" accordingly. qlist = self.view.branch_list (row, selected) = qtutils.selected_row(qlist) if not selected: return sources = self._branch_sources() rev = sources[row] # Update the model with the selection self.model.set_revision(rev) # Only set the branch name field if we're # branching from a remote branch. if not self.view.remote_radio.isChecked(): return branch = utils.basename(rev) if branch == 'HEAD': return # Signal that we've clicked on a remote branch self._remoteclicked = True self.model.set_local_branch(branch) self._remoteclicked = False
def __init__(self, path, is_dir): QtGui.QStandardItem.__init__(self) self.is_dir = is_dir self.path = path self.setEditable(False) self.setDragEnabled(False) self.setText(utils.basename(path)) if is_dir: self.setIcon(qtutils.dir_icon()) else: self.setIcon(qtutils.file_icon())
def update_remote_branches(self,*rest): """Update the remote branch name when a branch is selected""" widget = self.remote_branches branches = self.model.remote_branches selection = qtutils.selected_item(widget,branches) if not selection: return branch = utils.basename(selection) if branch == 'HEAD': return self.set_remote_branch(branch)
def __init__(self, path, is_dir): QtGui.QStandardItem.__init__(self) self.is_dir = is_dir self.path = path self.setEditable(False) self.setDragEnabled(False) self.setText(utils.basename(path)) if is_dir: icon = icons.directory() else: icon = icons.file_text() self.setIcon(icon)
def branch_item_changed(self, *rest): """This callback is called when the branch selection changes""" # When the branch selection changes then we should update # the "Revision Expression" accordingly. qlist = self.branch_list rev = qtutils.selected_item(qlist, self.branch_sources()) if rev is None: return # Update the model with the selection self.revision.setText(rev) # Set the branch field if we're branching from a remote branch. if not self.remote_radio.isChecked(): return branch = utils.basename(rev) if branch == 'HEAD': return # Signal that we've clicked on a remote branch self.branch_name.setText(branch)
def name(self): """Calculate the name for an entry.""" return utils.basename(self.path)
def update_name(self): """Emits a signal corresponding to the entry's name.""" # 'name' is cheap to calculate so simply emit a signal self.emit(SIGNAL(Columns.NAME), utils.basename(self.path)) if '/' not in self.path: self.update()