def read(self, configuration): c = config_t() if (config_read_file(c, self._file) != CONFIG_TRUE): error_text = c.error_text config_destroy(c) raise Exception(error_text) try: self._parser.unparse(c, configuration) finally: config_destroy(c) config_destroy(c) return configuration
def read(self, configuration): if not os.path.isfile(self._file): raise IOError("%s is not a file." % self._file) c = config_t() if (config_read_file(c, self._file) != CONFIG_TRUE): error_text = c.error_text config_destroy(c) raise Exception(error_text) try: self._parser.unparse(c, configuration) finally: config_destroy(c) config_destroy(c) return configuration
def read(self, configuration): if not os.path.isfile(self._file): raise IOError("%s is not a file." % self._file) c = config_t() if (config_read_file(c, self._file) != CONFIG_TRUE): error_text = c.error_text error_line = c.error_line config_destroy(c) raise SyntaxError('cannot read file %s, %s at line %d' % (self._file, error_text, error_line)) try: self._parser.unparse(c, configuration) except SyntaxError as e: raise type(e)("Syntax error in file %s (%s)" % (self._file, str(e))) finally: config_destroy(c) config_destroy(c) return configuration