split key to elements
183560
def key2elements(key):
    """"""
    # words = key.split('.')
    # if len(words) == 4:
    #     return words
    # # there is a dot in object name
    # fieldword = words.pop(-1)
    # nameword = '.'.join(words[-2:])
    # if nameword[-1] in ('"', "'"):
    #     # The object name is in quotes
    #     nameword = nameword[1:-1]
    # elements = words[:-2] + [nameword, fieldword, ]
    # return elements
    words = key.split('.')
    first2words = words[:2]
    lastword = words[-1]
    namewords = words[2:-1]
    namephrase = '.'.join(namewords)
    if namephrase.startswith("'") and namephrase.endswith("'"):
        namephrase = namephrase[1:-1]
    return first2words + [namephrase] + [lastword]
772717
private Iterable<Key> getSplitKey(List<Key> keys, int numSplits) {
    // If the number of keys is less than the number of splits, we are limited in the number of
    // splits we can make.
    if (keys.size() < numSplits - 1) {
      return keys;
    }

    // Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may
    // be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities.
    //
    // Consider the following dataset, where - represents an entity and * represents an entity
    // that is returned as a scatter entity:
    // ||---*-----*----*-----*-----*------*----*----||
    // If we want 4 splits in this data, the optimal split would look like:
    // ||---*-----*----*-----*-----*------*----*----||
    //            |          |            |
    // The scatter keys in the last region are not useful to us, so we never request them:
    // ||---*-----*----*-----*-----*------*---------||
    //            |          |            |
    // With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5.
    //
    // We keep this as a double so that any "fractional" keys per split get distributed throughout
    // the splits and don't make the last split significantly larger than the rest.
    double numKeysPerSplit = Math.max(1.0, ((double) keys.size()) / (numSplits - 1));

    List<Key> keysList = new ArrayList<Key>(numSplits - 1);
    // Grab the last sample for each split, otherwise the first split will be too small.
    for (int i = 1; i < numSplits; i++) {
      int splitIndex = (int) Math.round(i * numKeysPerSplit) - 1;
      keysList.add(keys.get(splitIndex));
    }

    return keysList;
  }
543448
def _split_index(params):
    
    result = {}
    for key in params:
        if isinstance(params[key], dict):
            value = params[key]['_value']
        else:
            value = params[key]
        result[key] = value
    return result
1040474
def split_data(data, subset, splits):
  '''
  '''

  return dict([(k, data[k][splits[subset]]) for k in data])
538490
private Object getValue(String key) {

        // iterate over configuration tree
        String[] splittedKeys = key.split("\\.");
        Object value = config;

        for (int i = 0; i < splittedKeys.length; i++) {

            String splittedKey = splittedKeys[i];

            if (value == null) {
                return null;
            }

            // parse arrays
            if (representsArray(splittedKey)) {

                // value array support
                int arrayIndex;
                int openingBracket = splittedKey.indexOf("[");
                int closingBracket = splittedKey.indexOf("]");

                try {
                    arrayIndex = Integer.parseInt(splittedKey.substring(openingBracket + 1, closingBracket));
                } catch (NumberFormatException e) {

                    if (log != null) {
                        log.severe("Cannot cast array index.");
                    }

                    return null;
                }

                splittedKey = splittedKey.substring(0, openingBracket);

                if (value instanceof Map) {
                    value = ((Map) value).get(splittedKey);
                } else {
                    return null;
                }

                if (value instanceof List) {
                    value = (arrayIndex < ((List) value).size()) ? ((List) value).get(arrayIndex) : null;
                }

            } else {
                if (value instanceof Map) {

                    Object tmpValue = ((Map) value).get(splittedKey);

                    if (tmpValue == null && i != splittedKeys.length - 1) {

                        String postfixKey = Arrays.stream(splittedKeys).skip(i)
                                .collect(Collectors.joining("."));

                        return ((Map) value).get(postfixKey);
                    } else {

                        value = tmpValue;
                    }
                } else {
                    return null;
                }
            }
        }

        return value;
    }
