Add -c option to read additional config file.
authorAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 18:31:17 +0000 (18:31 +0000)
committerAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 18:31:17 +0000 (18:31 +0000)
Send config-parsing output to stderr, and show the name of the config
  file upon error.

NEWS
README
rawdoglib/rawdog.py

diff --git a/NEWS b/NEWS
index 4fbd30c071815e5c9a8c97410d76e2da73e2e8c7..0a1ba6fe467f704e1dd5e70689b0c7bbe48558c3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,11 +11,15 @@ now encoded in UTF-8 rather than ISO-8859-1 as before).
 Use standard option syntax (i.e. "--update --write" instead of "update
 write").  The old syntax will be supported until 2.0.
 
-Warning output from --update now goes to stderr instead of stdout.
+Error output from reading the config file and from --update now goes to
+stderr instead of stdout.
 
 Made the socket timeout configurable (which also means the included copy
 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.
+
 - rawdog 1.2
 
 Updated feedparser to 2.5.2, which fixes a bug that was making rawdog
diff --git a/README b/README
index b86f6aa8c555b32e8aaad49a429ba8ca02abf07d..8134c5cddb84c69a5cef471d5960817377bfe556 100644 (file)
--- a/README
+++ b/README
@@ -45,6 +45,15 @@ known feed: Update that feed immediately, even if its period hasn't
 elapsed since it was last updated. This is useful if you're trying to
 debug your own feed.
 
+"--config FILE" (or "-c FILE"), where FILE is an absolute path or a path
+relative to your .rawdog directory: Read FILE as an additional config
+file; any options provided in FILE will override those set in the
+default config (with the exception of "feed", which is cumulative).
+This is useful if you want rawdog to write two different output files
+with different sets of options ("rawdog -u -w -c config2 -w" will first
+update and write with the default config, then read config2, then write
+again).
+
 You will want to run "rawdog -uw" periodically to fetch data and write
 the output file. The easiest way to do this is to add a crontab entry
 that looks something like this:
index 9982fbb570009c65f05c73859b8d71ff318dd61b..1a263b8144182da92606593e30e4582bb7c85495 100644 (file)
@@ -488,15 +488,18 @@ Usage: rawdog [OPTION]...
 -l, --list                   List feeds known at time of last update
 -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
 --help                       Display this help and exit
 
+Actions are taken in the order they are given on the command line.
+
 Report bugs to <azz@us-lot.org>."""
 
 def main(argv):
        """The command-line interface to the aggregator."""
 
        try:
-               (optlist, args) = getopt.getopt(argv, "ulwf:", ["update", "list", "write", "update-feed=", "help"])
+               (optlist, args) = getopt.getopt(argv, "ulwf:c:", ["update", "list", "write", "update-feed=", "help", "config="])
        except getopt.GetoptError, s:
                print s
                usage()
@@ -525,7 +528,8 @@ def main(argv):
        try:
                config.load("config")
        except ConfigError, err:
-               print err
+               print >>sys.stderr, "In config:"
+               print >>sys.stderr, err
                return 1
 
        persister = Persister("state", Rawdog)  
@@ -540,6 +544,13 @@ def main(argv):
                        rawdog.write(config)
                elif o in ("-f", "--update-feed"):
                        rawdog.update(config, a)
+               elif o in ("-c", "--config"):
+                       try:
+                               config.load(a)
+                       except ConfigError, err:
+                               print >>sys.stderr, "In " + a + ":"
+                               print >>sys.stderr, err
+                               return 1
 
        persister.save()