// ParseToRawMap takes the filename as a string and returns a RawMap.
186
func ParseToRawMap(fileName string) (cfg RawMap, err error) {
	var file *os.File

	cfg = make(RawMap, 0)
	file, err = os.Open(fileName)
	if err != nil {
		return
	}
	defer file.Close()
	scanner := bufio.NewScanner(file)

	var currentSection string
	for scanner.Scan() {
		line := scanner.Text()

		if commentLine.MatchString(line) {
			continue
		} else if blankLine.MatchString(line) {
			continue
		} else if configSection.MatchString(line) {
			section := configSection.ReplaceAllString(line, "$1")
			if !cfg.SectionInConfig(section) {
				cfg[section] = make(map[string]string, 0)
			}
			currentSection = section
		} else if configLine.MatchString(line) {
			regex := configLine
			if quotedConfigLine.MatchString(line) {
				regex = quotedConfigLine
			}
			if currentSection == "" {
				currentSection = defaultSection
				if !cfg.SectionInConfig(currentSection) {
					cfg[currentSection] = make(map[string]string, 0)
				}
			}
			key := regex.ReplaceAllString(line, "$1")
			val := regex.ReplaceAllString(line, "$2")
			cfg[currentSection][key] = val
		} else {
			err = fmt.Errorf("invalid config file")
			break
		}
	}
	return
}
778168
func tagsMapToRaw(m map[string]string) map[string]interface{} {
	raw := make(map[string]interface{})
	for k, v := range m {
		raw[k] = v
	}

	return raw
}
1148941
func (o *rawSet) RowsToMap(result *Params, keyCol, valueCol string) (int64, error) {
	return o.queryRowsTo(result, keyCol, valueCol)
}
962247
func (r *RawConfig) RawMap() map[string]interface{} {
	r.lock.Lock()
	defer r.lock.Unlock()

	m := make(map[string]interface{})
	for k, v := range r.Raw {
		m[k] = v
	}
	return m
}
586425
func (v *VersioningTestV2) GetNewmap() (o map[int32]int32) {
	if v != nil && v.Newmap != nil {
		return v.Newmap
	}

	return
}
1041528
func parseTagIntoMap(tag string) tagOptionsMap {
	optionsMap := make(tagOptionsMap)
	options := strings.Split(tag, ",")

	for i, option := range options {
		option = strings.TrimSpace(option)

		validationOptions := strings.Split(option, "~")
		if !isValidTag(validationOptions[0]) {
			continue
		}
		if len(validationOptions) == 2 {
			optionsMap[validationOptions[0]] = tagOption{validationOptions[0], validationOptions[1], i}
		} else {
			optionsMap[validationOptions[0]] = tagOption{validationOptions[0], "", i}
		}
	}
	return optionsMap
}
915623
func (reader *PluginConfigReader) GetStreamMap(key string, defaultValue string) map[MessageStreamID]string {
	value, err := reader.WithError.GetStreamMap(key, defaultValue)
	reader.Errors.Push(err)
	return value
}
575730
func ParseMapFromAnnotations(annotations map[string]string) (*Map, error) {
	uuidMap := make(map[string]*Lease)
	nameMap := make(map[string]uuid.UUID)
	for uuidStr, leaseStr := range annotations {
		// try to parse the UUID and the lease, but skip if the annotation has a malformed UUID or
		// lease. This is to work in clusters that have other annotations
		u := uuid.Parse(uuidStr)
		if u == nil {
			continue
		}
		lease, err := ParseLease(leaseStr)
		if err != nil {
			continue
		}
		uuidMap[u.String()] = lease
		nameMap[lease.ClusterName] = u
	}
	return &Map{uuidMap: uuidMap, nameMap: nameMap}, nil
}
1330761
func ParseOrderedMap(data string) ([]string, []string, error) {
	parts := strings.Split(data, MapSeparator)
	keys := make([]string, len(parts))
	values := make([]string, len(parts))
	for i, part := range parts {
		split := strings.SplitN(part, MapEquals, 2)
		if len(split) != 2 {
			return nil, nil, fmt.Errorf("Failed to parse map (key-value pair %v does not contain separator '%v'): %v", i+1, MapEquals, part)
		}
		keys[i] = split[0]
		values[i] = split[1]
	}
	return keys, values, nil
}
1289984
func FindInMap(mapName string, topLevelKey Stringable, secondLevelKey Stringable) *StringExpr {
	return FindInMapFunc{
		MapName:        mapName,
		TopLevelKey:    *topLevelKey.String(),
		SecondLevelKey: *secondLevelKey.String(),
	}.String()
}
639068
func parseMap(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
	if r.IsNil() {
		r.Set(reflect.MakeMap(r.Type()))
	}

	if tag.Get("flattened") == "" { // look at all child entries
		for _, entry := range node.Children["entry"] {
			parseMapEntry(r, entry, tag)
		}
	} else { // this element is itself an entry
		parseMapEntry(r, node, tag)
	}

	return nil
}
434736
func (g *Grok) ParseToMultiMap(pattern, text string) (map[string][]string, error) {
	gr, err := g.compile(pattern)
	if err != nil {
		return nil, err
	}

	captures := make(map[string][]string)
	if match := gr.regexp.FindStringSubmatch(text); len(match) > 0 {
		for i, name := range gr.regexp.SubexpNames() {
			if name != "" {
				if g.config.RemoveEmptyValues == true && match[i] == "" {
					continue
				}
				name = g.nameToAlias(name)
				captures[name] = append(captures[name], match[i])
			}
		}
	}

	return captures, nil
}
157220
func (f *File) SetMapFlat(values map[string]string) {
	for key, value := range values {
		f.SetKey(key, value)
	}
}
163659
func WmColormapWindowsSet(xu *xgbutil.XUtil, win xproto.Window,
	windows []xproto.Window) error {

	return xprop.ChangeProp32(xu, win, "WM_COLORMAP_WINDOWS", "WINDOW",
		xprop.WindowToInt(windows)...)
}
479921
func parseAnnotationsString(a map[string]string, key string, def string) string {
	if v, ok := a[key]; ok {
		return v
	}
	return def
}
1044900
func (opts *Options) valuesMap(m map[string]interface{}) (map[string]interface{}, error) {
	for _, skv := range opts.Values {
		if err := strvals.ParseInto(skv, m); err != nil {
			return nil, err
		}
	}
	return m, nil
}
1058295
func parseMap(m Map) (map[int]interface{}, map[string]string) {
	var options = make(map[int]interface{})
	var headers = make(map[string]string)

	if m == nil {
		return options, headers
	}

	for k, v := range m {
		// integer is option
		if kInt, ok := k.(int); ok {
			// don't need to validate
			options[kInt] = v
		} else if kString, ok := k.(string); ok {
			kStringUpper := strings.ToUpper(kString)
			if kInt, ok := CONST[kStringUpper]; ok {
				options[kInt] = v
			} else {
				// it should be header, but we still need to validate it's type
				if vString, ok := v.(string); ok {
					headers[kString] = vString
				}
			}
		}
	}

	return options, headers
}