From 55fb31325d1c85f5ffacc00359a2ff0c572e87d8 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sat, 6 Aug 2011 21:29:56 +0200 Subject: [PATCH] State expiration updated State expiration is only done when the --tail is in use. --- wikirc2text.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/wikirc2text.py b/wikirc2text.py index 2548cc5..eb60afb 100644 --- a/wikirc2text.py +++ b/wikirc2text.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # # wikirc2text - dump MediaWiki RecentChanges into text line while keeping -# the state of the already seen lines. -# +# the state of the already seen lines. +# # Copyright (C) 2011 Alexandre Dulaunoy (a AT foo.be) # # This program is free software: you can redistribute it and/or modify @@ -75,6 +75,8 @@ def core (): print rcline.encode('utf-8') if x > 1: time.sleep(float(options.wait)) + if options.statesec is not None: + expirecache(options.statesec) if (options.state): s.close() @@ -91,10 +93,7 @@ def expirecache (seconds): sdeleted=sdeleted+1 s.close() - print "%s states deleted" % str(sdeleted) - -if not options.statesec: - core() -else: - expirecache(options.statesec) + log = "%s states deleted" % str(sdeleted) + sys.stderr.write(log) +core()