def __getattr__(self, name): options = DEFAULTS[self.section] convert, default, doc = options[name] value = Config.config.get(self.section, name) try: return convert(value) except ConfigError as e: raise ConfigError("Error in .wpmrc section %r option %r: %s" % (self.section, name, e))
def int_tuple(s): """Parses a string containing a tuple of two ints.""" try: if (s[0] != "(") or (s[-1] != ")"): raise ValueError() values = s[1:-1].split(",") if len(values) != 2: raise ValueError() return map(int, values) except ValueError: raise ConfigError("Required format is (integer, integer): %s" % s)
def verify(self): """Verifies wpmrc values.""" level = self.wpm.confidence_level if not 0 < level < 1: raise ConfigError( "The .wpmrc confidence level must be within [0, 1>")