import yaml import io import os cfg_file = None cfg = None def read_config(): global cfg if not cfg_file or not os.path.exists(cfg_file): return None with io.open(cfg_file, 'r') as fp: _cfg = yaml.load(fp) cfg = _cfg