From: Adam Sampson Date: Sat, 20 Sep 2003 18:36:39 +0000 (+0000) Subject: Allow "outputfile -". X-Git-Tag: v1.3~8 X-Git-Url: http://git.ozo.com/?a=commitdiff_plain;h=7193772a00b9af9a77cf5ce1b1c26d4ca780a5b8;p=rawdog%2F.git Allow "outputfile -". --- diff --git a/NEWS b/NEWS index 0a1ba6f..16e25c8 100644 --- 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 c4e643f..1fdbe30 100644 --- 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 tag diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 1a263b8..8486496 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -471,13 +471,17 @@ by Adam Sampson.

print >>f, """""" 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."""