diff --git a/docs/filters.html b/docs/filters.html index b4a0394..865aa41 100644 --- a/docs/filters.html +++ b/docs/filters.html @@ -13,7 +13,7 @@ parameters come from the config file, and output goes to stdout. Anything written to stderr is logged as an ERROR message. If no stdout is produced, the entry is not written to the cache or -processed further.

+processed further; in fact, if the entry had previously been written to the cache, it will be removed.

Input to a filter is a aggressively normalized entry. For @@ -54,6 +54,18 @@ instead of XPath expressions.

Notes

diff --git a/planet/spider.py b/planet/spider.py index 3ee8515..e88d203 100644 --- a/planet/spider.py +++ b/planet/spider.py @@ -194,7 +194,9 @@ def writeCache(feed_uri, feed_info, data): for filter in config.filters(feed_uri): output = shell.run(filter, output, mode="filter") if not output: break - if not output: continue + if not output: + if os.path.exists(cache_file): os.remove(cache_file) + continue # write out and timestamp the results write(output, cache_file) diff --git a/tests/test_spider.py b/tests/test_spider.py index ecf5986..1936f8d 100644 --- a/tests/test_spider.py +++ b/tests/test_spider.py @@ -73,6 +73,14 @@ class SpiderTest(unittest.TestCase): self.spiderFeed(testfeed % '1b') self.verify_spiderFeed() + def test_spiderFeed_retroactive_filter(self): + config.load(configfile) + self.spiderFeed(testfeed % '1b') + self.assertEqual(5, len(glob.glob(workdir+"/*"))) + config.parser.set('Planet', 'filter', 'two') + self.spiderFeed(testfeed % '1b') + self.assertEqual(1, len(glob.glob(workdir+"/*"))) + def test_spiderUpdate(self): config.load(configfile) self.spiderFeed(testfeed % '1a')