Show More
@@ -13,16 +13,14 b' def parsemeta(text):' | |||||
13 | """return (metadatadict, keylist, metadatasize)""" |
|
13 | """return (metadatadict, keylist, metadatasize)""" | |
14 | # text can be buffer, so we can't use .startswith or .index |
|
14 | # text can be buffer, so we can't use .startswith or .index | |
15 | if text[:2] != '\1\n': |
|
15 | if text[:2] != '\1\n': | |
16 |
return None, None |
|
16 | return None, None | |
17 | s = _mdre.search(text, 2).start() |
|
17 | s = _mdre.search(text, 2).start() | |
18 | mtext = text[2:s] |
|
18 | mtext = text[2:s] | |
19 | meta = {} |
|
19 | meta = {} | |
20 | keys = [] |
|
|||
21 | for l in mtext.splitlines(): |
|
20 | for l in mtext.splitlines(): | |
22 | k, v = l.split(": ", 1) |
|
21 | k, v = l.split(": ", 1) | |
23 | meta[k] = v |
|
22 | meta[k] = v | |
24 | keys.append(k) |
|
23 | return meta, (s + 2) | |
25 | return meta, keys, (s + 2) |
|
|||
26 |
|
24 | |||
27 | def packmeta(meta, text): |
|
25 | def packmeta(meta, text): | |
28 | keys = sorted(meta.iterkeys()) |
|
26 | keys = sorted(meta.iterkeys()) |
General Comments 0
You need to be logged in to leave comments.
Login now