3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

[WIP] conf: re-add 'fname' variable (used by REHASH)

This commit is contained in:
James Lu 2016-06-21 11:31:39 -07:00
parent 3a57e8d595
commit dce768017a

11
conf.py
View File

@ -31,16 +31,17 @@ def validateConf(conf):
return conf return conf
def loadConf(fname, errors_fatal=True): def loadConf(filename, errors_fatal=True):
"""Loads a PyLink configuration file from the filename given.""" """Loads a PyLink configuration file from the filename given."""
global confname, conf global confname, conf, fname
confname = fname.split('.', 1)[0] fname = filename
with open(fname, 'r') as f: confname = filename.split('.', 1)[0]
with open(filename, 'r') as f:
try: try:
conf = yaml.load(f) conf = yaml.load(f)
conf = validateConf(conf) conf = validateConf(conf)
except Exception as e: except Exception as e:
print('ERROR: Failed to load config from %r: %s: %s' % (fname, type(e).__name__, e)) print('ERROR: Failed to load config from %r: %s: %s' % (filename, type(e).__name__, e))
if errors_fatal: if errors_fatal:
sys.exit(4) sys.exit(4)
raise raise