def sxpr_file(self, fin): try: vals = sxp.parse(fin) except: raise ArgError('Coercion to sxpr failed') if len(vals) == 1: return vals[0] else: raise ArgError('Too many sxprs')
def set_config(self): """If the config file exists, read it. If not, ignore it. The config file is a sequence of sxp forms. """ self.config_path = os.getenv(self.config_var, self.config_default) if os.path.exists(self.config_path): try: fin = file(self.config_path, 'rb') try: config = sxp.parse(fin) finally: fin.close() if config is None: config = ['xend-config'] else: config.insert(0, 'xend-config') self.config = config except Exception, ex: self._logError('Reading config file %s: %s', self.config_path, str(ex)) raise