1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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): cfg = None return with io.open(cfg_file, 'r') as fp: cfg = yaml.load(fp) fp.close()