Allow "outputfile -".
authorAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 18:36:39 +0000 (18:36 +0000)
committerAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 18:36:39 +0000 (18:36 +0000)
NEWS
config
rawdoglib/rawdog.py

diff --git a/NEWS b/NEWS
index 0a1ba6fe467f704e1dd5e70689b0c7bbe48558c3..16e25c82a4ad23481bd89e1bbc3f54d4785b411b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,10 @@ of feedparser isn't modified any more).
 Added --config option to read an additional config file; this lets you
 have multiple output files with different options.
 
+Allow "outputfile -" to write the output to stdout; useful if you want
+to have cron mail the output to you rather than putting it on a web
+page.
+
 - rawdog 1.2
 
 Updated feedparser to 2.5.2, which fixes a bug that was making rawdog
diff --git a/config b/config
index c4e643fe2b876388813ccd29afb64cdff7173f2b..1fdbe3053200ac57c730bee58e7d81290e1d18dd 100644 (file)
--- a/config
+++ b/config
@@ -13,7 +13,7 @@ dayformat %A, %d %B
 timeformat %H:%M
 
 # Where to write the output HTML to. You should place style.css in the same
-# directory.
+# directory. Specify this as "-" to write the HTML to stdout.
 outputfile /home/azz/public_html/rawdog.html
 
 # Whether to use (1) or not use (0) a <meta http-equiv="Refresh" ...> tag
index 1a263b8144182da92606593e30e4582bb7c85495..84864963f6db4f6882d7cefd7f8de203685282da 100644 (file)
@@ -471,13 +471,17 @@ by <a href="mailto:azz@us-lot.org">Adam Sampson</a>.</p>
                print >>f, """</table>"""
                bits["feeds"] = f.getvalue()
 
-               f = open(outputfile + ".new", "w")
                s = template
                for k in bits.keys():
                        s = s.replace("__" + k + "__", bits[k])
-               print >>f, s
-               f.close()
-               os.rename(outputfile + ".new", outputfile)
+
+               if outputfile == "-":
+                       print s
+               else:
+                       f = open(outputfile + ".new", "w")
+                       print >>f, s
+                       f.close()
+                       os.rename(outputfile + ".new", outputfile)
 
 def usage():
        """Display usage information."""