Ensure configuration keys are not incorrectly nested under other keys.
194858
def _check_for_misplaced(xs, subkey, other_keys):
    
    problems = []
    for x in xs:
        check_dict = x.get(subkey, {})
        for to_check in other_keys:
            if to_check in check_dict:
                problems.append((x["description"], to_check, subkey))
    if len(problems) > 0:
        raise ValueError("\n".join(["Incorrectly nested keys found in sample YAML. These should be top level:",
                                    " sample         |   key name      |   nested under ",
                                    "----------------+-----------------+----------------"] +
                                   ["% 15s | % 15s | % 15s" % (a, b, c) for (a, b, c) in problems]))
1116486
def set_if_none(user_config, config, key, value):
    '''
    
    '''

    keys = key.split('.')
    for k in keys[:-1]:
        try:
            user_config = user_config[k]
        except KeyError:
            user_config = {}

        config = config[k]

    key = keys[-1]

    if key not in user_config and not config[key]:
        config[key] = value
655989
def check_config(config):
    
    for section, expected_section_keys in SECTION_KEYS.items():
        section_content = config.get(section)
        if not section_content:
            raise ConfigurationError("Config file badly formed! Section {} is missing."
                                     .format(section))
        elif not _section_is_healthy(section_content, expected_section_keys):
            raise ConfigurationError("The {} section of the configuration file is badly formed!"
                                     .format(section))
218402
function checkKeyCodes (
  eventKeyCode,
  key,
  builtInKeyCode,
  eventKeyName,
  builtInKeyName
) {
  const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
    return isKeyNotMatch(builtInKeyName, eventKeyName)
  } else if (mappedKeyCode) {
    return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  } else if (eventKeyName) {
    return hyphenate(eventKeyName) !== key
  }
}
460606
protected void ensureColKey(E key) {
		if (!colKeys.containsKey(key)) {
			colKeys.put(key, colKeys.size());
			addCol();
		}
	}
31856
def custom_conf(self, conf):
        ''''''
        if conf:
            for (key, val) in conf.items():
                self.__conf[key] = val
        return self
603573
public static void arrangeKeys(ArrayList<String> keys) {
    move(keys, "timestamp", 0);
    move(keys, "hostname", 1);
    move(keys, "type", 2);
  }
104378
def _trim_config(self, b_config, mod, key):
        '''
        
        '''
        if isinstance(b_config[mod], list):
            self._remove_list_item(b_config[mod], key)
        elif isinstance(b_config[mod], dict):
            b_config[mod].pop(key)
        return b_config
921578
def _validate_other_keys(optional, types, missing, validated, data,
                         to_validate):
    """"""
    errors = []
    for key in to_validate:
        value = data[key]
        if key in optional:
            errors.extend(
                _validate_optional_key(
                    key, missing, value, validated, optional))
            continue
        errors.extend(_validate_type_key(key, value, types, validated))
    return errors
845060
def _check_key(self, key):
        
        self.setup_schema()
        if key not in self._attrs and key not in self:
            raise KeyError(key)
624555
def reorder_keys(self, keys):
        ''''''
        if len(keys) != len(self._keys):
            raise ValueError('The supplied number of keys does not match.')
        if set(keys) != set(self._d.keys()):
            raise ValueError('The supplied keys do not match the current set of keys.')
        self._keys = keys
761903
def check_config(config):
    ""
    shortnames = [count['shortname'] for count in config['count']]
    if len(shortnames) != len(set(shortnames)):
        logger.error("error: duplicate `shortname' in count configuration.")
        return False
    return True
118128
def _normalize_compare_config(self, diff):
        """"""
        ignore_strings = [
            "Contextual Config Diffs",
            "No changes were found",
            "ntp clock-period",
        ]
        if self.auto_file_prompt:
            ignore_strings.append("file prompt quiet")

        new_list = []
        for line in diff.splitlines():
            for ignore in ignore_strings:
                if ignore in line:
                    break
            else:  # nobreak
                new_list.append(line)
        return "\n".join(new_list)
994257
def keys(cls, section=None):
        """"""
        section = section or cls._default_sect
        if section not in cls._conf:
            cls._load(section=section)
        return cls._conf[section].keys()
1337979
def _BuildKeyHierarchy(self, subkeys, values):
    
    if subkeys:
      for registry_key in subkeys:
        name = registry_key.name.upper()
        if name in self._subkeys:
          continue
        self._subkeys[name] = registry_key

        # pylint: disable=protected-access
        registry_key._key_path = key_paths.JoinKeyPath([
            self._key_path, registry_key.name])

    if values:
      for registry_value in values:
        name = registry_value.name.upper()
        if name in self._values:
          continue
        self._values[name] = registry_value
794617
def validate_sectionless_conf(self, file_contents, expected):
        """"""
        for line in file_contents.split('\n'):
            if '=' in line:
                args = line.split('=')
                if len(args) <= 1:
                    continue
                key = args[0].strip()
                value = args[1].strip()
                if key in expected.keys():
                    if expected[key] != value:
                        msg = ('Config mismatch.  Expected, actual:  {}, '
                               '{}'.format(expected[key], value))
                        amulet.raise_status(amulet.FAIL, msg=msg)
1349660
def create(key_name: str, sections: List[str]): # -> NoParserFoundForObject:
        
        return MultipleKeyOccurenceInConfigurationError('Cannot read the provided config file as a flat dictionary : '
                                                        'key \'' + key_name + '\' appears several times, in sections'
                                                                              '\'' + str(sections) + '\'.')