Retrieve cwlkeys from inputs, handling defaults which can be null.

    When inputs are null in some and present in others, this creates unequal
    keys in each sample, confusing decision making about which are primary and extras.
12700
def _get_all_cwlkeys(items, default_keys=None):
    
    if default_keys:
        default_keys = set(default_keys)
    else:
        default_keys = set(["metadata__batch", "config__algorithm__validate",
                            "config__algorithm__validate_regions",
                            "config__algorithm__validate_regions_merged",
                            "config__algorithm__variant_regions",
                            "validate__summary",
                            "validate__tp", "validate__fp", "validate__fn",
                            "config__algorithm__coverage", "config__algorithm__coverage_merged",
                            "genome_resources__variation__cosmic", "genome_resources__variation__dbsnp",
                            "genome_resources__variation__clinvar"
        ])
    all_keys = set([])
    for data in items:
        all_keys.update(set(data["cwl_keys"]))
    all_keys.update(default_keys)
    return all_keys
559692
def get_input(context, conf):
    
    name = conf['name']['value']
    prompt = conf['prompt']['value']
    default = conf['default']['value'] or conf['debug']['value']

    if context.submodule or context.inputs:
        value = context.inputs.get(name, default)
    elif not context.test:
        # we skip user interaction during tests
        raw = raw_input("%s (default=%s) " % (encode(prompt), encode(default)))
        value = raw or default
    else:
        value = default

    return value
883967
public boolean updateDefaultKeys(String from, String to) {
        if (null == from) {
            return false;
        }
        if (null == to) {
            return false;
        }
        if (StringUtils.equals(from, to)) {
            return false;
        }
        String value = this.defaultValues.remove(from);
        if (null == value) {
            return false;
        }
        this.defaultValues.put(to, value);
        return true;
    }
1078636
function(value)
	{
		for (var key in mxStyleRegistry.values)
		{
			if (mxStyleRegistry.values[key] == value)
			{
				return key;
			}
		}
		
		return null;
	}
704985
function defaults(array, defaults) {

  if(!isArray(array) || !isObject(defaults)) {
    return array;
  }
  //get defaults keys(include nested).
  var keys = deepKeys(defaults);

  array.forEach(function(elm) {
    //loop through all the keys
    keys.forEach(function(key) {
      var getter = $parse(key);
      var setter = getter.assign;
      //if it's not exist
      if(isUndefined(getter(elm))) {
        //get from defaults, and set to the returned object
        setter(elm, getter(defaults))
      }
    });
  });

  return array;
}
1334783
def _process_input_wcs_single(fname, wcskey, updatewcs):
    
    if wcskey in ['', ' ', 'INDEF', None]:
        if updatewcs:
            uw.updatewcs(fname, checkfiles=False)
    else:
        numext = fileutil.countExtn(fname)
        extlist = []
        for extn in range(1, numext + 1):
            extlist.append(('SCI', extn))
        if wcskey in string.ascii_uppercase:
            wkey = wcskey
            wname = ' '
        else:
            wname = wcskey
            wkey = ' '
        altwcs.restoreWCS(fname, extlist, wcskey=wkey, wcsname=wname)
    # make an asn table at the end
    # Make sure there is a WCSCORR table for each input image
    if wcskey not in ['', ' ', 'INDEF', None] or updatewcs:
        wcscorr.init_wcscorr(fname)
907497
function discoverKey(arr, discoverableKeys, defaultKey) {
  if (arr.length === 0) return defaultKey;
  if (arr.length === 1) return arr[0];
  for (var i = 0; i < arr.length; i++) {
    if (discoverableKeys[arr[i]]) return arr[i];
  }
  return defaultKey;
}
491198
@Deprecated
  public static <K, V> V getOrPutDefault(Map<K, V> map, K key, Supplier<V> defaultGetter) {
    return map.computeIfAbsent(key, k -> defaultGetter.get());
  }
1117095
public function input($key=null, $default=null)
	{
	    if ($key && $key !== '*') {
	        return isset($_SERVER['argv'][$key]) ? $_SERVER['argv'][$key] : $default;
	    } else {
	        return isset($_SERVER['argv']) ? $_SERVER['argv'] : [];
	    }
	}
1276617
public alluxio.grpc.InconsistentPropertyValues getValuesOrDefault(
      java.lang.String key,
      alluxio.grpc.InconsistentPropertyValues defaultValue) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, alluxio.grpc.InconsistentPropertyValues> map =
        internalGetValues().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
