from os import path

class ConfigPath(object):
    def __getattr__(self, key):
        return_path = path.join(path.dirname(__file__), key + '.cfg')
        if not path.exists(return_path): return None
        return return_path

config_path = ConfigPath()

from os import path

class ConfigPath(object):
    def __init__(self):
        self.config_paths = [path.join(path.expanduser('~'), '.magpie'), path.dirname(__file__)]
    def __getattr__(self, key):
        for path in self.config_paths:
            return_path = path.join(path, key + '.cfg')
            if path.exists(return_path): return return_path
        return None

config_path = ConfigPath()

Enable configuration from home directory
Enable configuration from home directory

This adds the possibility of defining multiple locations for the config-files. The given example first searches in ~/.magpie and if it doesn't find any config-files there, it searches in the default path. This enables configuration for each individual user and fixes the problem that magpie must be run as root if it was installed as root.