diff options
author | jaseg <s@jaseg.de> | 2013-04-06 17:01:15 +0200 |
---|---|---|
committer | jaseg <s@jaseg.de> | 2013-04-06 17:02:35 +0200 |
commit | e6e6d578da31c5ebd4c32f4fa5b6296591f99c25 (patch) | |
tree | 70cb8acbb285de1e7dabe30a1c19955ce983b971 | |
parent | bf49f9dc679b83b136a782759bcdac361e91783f (diff) | |
download | pixelterm-e6e6d578da31c5ebd4c32f4fa5b6296591f99c25.tar.gz pixelterm-e6e6d578da31c5ebd4c32f4fa5b6296591f99c25.tar.bz2 pixelterm-e6e6d578da31c5ebd4c32f4fa5b6296591f99c25.zip |
Metadata format parsing bugfix
-rwxr-xr-x | unpixelterm.py | 15 |
1 files 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: |