917051
def _normalize_cwl_inputs(items):
    
    with_validate = {}
    vrn_files = []
    ready_items = []
    batch_samples = []
    for data in (cwlutils.normalize_missing(utils.to_single_data(d)) for d in items):
        batch_samples.append(dd.get_sample_name(data))
        if tz.get_in(["config", "algorithm", "validate"], data):
            with_validate[_checksum(tz.get_in(["config", "algorithm", "validate"], data))] = data
        if data.get("vrn_file"):
            vrn_files.append(data["vrn_file"])
        ready_items.append(data)
    if len(with_validate) == 0:
        data = _pick_lead_item(ready_items)
        data["batch_samples"] = batch_samples
        return data
    else:
        assert len(with_validate) == 1, len(with_validate)
        assert len(set(vrn_files)) == 1, set(vrn_files)
        data = _pick_lead_item(with_validate.values())
        data["batch_samples"] = batch_samples
        data["vrn_file"] = vrn_files[0]
        return data
81447
def _to_cwldata(key, val, get_retriever):
    
    out = []
    if isinstance(val, dict):
        if len(val) == 2 and "base" in val and "indexes" in val:
            if len(val["indexes"]) > 0 and val["base"] == val["indexes"][0]:
                out.append(("%s__indexes" % key, _item_to_cwldata(val["base"], get_retriever)))
            else:
                out.append((key, _to_cwlfile_with_indexes(val, get_retriever)))
        # Dump shared nested keys like resources as a JSON string
        elif key in workflow.ALWAYS_AVAILABLE or key in workflow.STRING_DICT:
            out.append((key, _item_to_cwldata(json.dumps(val), get_retriever)))
        elif key in workflow.FLAT_DICT:
            flat = []
            for k, vs in val.items():
                if not isinstance(vs, (list, tuple)):
                    vs = [vs]
                for v in vs:
                    flat.append("%s:%s" % (k, v))
            out.append((key, _item_to_cwldata(flat, get_retriever)))
        else:
            remain_val = {}
            for nkey, nval in val.items():
                cur_nkey = "%s__%s" % (key, nkey)
                cwl_nval = _item_to_cwldata(nval, get_retriever)
                if isinstance(cwl_nval, dict):
                    out.extend(_to_cwldata(cur_nkey, nval, get_retriever))
                elif key in workflow.ALWAYS_AVAILABLE:
                    remain_val[nkey] = nval
                else:
                    out.append((cur_nkey, cwl_nval))
            if remain_val:
                out.append((key, json.dumps(remain_val, sort_keys=True, separators=(',', ':'))))
    else:
        out.append((key, _item_to_cwldata(val, get_retriever)))
    return out
1102350
public function input(string $key = null, $default = null)
    {
        $inputs = $this->getQueryParams() + $this->getParsedBody();
        if (is_null($key)) {
            return $inputs;
        }
        return $inputs[$key] ?? $default;
    }
1162598
def get(key, default=None):
    '''
    
    '''
    store = load()

    if isinstance(key, six.string_types):
        return store.get(key, default)
    elif default is None:
        return [store[k] for k in key if k in store]
    else:
        return [store.get(k, default) for k in key]
1134117
private V getForNullKey() {
	for (Entry<K, V> e = table[0]; e != null; e = e.next) {
	    if (e.key == null) return e.value;
	}
	return null;
    }
1313729
@Override
    public Set<String> getKeys() {
        Map<String, String> map = inheritableThreadLocal.get();
        if (map != null) {
            return map.keySet();
        } else {
            return null;
        }
    }
898021
def get_input(self, key, force=False):
        
        if key not in self._inputs:
            raise InputException("Key {0} is not a valid input!".format(key))

        if self._inputs[key].prompt:
            prompt = self._inputs[key].prompt
        elif self._inputs[key].is_bool():
            prompt = "{0}?".format(key)
        else:
            prompt = "please enter your {0}".format(key)
        help_text = self._inputs[key].help if hasattr(self._inputs[key], 'help') else None

        if self._inputs[key].value is EMPTY or force:

            default_value = None
            if self._inputs[key].default is not EMPTY:
                default_value = self._inputs[key].default
            if self._inputs[key].value is not EMPTY:
                default_value = self._inputs[key].value

            input_value = EMPTY
            while input_value is EMPTY or input_value == '?':
                if input_value == '?' and help_text:
                    print(help_text)
                input_value = lib.prompt(
                    prompt,
                    default=default_value,
                    bool_type=self._inputs[key].in_type,
                    secret=self._inputs[key].is_secret)
            self._inputs[key].value = input_value

        return self._inputs[key].value