Byron Clark  committed 85f76ce

Add an option for an alternate config file.

  • Participants
  • Parent commits 9e06445
  • Branches default

Comments (0)

Files changed (2)

File bin/comicbox

 if __name__ == '__main__':
     import datetime
     import logging
+    import optparse
     import os
     import string
     import sys
+    logger = logging.getLogger('comicbox')
+    parser = optparse.OptionParser()
+    parser.add_option('-f', '--file', dest='filename',
+                      help='alternate configuration FILE', metavar='FILE')
+    (options, args) = parser.parse_args()
     import comicbox.configuration
     from import fetch_strips
-    logger = logging.getLogger('comicbox')
-    today =
     # parse the configuration
-        exepath = os.path.dirname(os.path.abspath(sys.argv[0]))
-        conf = comicbox.configuration.load_configuration(exepath)
+        configs = [os.path.expanduser('~/.comicboxrc')]
+        if options.filename:
+            configs.append(options.filename)
+        conf = comicbox.configuration.load_configuration(configs)
     except comicbox.configuration.ConfigurationError, err:
         logger.fatal('unable to load configuration: %s' % (err,))
     except ImportError, err:
         logger.fatal('unable to load backend: %s' % (err,))
+    today =
     b = backend(today, backend_args)
     fetch_strips(strips, b, today)

File comicbox/

-def load_configuration(exepath):
+def load_configuration(config_files):
     """load comicbox configuration from a file.
-    Loads the comicbox configuration from comicboxrc in same dir as
-    sys.argv[0] and ~/.comicboxrc.  Settings in ~/.comicboxrc override settings
-    in sys.argv[0]/comicboxrc.
+    Loads the comicbox configuration from config_files.
     There must be at least a 'comicbox' section in the configuration file.
     This section holds the backend and chosen strips.  If the backend takes
     additional parameters they will be in a section with the same name as the
     backend.  See doc/comicboxrc.example for an example."""
-    config_files = [os.path.join(exepath, 'comicboxrc'),
-                    os.path.expanduser('~/.comicboxrc')]
     parser = ConfigParser.SafeConfigParser()
     if len( == 0:
         raise ConfigurationError('No configuration files found')