From 1f9d3358f907d47cc32e6668c5a10e071497c5fe Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 25 Feb 2018 17:40:29 +0000 Subject: [PATCH] Add the --find option. --- NEWS | 3 +++ rawdoglib/rawdog.py | 11 ++++++++++- test-rawdog | 20 +++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 044c092..2e7d5e2 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ When automatically updating the config file in response to an HTTP redirect fails, produce a more sensible error message (including the URL of the feed in question). +Add the --find option, which shows what feedscanner returns for a given +URL (as --dump does for feedparser). + - rawdog 2.22 When handling an HTTP 301 redirect response, check whether the new diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 64ae93f..5c4eaa8 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -1,5 +1,5 @@ # rawdog: RSS aggregator without delusions of grandeur. -# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, 2016, 2017 Adam Sampson +# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Adam Sampson # # rawdog is free software; you can redistribute and/or modify it # under the terms of that license as published by the Free Software @@ -1858,6 +1858,7 @@ Actions (performed in order given): Special actions (all other options are ignored if one of these is specified): --dump URL Show what rawdog's parser returns for URL +--find URL Show what rawdog's feed finder returns for URL --help Display this help and exit Report bugs to .""" @@ -1879,6 +1880,7 @@ def main(argv): "config=", "dir=", "dump=", + "find=", "help", "list", "log=", @@ -1916,6 +1918,13 @@ def main(argv): import pprint pprint.pprint(feedparser.parse(a, agent=HTTP_AGENT)) return 0 + elif o == "--find": + feeds = rawdoglib.feedscanner.feeds(a) + if len(feeds) == 0: + return 1 + for url in feeds: + print url + return 0 elif o == "--help": usage() return 0 diff --git a/test-rawdog b/test-rawdog index c59cc76..b2a13a9 100755 --- a/test-rawdog +++ b/test-rawdog @@ -1,6 +1,6 @@ #!/bin/sh # test-rawdog: run some basic tests to make sure rawdog's working. -# Copyright 2013, 2014, 2015, 2016 Adam Sampson +# Copyright 2013, 2014, 2015, 2016, 2018 Adam Sampson # # rawdog is free software; you can redistribute and/or modify it # under the terms of that license as published by the Free Software @@ -787,6 +787,24 @@ make_atom10 $httpdir/feed.atom run --dump $httpurl/feed.atom contains $outfile example-feed-title +begin "--find, successful" +make_atom10 $httpdir/feed1.atom +make_atom10 $httpdir/feed2.atom +make_html_head $httpdir/page.html < + +EOF +run --find $httpurl/page.html +contains $outfile $httpurl/feed1.atom +contains $outfile $httpurl/feed2.atom + +begin "--find, unsuccessful" +make_html_head $httpdir/page.html <