summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-08-10 12:33:41 +0200
committerhut <hut@lavabit.com>2011-08-10 12:34:32 +0200
commitc3364edc639b88559dad7545f480256816a1a6ea (patch)
tree9413ab367f7a53a2f4520d7586d12f46c38c82c6
parentdc91c2868201bee8bb3bbbaae3618a2a2b9ebdde (diff)
downloadranger-c3364edc639b88559dad7545f480256816a1a6ea.tar.gz
container.tags: modified DaPangus' patch for more compatibility
-rw-r--r--ranger/container/tags.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/ranger/container/tags.py b/ranger/container/tags.py
index ed015d16..f375fcbd 100644
--- a/ranger/container/tags.py
+++ b/ranger/container/tags.py
@@ -19,6 +19,7 @@ import string
 ALLOWED_KEYS = string.ascii_letters + string.digits + string.punctuation
 
 class Tags(object):
+	default_tag = '*'
 
 	def __init__(self, filename):
 
@@ -36,7 +37,7 @@ class Tags(object):
 		if 'mark' in others:
 			mark = others['mark']
 		else:
-			mark = '*'
+			mark = self.default_tag
 		self.sync()
 		for item in items:
 			self.tags[item] = mark
@@ -55,11 +56,11 @@ class Tags(object):
 		if 'mark' in others:
 			mark = others['mark']
 		else:
-			mark = '*'
+			mark = self.default_tag
 		self.sync()
 		for item in items:
 			try:
-				if item in self and self.tags[item] == mark:
+				if item in self and mark in (self.tags[item], self.default_tag):
 					del(self.tags[item])
 				else:
 					self.tags[item] = mark
@@ -71,7 +72,7 @@ class Tags(object):
 		if item in self.tags:
 			return self.tags[item]
 		else:
-			return '*'
+			return self.default_tag
 
 	def sync(self):
 		try:
@@ -93,7 +94,10 @@ class Tags(object):
 
 	def _compile(self, f):
 		for path, mark in self.tags.items():
-			if mark in ALLOWED_KEYS:
+			if mark == self.default_tag:
+				# COMPAT: keep the old format if the default tag is used
+				f.write(path + '\n')
+			elif mark in ALLOWED_KEYS:
 				f.write('{0}:{1}\n'.format(mark, path))
 
 	def _parse(self, f):
@@ -105,7 +109,8 @@ class Tags(object):
 				if mark in ALLOWED_KEYS:
 					result[path] = mark
 			else:
-				result[line] = '*'
+				result[line] = self.default_tag
+
 		return result
 
 	def __nonzero__(self):