def _update_config_from_env(config, env):
 srcdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
 if (env in ['prod', 'staging']):
  base_cfg_path = ['/etc/inboxapp/secrets.yml', '/etc/inboxapp/config.json']
 else:
  v = {'env': env, 'srcdir': srcdir}
  base_cfg_path = ['{srcdir}/etc/secrets-{env}.yml'.format(**v), '{srcdir}/etc/config-{env}.json'.format(**v)]
 if ('SYNC_ENGINE_CFG_PATH' in os.environ):
  cfg_path = os.environ.get('SYNC_ENGINE_CFG_PATH', '').split(os.path.pathsep)
  cfg_path = list((p.strip() for p in cfg_path if p.strip()))
 else:
  cfg_path = []
 path = (cfg_path + base_cfg_path)
 for filename in reversed(path):
  try:
   f = open(filename)
  except (IOError, OSError) as e:
   if (e.errno != errno.ENOENT):
    raise
  else:
   with f:
    config.update(yaml.safe_load(f))

def _update_config_from_env ( config , env ) : srcdir = os . path . join ( os . path . dirname ( os . path . realpath ( __file__ ) ) , '..' ) if ( env in [ 'prod' , 'staging' ] ) : base_cfg_path = [ '/etc/inboxapp/secrets.yml' , '/etc/inboxapp/config.json' ] else : v = { 'env' : env , 'srcdir' : srcdir } base_cfg_path = [ '{srcdir}/etc/secrets-{env}.yml' . format ( ** v ) , '{srcdir}/etc/config-{env}.json' . format ( ** v ) ] if ( 'SYNC_ENGINE_CFG_PATH' in os . environ ) : cfg_path = os . environ . get ( 'SYNC_ENGINE_CFG_PATH' , '' ) . split ( os . path . pathsep ) cfg_path = list ( ( p . strip ( ) for p in cfg_path if p . strip ( ) ) ) else : cfg_path = [ ] path = ( cfg_path + base_cfg_path ) for filename in reversed ( path ) : try : f = open ( filename ) except ( IOError , OSError ) as e : if ( e . errno != errno . ENOENT ) : raise else : with f : config . update ( yaml . safe_load ( f ) )
update a config dictionary from configuration files specified in the environment .