From 25dc1b0efb311465bc30e4e6be64d062a1b891a3 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 20 Sep 2003 18:44:23 +0000 Subject: [PATCH] Add --show-template. --- NEWS | 3 +++ rawdoglib/rawdog.py | 34 +++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 16e25c8..0ef4be0 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,9 @@ 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. +Added --show-template option to show the template currently in use (so +you can customise it yourself). + - rawdog 1.2 Updated feedparser to 2.5.2, which fixes a bug that was making rawdog diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 8486496..07acb97 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -354,16 +354,7 @@ class Rawdog(Persistable): self.modified() - def write(self, config): - outputfile = config["outputfile"] - now = time.time() - - bits = { "version" : VERSION } - - refresh = 24 * 60 - for feed in self.feeds.values(): - if feed.period < refresh: refresh = feed.period - + def get_template(self, config): template = """ @@ -373,7 +364,7 @@ class Rawdog(Persistable): if config["userefresh"]: template += """__refresh__ """ - template += """ + template += """ rawdog @@ -396,6 +387,20 @@ by Adam Sampson.

""" + return template + + def show_template(self, config): + print self.get_template(config) + + def write(self, config): + outputfile = config["outputfile"] + now = time.time() + + bits = { "version" : VERSION } + + refresh = 24 * 60 + for feed in self.feeds.values(): + if feed.period < refresh: refresh = feed.period bits["refresh"] = """""" @@ -471,7 +476,7 @@ by Adam Sampson.

print >>f, """""" bits["feeds"] = f.getvalue() - s = template + s = get_template() for k in bits.keys(): s = s.replace("__" + k + "__", bits[k]) @@ -493,6 +498,7 @@ Usage: rawdog [OPTION]... -w, --write Write out HTML output -f|--update-feed URL Force an update on the single feed URL -c|--config FILE Read additional config file FILE +-t, --show-template Print the template currently in use --help Display this help and exit Actions are taken in the order they are given on the command line. @@ -503,7 +509,7 @@ def main(argv): """The command-line interface to the aggregator.""" try: - (optlist, args) = getopt.getopt(argv, "ulwf:c:", ["update", "list", "write", "update-feed=", "help", "config="]) + (optlist, args) = getopt.getopt(argv, "ulwf:c:t", ["update", "list", "write", "update-feed=", "help", "config=", "show-template"]) except getopt.GetoptError, s: print s usage() @@ -555,6 +561,8 @@ def main(argv): print >>sys.stderr, "In " + a + ":" print >>sys.stderr, err return 1 + elif o in ("-t", "--show-template"): + rawdog.show_template(config) persister.save() -- 2.35.1