Some of the question I have but found answered nowhere:
I have a feedparser object that was created from a string. How can I
trigger a update (from a new string) but the feedparser should treat the
new string like the same feed (thus setting feed.updated etc.).
Hmm. Do you mean that the feed object should stay the same? Like the
difference between "a = [1,2,3]; a = [1,2,3]+[4]" and "a = [1,2,3];
a.append(4)"? I glanced at the parse function in the source code and
it looks like it's not directly possible. You could modify it so that
the "result" dictionary is optionally given as an argument, so when
updating you'd do: feedparser.parse(string, oldFeed). You'd also have
to clear the oldFeed object before update.
But you might also be able to solve the problem by using an additional
layer of indirection. Instead of passing around the "feed" object,
you'd pass around a proxy object like this:
class Empty: pass
proxy = Empty()
proxy.feed = feedparser.parse(string)
storeProxyForLaterUse(proxy)
proxy.feed = feedparser.parse(string2)
useStoredProxy() #this would use the updated feed through the proxy
Then just use proxy.feed.updated everywhere instead of directly
feed.updated. A smarter proxy would automatically translate
proxy.updated into proxy.feed.updated so usage would stay as simple as
without the proxy. Doing this is quite easy in Python (search for
__getattr__ examples).