""" RSS->IMAP gateway - read your favourite RSS feeds with your favourite email client """ __version__ = "0.1" __license__ = "Python" __copyright__ = "Copyright 2005, Jens Georg" __author__ = "Jens Georg " from ConfigParser import ConfigParser, NoOptionError import Feed class ConfigError(Exception): def __init__(self, value): self.value = calue def __str__(self): return repr (self.value) class Config: def __init__(self, file): self.feeds = [] self.config = ConfigParser() try: self.config.read (file) except: raise if not self.config.has_section ("config"): raise ConfigError ("Invalid config file. Global section is missing") try: self.port = self.config.getint ("config", "port") except NoOptionError: self.port = 4444 try: self.interface = self.config.get ("config", "bind") except NoOptionError: self.interface = '' try: self.logfile = self.config.get ("config", "log") except NoOptionError: self.logfile = "stderr" try: self.toaddress = self.config.get ("config", "toaddress") except NoOptionError: self.toaddress = "none@localhost" for group in self.config.sections(): if group == "config": continue try: url = self.config.get (group, "url") except NoOptionError: raise ConfigError ("Invalid config file. There is no URL for feed %s" % group); try: timeout = self.config.getint (group, "timeout") except NoOptionError: timeout = 3600 try: force_html = self.config.getboolean (group, "force_html") except NoOptionError: force_html = False try: user = self.config.get (group, "user") except NoOptionError: user = None if user: try: password = self.config.get (group, "password") except NoOptionError: password = "" else: password = None self.feeds.append(Feed.create (group, url, timeout, force_html, user, password))