From e6e6d578da31c5ebd4c32f4fa5b6296591f99c25 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 6 Apr 2013 17:01:15 +0200 Subject: Metadata format parsing bugfix --- unpixelterm.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/unpixelterm.py b/unpixelterm.py index fdde9c0..b9190b2 100755 --- a/unpixelterm.py +++ b/unpixelterm.py @@ -43,11 +43,18 @@ def unpixelterm(text): try: first = lines.index('$$$') second = lines[first+1:].index('$$$') - foo = [ line.split(': ') for line in lines[first+1:second] if line != '' ] + comment = [] d = {} - for k,v in foo: - if k not in ['WIDTH', 'HEIGHT']: - d[k.lower()] = d.get(k.lower(), []) + [v] + for l in lines[first+1:second]: + parts = l.split(': ') + if len(parts) == 2: + k,v = parts + if k not in ['WIDTH', 'HEIGHT']: + d[k.lower()] = d.get(k.lower(), []) + [v] + elif l != '': + comment.append(l) + if comment: + d['comment'] = d.get('comment', []) + comment metadata.update(d) lines[first:] = lines[first+1+second+1:] except: -- cgit