Inserts any necessary separators and whitespace before a name. Also
adjusts the stack to expect the key's value.
345432
private void beforeKey() throws JSONException {
        Scope context = peek();
        if (context == Scope.NONEMPTY_OBJECT) { // first in object
            out.append(',');
        } else if (context != Scope.EMPTY_OBJECT) { // not in an object!
            throw new JSONException("Nesting problem");
        }
        newline();
        replaceTop(Scope.DANGLING_KEY);
    }
876925
def leading_whitespace(self, inputstring):
        """"""
        count = 0
        for i, c in enumerate(inputstring):
            if c == " ":
                count += 1
            elif c == "\t":
                count += tabworth - (i % tabworth)
            else:
                break
            if self.indchar is None:
                self.indchar = c
            elif c != self.indchar:
                self.strict_err_or_warn("found mixing of tabs and spaces", inputstring, i)
        return count
236528
function insert(str, key, valu) {
    const re = new RegExp("\\$\\{" + key + "\\}", 'g');
    return str.replace(re, valu);
  }
333640
private <T> void appendNameList(StringBuffer sb,
                                    java.util.Set<T> resolutions,
                                    String sep) {
        for (T oneRes : resolutions) {
            sb.append(sep).append(oneRes.toString());
            sep = ", ";
        }
    }
1111125
def prettify(name, blank=" "):
    
    if name.startswith("."):  # remove starting
        name = name[1:]

    for bad_char in BAD_CHARS:
        name = name.replace(bad_char, blank)  # remove token

    name = String(name).remove_all(blank)

    for i in range(1, len(name) - 2):
        try:
            are_blanks = name[i - 1] == blank and name[i + 1] == blank
            if are_blanks and name[i] in BAD_CHARS:
                name = name[:i - 1] + name[i + 2:]
        except:  # out of bounds
            pass

    if name.startswith(blank):
        name = name[1:]

    if name.endswith(blank):  # remove ending replacement
        name = name[:-1]

    return name
124702
@Override
    public void appendNames(StringBuilder sb, String sep)
    {
        // Let's first get the alphabetized list of all names from main hash
        TreeSet<PrefixedName> ts = new TreeSet<PrefixedName>();
        for (int i = 0; i < mNames.length; ++i) {
            PrefixedName name = mNames[i];
            if (name != null) {
                ts.add(name);
            }
        }

        // then spill area
        if (mBuckets != null) {
            for (int i = 0; i < (mNames.length >> 2); ++i) {
                Bucket b = mBuckets[i];
                while (b != null) {
                    ts.add(b.getName());
                    b = b.getNext();
                }
            }
        }

        // And then append them:
        Iterator<PrefixedName> it = ts.iterator();
        boolean first = true;
        while (it.hasNext()) {
            if (first) {
                first = false;
            } else {
                sb.append(sep);
            }
            sb.append(it.next().toString());
        }
    }
1183065
def _prepend_name(self, prefix, dict_):
        ''''''
        return dict(['.'.join([prefix, name]), msg]
                    for name, msg in dict_.iteritems())
217697
private void beforeName() throws IOException {
    int context = peekScope();
    if (context == NONEMPTY_OBJECT) { // first in object
      sink.writeByte(',');
    } else if (context != EMPTY_OBJECT) { // not in an object!
      throw new IllegalStateException("Nesting problem.");
    }
    newline();
    replaceTop(DANGLING_NAME);
  }
868415
public CommandOption<T> setting(String name) {

		Assert.notNullOrEmptyTrimmed(name, "Missing setting name");

		name = StringUtils.trim(name);
		String compare = StringUtils.sanitizeWhitespace(name);
		Assert.isTrue(name.equals(compare), "Setting name can not contain whitespace characters!");

		setting = name;
		return this;
	}
1359031
def join_name(parts,
                  separator: ObjectInspector.configuration.name_separator)
      the_parts = Array(parts).tap(&:compact!)
      the_parts.join(separator) if the_parts.any?
    end
494103
def process_pair(self, key, value):
        

        old_key = key
        old_value = value

        # Create key intelligently
        keyparts = self.bspacere.split(key)
        # print keyparts

        strippable = False
        lastpart = keyparts[-1]

        if lastpart.find('\\ ') != -1:
            keyparts[-1] = lastpart.replace('\\','')

        # If no backspace is found at the end, but empty
        # space is found, strip it
        elif lastpart and lastpart[-1] == ' ':
            strippable = True

        key = ''.join(keyparts)
        if strippable:
            key = key.strip()
            old_key = old_key.strip()

        old_value = self.unescape(old_value)
        value = self.unescape(value)

        # Patch from N B @ ActiveState
        curlies = re.compile(r'\$?\{.+?\}')
        found_variables = curlies.findall(value)

        for found_variable in found_variables:
            if found_variable.startswith('$'):
                source_key = found_variable[2:-1]
            else:
                source_key = found_variable[1:-1]

            if source_key in self._properties:
                value = value.replace(found_variable, self._properties[source_key], 1)

        self._properties[key] = value.strip()

        # Check if an entry exists in pristine keys
        if key in self._keymap:
            old_key = self._keymap.get(key)
            self._origprops[old_key] = old_value.strip()
        else:
            self._origprops[old_key] = old_value.strip()
            # Store entry in keymap
            self._keymap[key] = old_key

        if key not in self._keyorder:
            self._keyorder.append(key)
748742
def raise_for_missing_name(self, line: str, position: int, namespace: str, name: str) -> None:
        """"""
        self.raise_for_missing_namespace(line, position, namespace, name)

        if self.has_enumerated_namespace(namespace) and not self.has_enumerated_namespace_name(namespace, name):
            raise MissingNamespaceNameWarning(self.get_line_number(), line, position, namespace, name)

        if self.has_regex_namespace(namespace) and not self.has_regex_namespace_name(namespace, name):
            raise MissingNamespaceRegexWarning(self.get_line_number(), line, position, namespace, name)
1056520
def _set_name(self, name):
        
        if self._is_identifier_quoted(name):
            self._quoted = True
            name = self._trim_quotes(name)

        if "." in name:
            parts = name.split(".", 1)
            self._namespace = parts[0]
            name = parts[1]

        self._name = name
1180510
private static String key(String name) {
        return WHITE_SPACE.matcher(name).replaceAll(".").toLowerCase(Locale.ENGLISH);
    }
886036
def insert_before(self, key, new_item, instance=0):
        """"""
        self._insert_item(key, new_item, instance, False)
1238941
private void addCharPreds(String key, char c, List<String> preds) {
    preds.add(key + "=" + c);
    if (Character.isLetter(c)) {
      preds.add(key + "_alpha");
      if (Character.isUpperCase(c)) {
        preds.add(key + "_caps");
      }
    } else if (Character.isDigit(c)) {
      preds.add(key + "_num");
    } else if (StringUtil.isWhitespace(c)) {
      preds.add(key + "_ws");
    } else {
      if (c == '.' || c == '?' || c == '!') {
        preds.add(key + "_eos");
      } else if (c == ',' || c == ';' || c == ':') {
        preds.add(key + "_reos");
      } else if (c == '`' || c == '"' || c == '\'') {
        preds.add(key + "_quote");
      } else if (c == '[' || c == '{' || c == '(') {
        preds.add(key + "_lp");
      } else if (c == ']' || c == '}' || c == ')') {
        preds.add(key + "_rp");
      }
    }
  }
204507
def prepend(self, key, value, cas=0, format=None,
                persist_to=0, replicate_to=0):
        
        return _Base.prepend(self, key, value, cas=cas, format=format,
                             persist_to=persist_to, replicate_to=replicate_to)