Clean algorithm keys, handling items that can be specified as lists or single items.
769204
def _clean_algorithm(data):
    
    # convert single items to lists
    for key in ["variantcaller", "jointcaller", "svcaller"]:
        val = tz.get_in(["algorithm", key], data)
        if val:
            if not isinstance(val, (list, tuple)) and isinstance(val, six.string_types):
                val = [val]
            # check for cases like [false] or [None]
            if isinstance(val, (list, tuple)):
                if len(val) == 1 and not val[0] or (isinstance(val[0], six.string_types)
                                                    and val[0].lower() in ["none", "false"]):
                    val = False
            data["algorithm"][key] = val
    return data
868895
def _clean_dict(target_dict, whitelist=None):
    
    assert isinstance(target_dict, dict)
    return {
        ustr(k).strip(): ustr(v).strip()
        for k, v in target_dict.items()
        if v not in (None, Ellipsis, [], (), "")
        and (not whitelist or k in whitelist)
    }
279685
private static String[] normalizeKeys(Object keys) {
		if (keys instanceof Tuple) {
			Tuple tupleKeys = (Tuple) keys;
			if (tupleKeys.getArity() == 0) {
				return new String[0];
			}
			if (tupleKeys.getField(0) instanceof Integer) {
				String[] stringKeys = new String[tupleKeys.getArity()];
				for (int x = 0; x < stringKeys.length; x++) {
					stringKeys[x] = "f0.f" + (Integer) tupleKeys.getField(x);
				}
				return stringKeys;
			}
			if (tupleKeys.getField(0) instanceof String) {
				return tupleToStringArray(tupleKeys);
			}
			throw new RuntimeException("Key argument contains field that is neither an int nor a String: " + tupleKeys);
		}
		if (keys instanceof int[]) {
			int[] intKeys = (int[]) keys;
			String[] stringKeys = new String[intKeys.length];
			for (int x = 0; x < stringKeys.length; x++) {
				stringKeys[x] = "f0.f" + intKeys[x];
			}
601766
def _clean_key_type(key_name, escape_char=ESCAPE_SEQ):
    

    for i in (2, 1):

        if len(key_name) < i:
            return None, key_name

        type_v = key_name[-i:]

        if type_v in _KEY_SPLIT:
            if len(key_name) <= i:
                return _KEY_SPLIT[type_v], ''

            esc_cnt = 0
            for pos in range(-i - 1, -len(key_name) - 1, -1):
                if key_name[pos] == escape_char:
                    esc_cnt += 1
                else:
                    break

            if esc_cnt % 2 == 0:
                return _KEY_SPLIT[type_v], key_name[:-i]
            else:
                return None, key_name

    return None, key_name
738747
def text_cleanup(data, key, last_type):
    
    if key in data and last_type == STRING_TYPE:
        data[key] = data[key].strip()
    return data
1211532
def clean_key(self):
        
        key = self.cleaned_data["key"]
        gpg = get_gpg()
        result = gpg.import_keys(key)
        if result.count == 0:
            raise forms.ValidationError(_("Invalid Key"))
        return key
248454
def only(self, *keys):
        
        items = []

        for key, value in enumerate(self.items):
            if key in keys:
                items.append(value)

        return self.__class__(items)
1074551
def clean_unique_fields(self):
        """"""
        if not self.unique_fields:
            return

        keys = set()
        duplicates = []

        for form in self.forms:
            key = tuple(form.cleaned_data[field] for field in self.unique_fields)
            if key in keys:
                duplicates.append(",".join(key))
            else:
                keys.add(key)

        if duplicates:
            raise forms.ValidationError(
                "Fields %s should be unique; found duplicates for %s" % (
                    ','.join(self.unique_fields), duplicates))
768283
private void cleanUp(final DataSet ds) {
		Set<String> indexedKeys = Sets.newHashSet();
		for (String key : ds.getDataView().keySet()) {
			// Search for indexed entries
			if (key.contains("#")) {
				// Remember key (without index)
				indexedKeys.add(key.substring(0, key.indexOf("#")));
			}
		}
		// Remove all indexes
		for (String indexedKey : indexedKeys) {
			ds.removeValue(indexedKey);
		}
	}
309379
function normalizeList(items) {
    if (!items) {
        return [];
    }
    var list;
    if (Array.isArray(items)) {
        list = [].concat(items);
    } else if (typeof items === 'string') {
        list = items.split(/[\s,]+/g).filter(Boolean);
    } else {
        throw new Error('Invalid items: ' + items);
    }
    return list;
}
1171808
function (key, howMany) {
                    // first add in all the new items if we have any, this should serve to push key to the right
                    if (arguments.length > 2) {
                        var args = copyargs(arguments);
                        args[1] = 0; // howMany
                        this._list._spliceFromKey.apply(this._list, args);
                    }
                    // now we can remove anything that needs to be removed, since they are not necessarially contiguous
                    // in the underlying list we remove them one by one.
                    var result = [];
                    if (howMany) {
                        var keysToRemove = [];
                        var filteredKeys = this._filteredKeys;
                        var filteredKeyIndex = filteredKeys.indexOf(key);
                        for (var i = filteredKeyIndex, len = filteredKeys.length; i < len && (i - filteredKeyIndex) < howMany; i++) {
                            var key = filteredKeys[i];
                            keysToRemove.push(key);
                        }
                        var that = this;
                        keysToRemove.forEach(function (key) {
                            result.push(that._list._spliceFromKey(key, 1)[0]);
                        });
                    }
                    return result;
                }
965311
def _prune(current, keys):
    
    pruned_current = {k: current[k] for k in keys if k in current}
    pruned_children = list(
        filter(
            None, [_prune(c, keys) for c in current.get("IORegistryEntryChildren", [])]
        )
    )
    keep_current = any(k in current for k in keys) or pruned_children
    if keep_current:
        if pruned_children:
            pruned_current["IORegistryEntryChildren"] = pruned_children
        return pruned_current
    else:
        return {}
1142859
def filter_keys(cls, data):
        
        keys = list(data.keys())
        for pattern in cls.EXCLUDE_PATTERNS:
            for key in keys:
                if re.match(pattern, key):
                    keys.remove(key)
        return dict(filter(lambda x: x[0] in keys, data.items()))
974174
function removeKeyFromList(list, key, value) {
    for (var i = list.length - 1; i >= 0; i--) {
        if (list[i][key] == value) {
            return list.splice(i, 1); // remove from array
        }
    }
    return false;
}
990382
def clean(self, settings):
        
        return {k: v for k, v in settings.items() if k in DEFAULT_SETTINGS}
498155
function clean(type, options) {
  options = assign({}, defaults, options);
  if (type === 'dblclick') {
    options.detail = 2;
  }
  if (isString(options.key)) {
    options.key = keycode(options.key);
  }
  return options;
}
257042
function _cleanObject (memo, value, key) {
  if (_hasData(value)) {
    memo[key] = value._data.data;
  } else if (_.isArray(value)) {
    memo[key] = _.reduce(value, _cleanArray, []);
  } else {
    memo[key] = value;
  }
  return memo;
}