Handle comma-separated key/values passed in command-line.
18058
def comma_separated_pairs(value):
    """"""
    pairs = value.split(",")
    results = {}
    for pair in pairs:
        key, pair_value = pair.split('=')
        results[key] = pair_value
    return results
43872
def clean_key(cls, key):
        
        for var_re in cls.VARIABLE_RES:
            key = var_re.sub('#', key)
        return key
1305560
def translate_key_val(val, delimiter='='):
    '''
    
    '''
    if isinstance(val, dict):
        return val
    val = translate_stringlist(val)
    new_val = {}
    for item in val:
        try:
            lvalue, rvalue = split(item, delimiter, 1)
        except (AttributeError, TypeError, ValueError):
            raise SaltInvocationError(
                '\'{0}\' is not a key{1}value pair'.format(item, delimiter)
            )
        new_val[lvalue] = rvalue
    return new_val
1263938
def force_ascii_values(data):
    """"""
    return {
        k: v.encode('utf8').decode('ascii', 'backslashreplace')
        for k, v in data.items()
    }
74551
def lpush(self, key, value, *values):
        
        return self.execute(b'LPUSH', key, value, *values)
533617
def process_regex(self, key):
        
        return re.compile(self.output_dict[key]) if \
            key in self.output_dict else None
936534
def _process_arguments(arguments):
    ''' 

    '''
    if arguments is None: return ""
    result = ""
    for key, value in arguments.items():
        if not key.startswith("bokeh-"):
            result += "&{}={}".format(quote_plus(str(key)), quote_plus(str(value)))
    return result
224835
def format_kwarg(key, value):
    
    translator = repr if isinstance(value, six.string_types) else six.text_type
    arg_value = translator(value)

    return '{0}={1}'.format(key, arg_value)
1262177
def _parse(args):
    """"""

    ordered = []
    opt_full = dict()
    opt_abbrev = dict()

    args = args + ['']  # Avoid out of range
    i = 0

    while i < len(args) - 1:
        arg = args[i]
        arg_next = args[i+1]
        if arg.startswith('--'):
            if arg_next.startswith('-'):
                raise ValueError('{} lacks value'.format(arg))
            else:
                opt_full[arg[2:]] = arg_next
                i += 2
        elif arg.startswith('-'):
            if arg_next.startswith('-'):
                raise ValueError('{} lacks value'.format(arg))
            else:
                opt_abbrev[arg[1:]] = arg_next
                i += 2
        else:
            ordered.append(arg)
            i += 1
    
    return ordered, opt_full, opt_abbrev
709278
def _handle_special_yaml_cases(v):
    
    if "::" in v:
        out = {}
        for part in v.split("::"):
            k_part, v_part = part.split(":")
            out[k_part] = v_part.split(";")
        v = out
    elif ";" in v:
        # split lists and remove accidental empty values
        v = [x for x in v.split(";") if x != ""]
    elif isinstance(v, list):
        v = v
    else:
        try:
            v = int(v)
        except ValueError:
            if v.lower() == "true":
                v = True
            elif v.lower() == "false":
                    v = False
    return v
1135836
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken,
            knowledge_base):
    """"""
    _ = stderr, time_taken, args, knowledge_base  # Unused.
    self.CheckReturn(cmd, return_val)
    result = rdf_protodict.AttributedDict()
    # The KeyValueParser generates an ordered dict by default. The sysctl vals
    # aren't ordering dependent, but there's no need to un-order it.
    for k, v in iteritems(self.lexer.ParseToOrderedDict(stdout)):
      key = k.replace(".", "_")
      if len(v) == 1:
        v = v[0]
      result[key] = v
    return [result]
814773
def handle_command_line():
    """"""
    phrase = ' '.join(sys.argv[1:]) or 'random'

    try:
        giphy = get_random_giphy(phrase)
    except ValueError:
        sys.stderr.write('Unable to find any GIFs for {!r}\n'.format(phrase))
        sys.exit(1)

    display(fetch_image(giphy))
577015
def _parse_output_keys(val):
    
    out = {}
    for k in val.split(","):
        # record output
        if ":" in k:
            name, attrs = k.split(":")
            out[name] = attrs.split(";")
        else:
            out[k] = None
    return out
1294809
function parseNameVal(cmd) {
    // This is kind of tricky because we need to support the old
    // variant:   KEY name value
    // as well as the new one:    KEY name=value ...
    // The trigger to know which one is being used will be whether we hit
    // a space or = first.  space ==> old, "=" ==> new
    var word;
    var words = parseWords(cmd.rest);

    cmd.args = {};

    if (words.length === 0) {
        cmd.error = 'No KEY name value, or KEY name=value arguments found';
        return false;
    }

    if (words[0].indexOf('=') == -1) {
        // Old format (KEY name value)
        var strs = cmd.rest.split(TOKEN_WHITESPACE);
        if (strs.length < 2) {
            cmd.error = cmd.name + ' must have two arguments, got ' + cmd.rest;
            return false;
        }

        // Convert to new style key:value map.
        cmd.args[strs[0]] = strs.slice(1).join(' ');

    } else {
        // New format (KEY name=value ...)
        var i;
        for (i = 0; i < words.length; i++) {
            word = words[i];
            if (word.indexOf('=') == -1) {
                cmd.error = 'Syntax error - can\'t find = in ' + word + '. Must be of the form: name=value';
                return false;
            }
            var parts = word.split('=');
            cmd.args[parts[0]] = parts.slice(1).join('=');
        }
    }

    return true;
}
1168190
def pretty_format_args(*args, **kwargs):
    
    args = list([repr(a) for a in args])
    for key, value in kwargs.items():
        args.append("%s=%s" % (key, repr(value)))
    return "(%s)" % ", ".join([a for a in args])
1274813
def cli(obj):
    """"""
    for k, v in obj.items():
        if isinstance(v, list):
            v = ', '.join(v)
        click.echo('{:20}: {}'.format(k, v))
396530
def kwarg(string, separator='='):
    """"""
    if separator not in string:
        raise ValueError("Separator '%s' not in value '%s'"
                         % (separator, string))
    if string.strip().startswith(separator):
        raise ValueError("Value '%s' starts with separator '%s'"
                         % (string, separator))
    if string.strip().endswith(separator):
        raise ValueError("Value '%s' ends with separator '%s'"
                         % (string, separator))
    if string.count(separator) != 1:
        raise ValueError("Value '%s' should only have one '%s' separator"
                         % (string, separator))
    key, value = string.split(separator)
    return {key: value}