def _update_settings(self, new_settings, enforce_helpstring=True):
for raw_setting_name, value in six.iteritems(new_settings):<EOL><INDENT>setting_name = raw_setting_name.replace("<STR_LIT:_>", "<STR_LIT:->")<EOL>setting_already_exists = setting_name in self._instance_settings<EOL>value_is_list_len_2 = isinstance(value, list) and len(value) == <NUM_LIT:2><EOL>treat_as_tuple = not setting_already_exists and value_is_list_len_2<EOL>if isinstance(value, tuple) or treat_as_tuple:<EOL><INDENT>self._instance_settings[setting_name] = value<EOL><DEDENT>else:<EOL><INDENT>if setting_name not in self._instance_settings:<EOL><INDENT>if enforce_helpstring:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise InternalCashewException(msg % setting_name)<EOL><DEDENT>else:<EOL><INDENT>self._instance_settings[setting_name] = ('<STR_LIT>', value,)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>orig = self._instance_settings[setting_name]<EOL>self._instance_settings[setting_name] = (orig[<NUM_LIT:0>], value,)<EOL><DEDENT><DEDENT><DEDENT>
This method does the work of updating settings. Can be passed with
enforce_helpstring = False which you may want if allowing end users to
add arbitrary metadata via the settings system.

Preferable to use update_settings (without leading _) in code to do the
right thing and always have docstrings.