def load(fname, cfg=None): try: fp = contread.openfile(fname) res = _loadfile(fp, cfg) fp.close() return res except EnvironmentError as e: raise derrors.IOErr("could not read config file %s: %s" % (fname, str(e))) except contread.StartingContinuedLine as e: raise derrors.CfgErr("configuration file %s: %s" % (fname, str(e))) except derrors.CfgErr as e: raise derrors.CfgErr("configuration file %s: %s" % (fname, str(e)))
def testOpenNull(self): "Can we open /dev/null and get immediate EOF?" fp = contread.openfile("/dev/null") self.assertEqual(fp.readcontline(), '')