From 489a446cee990cdded2c69687fe44e1426710465 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 13 Apr 2015 13:30:13 +0200 Subject: container.tags: added TagsDummy class for use with --clean --- ranger/container/tags.py | 37 +++++++++++++++++++++++++++++++++++++ ranger/core/fm.py | 4 +++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ranger/container/tags.py b/ranger/container/tags.py index 7ecef603..098ae9e3 100644 --- a/ranger/container/tags.py +++ b/ranger/container/tags.py @@ -109,3 +109,40 @@ class Tags(object): def __nonzero__(self): return True __bool__ = __nonzero__ + + +class TagsDummy(Tags): + """A dummy Tags class for use with `ranger --clean`. + + It acts like there are no tags and avoids writing any changes. + """ + + def __init__(self, filename): + self.tags = dict() + + def __contains__(self, item): + return False + + def add(self, *items, **others): + pass + + def remove(self, *items, **others): + pass + + def toggle(self, *items, **others): + pass + + def marker(self, item): + return self.default_tag + + def sync(self): + pass + + def dump(self): + pass + + def _compile(self, f): + pass + + def _parse(self, f): + pass diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 8ae1e753..6c9513c3 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -15,7 +15,7 @@ import sys import ranger.api from ranger.core.actions import Actions from ranger.core.tab import Tab -from ranger.container.tags import Tags +from ranger.container.tags import Tags, TagsDummy from ranger.gui.ui import UI from ranger.container.bookmarks import Bookmarks from ranger.core.runner import Runner @@ -100,6 +100,8 @@ class FM(Actions, SignalDispatcher): if not ranger.arg.clean and self.tags is None: self.tags = Tags(self.confpath('tagged')) + elif ranger.arg.clean: + self.tags = TagsDummy("") if self.bookmarks is None: if ranger.arg.clean: -- cgit 1.4.1-2-gfad0