1.1 --- a/MoinRemoteSupport.py Sun May 05 20:32:20 2013 +0200
1.2 +++ b/MoinRemoteSupport.py Mon May 06 18:06:04 2013 +0200
1.3 @@ -2,10 +2,11 @@
1.4 """
1.5 MoinMoin - MoinRemoteSupport library
1.6
1.7 - @copyright: 2011, 2012 by Paul Boddie <paul@boddie.org.uk>
1.8 + @copyright: 2011, 2012, 2013 by Paul Boddie <paul@boddie.org.uk>
1.9 @license: GNU GPL (v2 or later), see COPYING.txt for details.
1.10 """
1.11
1.12 +from ContentTypeSupport import getContentTypeAndEncoding
1.13 from MoinMoin.action import cache
1.14 from MoinMoin import caching
1.15 import urllib2, time
1.16 @@ -77,4 +78,21 @@
1.17 finally:
1.18 cache_entry.close()
1.19
1.20 +def getCachedResourceMetadata(f):
1.21 +
1.22 + "Return a metadata dictionary for the given resource file-like object 'f'."
1.23 +
1.24 + url = f.readline()
1.25 + content_type, encoding = getContentTypeAndEncoding(f.readline())
1.26 +
1.27 + metadata = {}
1.28 + line = f.readline()
1.29 +
1.30 + while line.strip():
1.31 + key, value = [v.strip() for v in line.split(":", 1)]
1.32 + metadata[key] = value
1.33 + line = f.readline()
1.34 +
1.35 + return url, content_type, encoding, metadata
1.36 +
1.37 # vim: tabstop=4 expandtab shiftwidth=4