class DictCfgParser(ConfigParser.ConfigParser): def as_dict(self): d = dict(self._sections) for k in d: d[k] = dict(self._defaults, **d[k]) d[k].pop('__name__', None) return d if "PRJ_ENV" in os.environ: prj_env = os.environ["PRJ_ENV"] else: prj_env = "dev" cfg_path = os.path.join(base.find_path(), 'conf', prj_env) def on_production(): return prj_env == "prod" def on_stagging(): return prj_env == "stagging" def on_dev(): return prj_env == "dev" def load_config(fname):
# -*- coding: utf-8 -*- from __future__ import unicode_literals from contextlib import contextmanager import os import os.path as path import codecs import yaml import logging import gaia.base as base logger = logging.getLogger("gaia") i18n_path = os.path.join(base.find_path(), "i18n") tables = {} for root, dirs, files in os.walk(i18n_path, followlinks=True): logger.info("i18n checking [%s, %s, %s] ..." % (root, str(dirs), str(files))) if path.basename(root) == "i18n": for d in dirs: tables[d] = {} else: lang = path.basename(root) logger.info("initialing language %s ..." % lang) for fnm in files: fpth = os.path.join(root, fnm) bndl = "".join(fnm.split(".")[:-1])