# HG changeset patch # User Paul Boddie # Date 1367856364 -7200 # Node ID 665a909bdb2710dca3b7371559159b1c43084352 # Parent 6c0a2c15d1ca3602790eafe10fba80f096352b06 Added a function to read and return cached item metadata. diff -r 6c0a2c15d1ca -r 665a909bdb27 MoinRemoteSupport.py --- a/MoinRemoteSupport.py Sun May 05 20:32:20 2013 +0200 +++ b/MoinRemoteSupport.py Mon May 06 18:06:04 2013 +0200 @@ -2,10 +2,11 @@ """ MoinMoin - MoinRemoteSupport library - @copyright: 2011, 2012 by Paul Boddie + @copyright: 2011, 2012, 2013 by Paul Boddie @license: GNU GPL (v2 or later), see COPYING.txt for details. """ +from ContentTypeSupport import getContentTypeAndEncoding from MoinMoin.action import cache from MoinMoin import caching import urllib2, time @@ -77,4 +78,21 @@ finally: cache_entry.close() +def getCachedResourceMetadata(f): + + "Return a metadata dictionary for the given resource file-like object 'f'." + + url = f.readline() + content_type, encoding = getContentTypeAndEncoding(f.readline()) + + metadata = {} + line = f.readline() + + while line.strip(): + key, value = [v.strip() for v in line.split(":", 1)] + metadata[key] = value + line = f.readline() + + return url, content_type, encoding, metadata + # vim: tabstop=4 expandtab shiftwidth=4