Add the --find option.
authorAdam Sampson <ats@offog.org>
Sun, 25 Feb 2018 17:40:29 +0000 (17:40 +0000)
committerAdam Sampson <ats@offog.org>
Sun, 25 Feb 2018 17:40:29 +0000 (17:40 +0000)
NEWS
rawdoglib/rawdog.py
test-rawdog

diff --git a/NEWS b/NEWS
index 044c092fd494c20c5595ab358ed728da9103e96f..2e7d5e2fe32850691c703103319e5bd3a5967a30 100644 (file)
--- 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
index 64ae93f13341bc7020c3aca3c97053c92a5a0f27..5c4eaa86d745564328a6b42b72a5de57c87462e2 100644 (file)
@@ -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 <ats@offog.org>
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Adam Sampson <ats@offog.org>
 #
 # 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 <ats@offog.org>."""
@@ -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
index c59cc769f1c031f544ad3660e4356dfbf15002cf..b2a13a976363498edaed5a44c70c515c1f2e9107 100755 (executable)
@@ -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 <ats@offog.org>
+# Copyright 2013, 2014, 2015, 2016, 2018 Adam Sampson <ats@offog.org>
 #
 # 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
+<link rel="alternate" type="application/atom+xml" title="one" href="$httpurl/feed1.atom">
+<link rel="alternate" type="application/atom+xml" title="two" href="$httpurl/feed2.atom">
+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 <<EOF
+(no feeds in this file)
+EOF
+runn --find $httpurl/page.html
+not_contains $outfile '/'
+
 begin "filename"
 make_rss20 $statedir/simple.rss
 add "feed 0 simple.rss"