156152
def transform(data, keysToSplit=[]):
    
    transformed = { }
    for key in data:
        if key in keysToSplit:
            transformed[key] = data[key]['value'].split(SEPARATOR)
        else:
            transformed[key] = data[key]['value']
    return transformed
1363021
def _pairs(keys, *, start=1, sep=' AND '):
    '''
    
    '''
    return sep.join('{}=${}'.format(k, i) for i, k in enumerate(keys, start))
695277
public static TransposePathElement parse( String key ) {

        if ( key == null || key.length() < 2 ) {
            throw new SpecException( "'Transpose Input' key '@', can not be null or of length 1.  Offending key : " + key );
        }
        if ( '@' != key.charAt( 0 ) ) {
            throw new SpecException( "'Transpose Input' key must start with an '@'.  Offending key : " + key );
        }

        // Strip off the leading '@' as we don't need it anymore.
        String meat = key.substring( 1 );

        if ( meat.contains( "@" ) ) {
            throw new SpecException( "@ pathElement can not contain a nested @. Was: " + meat );
        }
        if ( meat.contains( "*" ) || meat.contains( "[]" ) ) {
            throw new SpecException( "'Transpose Input' can not contain expansion wildcards (* and []).  Offending key : " + key );
        }

        // Check to see if the key is wrapped by parens
        if ( meat.startsWith( "(" ) ) {
            if ( meat.endsWith( ")" ) ) {
                meat = meat.substring( 1, meat.length() - 1 );
            }
            else {
                throw new SpecException( "@ path element that starts with '(' must have a matching ')'.  Offending key : " + key );
            }
        }

        return innerParse( key, meat );
    }
223998
function(attr, keepKey) {
                        //Keep key intact
                        if (keepKey) {
                            return [attr];
                        }
                        // Split key on '.'
                        return can.isArray(attr) ? attr : ("" + attr)
                            .split(".");
                    }
300858
def _split_header(header):
        """"""
        params = {}
        parts = header.split(',')
        for param in parts:
            # Ignore realm parameter.
            if param.lower().startswith('realm='):
                continue
            # Remove whitespace.
            param = param.strip()
            # Split key-value.
            param_parts = param.split('=', 1)
            # Remove quotes and unescape the value.
            params[param_parts[0]] = unquote(param_parts[1].strip('\"'))
        return params
526126
def split_elements(value):
    """"""
    l = [v.strip() for v in value.split(',')]
    if len(l) == 1:
        l = value.split()
    return l
398959
function SplitIndex(s) {
        var spl = s.split(spDelim);
        this.id = spl[0];
        this.value = spl[1];
    }
795187
def split(s):
  """"""
  l = [_split(x) for x in _SPLIT_RE.split(s)]
  return [item for sublist in l for item in sublist]
696498
function splitLastKey (path) {
  let pathArr = path.split('.')
  if (pathArr.length >= 2) {
    let patentObjectPath = pathArr.splice(0, pathArr.length - 1) || []// pathArr -> key
    return [pathArr, patentObjectPath.join('.')]
  } else {
    return [pathArr]
  }
}
397442
function getKeys(key) {
    var keys;
    key = key.replace(/\s/g, '');
    keys = key.split(',');
    if ((keys[keys.length - 1]) == '') {
      keys[keys.length - 2] += ',';
    }
    return keys;
  }
448525
def key_parts(key, &block)
      return enum_for(:key_parts, key) unless block
      nesting = PARENS
      counts  = PARENS_ZEROS # dup'd later if key contains parenthesis
      delim   = '.'
      from    = to = 0
      key.each_char do |char|
        if char == delim && PARENS_ZEROS == counts
          block.yield key[from...to]
          from = to = (to + 1)
        else
          nest_i, nest_inc = nesting[char]
          if nest_i
            counts = counts.dup if counts.frozen?
            counts[nest_i] += nest_inc
          end
          to += 1
        end
      end
      block.yield(key[from...to]) if from < to && to <= key.length
      true
    end
1085211
def _parse_key(key):
    '''
    
    '''
    splt = key.split("\\")
    hive = splt.pop(0)
    key = '\\'.join(splt)
    return hive, key