summaryrefslogtreecommitdiff
path: root/nephilim/song.py
diff options
context:
space:
mode:
Diffstat (limited to 'nephilim/song.py')
-rw-r--r--nephilim/song.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/nephilim/song.py b/nephilim/song.py
index 6cf0a6b..cbe22d5 100644
--- a/nephilim/song.py
+++ b/nephilim/song.py
@@ -17,6 +17,7 @@
from PyQt4 import QtCore
import os
+from string import Template
from common import sec2min
@@ -82,13 +83,10 @@ class Song(dict):
def __nonzero__(self):
return bool(self['file'])
- def expand_tags(self, str):
- """Expands tags in form $tag in str."""
- ret = str
- ret = ret.replace('$title', self['title']) #to ensure that it is set to at least filename
- for tag in self.keys() + ['tracknum', 'length', 'id']:
- ret = ret.replace('$' + tag, unicode(self[tag]))
- ret = ret.replace('$songdir', os.path.dirname(self['file']))
+ def expand_tags(self, s):
+ """Expands tags in form ${tag} in string s."""
+ ret = Template(s)
+ ret = ret.safe_substitute(self)
return ret
class SongRef: