summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorLaurent Charignon <l.charignon@gmail.com>2016-01-31 18:30:40 -0800
committerLaurent Charignon <l.charignon@gmail.com>2016-01-31 19:00:33 -0800
commitcb137db7fc8a1bf3d0efd31493d0a781c35b7931 (patch)
treefd116bc303668c14602ed80cc8d7c5becec42ac0
parent54e39a0da914d9253c74e480cc4b785d12aad014 (diff)
downloadranger-cb137db7fc8a1bf3d0efd31493d0a781c35b7931.tar.gz
bookmark: replace delete by __delitem__ for consistency with other methods
We are already using the python magic methods __setitem__, __getitem__,
__contains__ and __iter__. It makes sense to use __delitem__ and not
have a custom method name for removing bookmarks. We change the only
place where this method is called in the code.
-rw-r--r--ranger/container/bookmarks.py16
-rw-r--r--ranger/core/actions.py2
2 files changed, 8 insertions, 10 deletions
diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py
index 9d00e9c8..02f3e3bc 100644
--- a/ranger/container/bookmarks.py
+++ b/ranger/container/bookmarks.py
@@ -43,14 +43,6 @@ class Bookmarks(object):
 
         self._set_dict(new_dict, original=new_dict)
 
-    def delete(self, key):
-        """Delete the bookmark with the given key"""
-        if key == '`':
-            key = "'"
-        if key in self.dct:
-            del self.dct[key]
-            if self.autosave: self.save()
-
     def enter(self, key):
         """Enter the bookmark with the given key.
 
@@ -72,7 +64,13 @@ class Bookmarks(object):
         if self.autosave: self.save()
 
     def __delitem__(self, key):
-        self.delete(key)
+        """Delete the bookmark with the given key"""
+        if key == '`':
+            key = "'"
+        if key in self.dct:
+            del self.dct[key]
+            if self.autosave: self.save()
+
 
     def __iter__(self):
         return iter(self.dct.items())
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 63916145..e692eb39 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -790,7 +790,7 @@ class Actions(FileManagerAware, SettingsAware):
     def unset_bookmark(self, key):
         """Delete the bookmark with the name <key>"""
         self.bookmarks.update_if_outdated()
-        self.bookmarks.delete(str(key))
+        del self.bookmarks[str(key)]
 
     def draw_bookmarks(self):
         self.ui.browser.draw_bookmarks = True