Parse out a hash from a list of key=value strings
12156
def cli_hash(list_of_kv):
    """"""
    ev_obj = {}
    for extra_var in list_of_kv:
        ev_list = extra_var.split('=')
        key = ev_list[0]
        val = '='.join(ev_list[1:])  # b64 and other side effects
        ev_obj[key] = val

    return ev_obj
783737
def to_s
      arr = []
      if freq = @hash.delete('FREQ')
        arr << "FREQ=#{freq.join(',')}"
      end
      arr.concat(@hash.map do |key, value|
        if value.is_a?(Array)
          "#{key}=#{value.join(',')}"
        end
      end.compact)
      arr.join(';')
    end
355910
def process_hash_row(hsh)
      if @headers.any?
        keys_or_values = hsh.values
        @row_id = hsh[:row_id]
      else
        keys_or_values = hsh.keys.map(&:to_s)
      end

      file_line = keys_or_values.join(',')
      validated_line = utf_filter(check_utf(file_line))
      res = line_parse(validated_line)
      res
    end
1103106
def stringify_keys(object)
      case object
      when Hash
        object.each_with_object({}) do |(key, value), result|
          result[key.to_s] = stringify_keys(value)
        end
      when Array
        object.map { |e| stringify_keys(e) }
      else
        object
      end
    end
1346454
def recursive_to_hash(*values)
      if values.size == 1
        value = values.first
        case value
        when String, Numeric, Symbol, TrueClass, FalseClass, NilClass, Time
          value
        when Hash
          value.inject({}) { |h, (k, v)| h.update k => recursive_to_hash(v) }
        when Array
          value.map { |v| recursive_to_hash v }
        else
          value.to_hash
        end
      else
        values.all? { |v| Type! v, Hash, NilClass }
        recursive_to_hash(values.compact.reduce { |h, v| h.merge v })
      end
    end
681837
def to_hash
      result = {}
      @lines.entries.each do |section|
        result[section.key] ||= {}
        section.entries.each do |option|
          opts = Array(option)
          val = opts.map { |o| o.respond_to?(:value) ? o.value : o }
          val = val.size > 1 ? val : val.first
          result[section.key][opts.first.key] = val
        end
      end
      result
    end
167512
def parse_links(json)
      links = json[:links] || json[:link] || json['links'] || json['link']
      return [] if links.nil?

      links = [links] unless links.is_a?(Array)
      links.map do |link|
        if (link[:href].nil? && link['href'].nil?) || (link[:rel].nil? && link['rel'].nil?)
          msg = "Invalid hash link: #{link.inspect}"
          raise(RuntimeError, msg, caller)
        end
        EntryPoint.new(link[:href] || link['href'], link[:rel] || link['rel'])
      end
    end
811020
def get_hash(node,fields = None,exclude = ['pk','_id'],target = 'pk'):
    

    hasher = Hasher()

    def add_to_hash(value):

        if isinstance(value,dict):
            if target in value:
                add_to_hash(value[target])
            else:
                attribute_list = []
                for key,v in sorted(value.items(),key = lambda x: x[0]):

                    if (fields is not None and key not in fields) \
                        or (exclude is not None and key in exclude):
                        continue
                    add_to_hash(key)
                    add_to_hash(v)
        elif isinstance(value,(tuple,list)) and value and isinstance(value[0],(dict,node_class)):
            for i,v in enumerate(value):
                hasher.add(i)
                add_to_hash(v)
        else:
            hasher.add(value)

    add_to_hash(node)

    return hasher.digest.hexdigest()
119259
def to_hash arr
      return {}   if arr.nil?
      return arr  if arr.kind_of?(Hash)
      arr = [ arr.to_sym ]  unless arr.kind_of?(Array)
      ret = {}
      arr.each { |key| ret[key.to_sym] = {} }
      ret
    end
664583
def to_hash
      result = {}

      @values.keys.each do |field_name|
        value = __send__(field_name)
        hashed_value = value.respond_to?(:to_hash_value) ? value.to_hash_value : value
        result.merge!(field_name => hashed_value)
      end

      result
    end
125047
def to_hash
      Hash[options.reject(&:null?).map { |o| [o.key, o.value] }]
    end
397313
def hmget(self, name, keys, *args):
        
        member_encode = self.memberparse.encode
        keys = [k for k in self._parse_values(keys, args)]
        with self.pipe as pipe:
            f = Future()
            res = pipe.hmget(self.redis_key(name),
                             [member_encode(k) for k in keys])

            def cb():
                f.set([self._value_decode(keys[i], v)
                       for i, v in enumerate(res.result)])

            pipe.on_execute(cb)
            return f
906619
def pluralized_array_from_hash(hash, singular_key, plural_key)
      [].tap do |array|
        value = value_from_singular_key(hash, singular_key)
        value ||= value_from_plural_key(hash, plural_key)
        array << value
      end.flatten.compact
    end
924480
def string_to_hash(markup)
      options = {}

      if match = markup.match(Syntax)
        markup.scan(TagAttributes) do |key, value|
          options[key.to_sym] = value.gsub(/\A"|"\z/, "")
        end
      end

      options
    end
259005
function stringToHash(hashAsString) {
        var entries = {};
        if (hashAsString) {
            var text = decodeURI(hashAsString);
            var items = text.split('&');
            angular.forEach(items, function (item) {
                var kv = item.split('=');
                var key = kv[0];
                var value = kv[1] || key;
                entries[key] = value;
            });
        }
        return entries;
    }
38937
def hash(mapping, bind, values):
    
    for v in values:
        if v is None:
            continue
        if not isinstance(v, six.string_types):
            v = six.text_type(v)
        yield sha1(v.encode('utf-8')).hexdigest()
386582
def extract(hash, *args)
      begin
        tmp = hash
        args.each do |arg|
          tmp = tmp[arg]
        end
        tmp
      rescue
        nil
      end
    end