summaryrefslogtreecommitdiff
path: root/format.py
diff options
context:
space:
mode:
authorjerous <jerous@gmail.com>2008-09-28 00:52:29 +0200
committerjerous <jerous@gmail.com>2008-09-28 00:52:29 +0200
commit5d4a94d2929a5f0401320c9368d3d2ffd582964f (patch)
tree3e4c16b98eac559629cd73c49f3590b6a4bc62be /format.py
parent95bcfd646d9cebc4e85120e836fe6537b8b648be (diff)
fix with nested brackets in a format
Diffstat (limited to 'format.py')
-rw-r--r--format.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/format.py b/format.py
index 12a00fd..f08d1d1 100644
--- a/format.py
+++ b/format.py
@@ -70,7 +70,7 @@ def match_bracket(string, start):
balance=1
start+=1
while balance>0:
- if start>len(string):
+ if start<=0:
raise Exception("No matching bracket found")
l=string.find("(", start)
r=string.find(")", start)
@@ -78,10 +78,11 @@ def match_bracket(string, start):
if l<0:
if r>0: balance-=1
else: return -1
+ start=r+1
else:
if l<r: balance+=1
- elif r<l: balance-=1
- start=min(l,r)+1
+ elif l>r: balance-=1
+ start=min(l,r)+1
if balance==0:
return r+1
@@ -100,6 +101,7 @@ def params(song, overwrite={}, ensure={"title":"", "artist":""\
params[param]=overwrite[param]
return params
+#f=compile("$if($date, ($date) )")
#f=compile("a$if($title,$title)b$if($artist,$artist)c")
#print f({'state':'playing', 'title':'martha', 'artist':'waits'})
#f=compile("$artist $if($title, titeltje:$artist, $artist $title!) $album")