3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

conf: split off absolute paths in confname

This fixes invalid database names such as "automode-/tmp/test.db" from being generated when PyLink is started with an absolute path to its config.

Closes #358.
This commit is contained in:
James Lu 2016-11-02 22:23:45 -07:00
parent 441bf5f048
commit 9950e0948f

View File

@ -11,6 +11,7 @@ except ImportError:
raise ImportError("Please install PyYAML and try again.")
import sys
import os.path
from collections import defaultdict
from . import world
@ -58,8 +59,10 @@ def validateConf(conf):
def loadConf(filename, errors_fatal=True):
"""Loads a PyLink configuration file from the filename given."""
global confname, conf, fname
# Note: store globally the last loaded conf filename, for REHASH in coremods/control.
fname = filename
confname = filename.split('.', 1)[0]
# For the internal config name, strip off any .yml extensions and absolute paths
confname = os.path.basename(filename).split('.', 1)[0]
try:
with open(filename, 'r') as f:
conf = yaml.load(f)