1127ff5fdcdfbe89efee98614cf4d4e2c29da4a8,deploy/utils/utils.py,,resolve_env_vars,#,296

Before Change



def resolve_env_vars(config):
  Recursively resolves environment variables in config values.
  if isinstance(config, str):
    return string.Template(config).substitute(os.environ)
  elif isinstance(config, dict):
    return {k: resolve_env_vars(v) for k, v in config.items()}
  elif isinstance(config, list):
    return [resolve_env_vars(i) for i in config]
  else:
    return config


def merge_dicts(*dicts):
  Merge dicts (list of dicts) into a new dictionary.

  Args:

After Change


  if isinstance(config, dict):
    keys = config.keys()
  elif isinstance(config, list):
    keys = range(len(config))
  else:
    return

  for k in keys:
    // Only do substitutions on strings.
    v = config[k]
    if isinstance(v, str):
      config[k] = string.Template(v).substitute(os.environ)
    else:
      // Recursively handle lists and dictionaries.
      resolve_env_vars(v)


def merge_config_dicts(root_config, included_configs):
  Merge config dicts (list of dicts) into a root config dictionary.

  Top-level lists with the same key (e.g. "projects") are concatenated, other
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: GoogleCloudPlatform/healthcare
Commit Name: 1127ff5fdcdfbe89efee98614cf4d4e2c29da4a8
Time: 2019-02-11
Author: noreply@google.com
File Name: deploy/utils/utils.py
Class Name:
Method Name: resolve_env_vars


Project Name: pymanopt/pymanopt
Commit Name: a1be7bf2f0926707e25b02570c17ba373878f768
Time: 2016-03-14
Author: jamiehntownsend@gmail.com
File Name: pymanopt/manifolds/psd.py
Class Name: PositiveDefinite
Method Name: exp


Project Name: chainer/chainercv
Commit Name: 90b78b1379b3423aa3b4b5d0de7313f88bda23ab
Time: 2019-02-17
Author: yuyuniitani@gmail.com
File Name: chainercv/utils/mask/mask_to_bbox.py
Class Name:
Method Name: mask_to_bbox