// Expand expands a string and ignores any errors that occur - keys that are
// not recognized are replaced with the empty string.
190834
func Expand(s string, fns ...KeyFunc) string {
	val, _ := ExpandStrict(s, append(fns, Empty)...)
	return val
}
403381
func expandInputs(inputs ...Input) [][]Input {
	// first pass to determine how large each array needs to be
	// this could probably be more efficient
	sz := 0
	for _, in := range inputs {
		if multi, isMulti := in.(MultiInput); isMulti {
			ins := multi.InputArray()
			l := len(ins)
			if l > sz {
				sz = l
			}
		}
	}
	if sz == 0 {
		// none were multi-channel inputs
		return [][]Input{inputs}
	}
	var (
		arr = make([][]Input, sz)
		n   = len(inputs)
	)
	for i := range arr {
		arr[i] = make([]Input, n)

		for j := range arr[i] {
			in := inputs[j]

			if multi, isMulti := in.(MultiInput); isMulti {
				ins := multi.InputArray()
				arr[i][j] = ins[i%len(ins)]
			} else {
				arr[i][j] = in
			}
		}
	}

	return arr
}
212246
func (c *ArgCommand) Expand(expander SingleWordExpander) error {
	p, err := expander(c.Key)
	if err != nil {
		return err
	}
	c.Key = p
	if c.Value != nil {
		p, err = expander(*c.Value)
		if err != nil {
			return err
		}
		c.Value = &p
	}
	return nil
}
1186650
func ExpandSlice(slice string) (string, error) {
	suffix := ".slice"
	// Name has to end with ".slice", but can't be just ".slice".
	if len(slice) < len(suffix) || !strings.HasSuffix(slice, suffix) {
		return "", fmt.Errorf("invalid slice name: %s", slice)
	}

	// Path-separators are not allowed.
	if strings.Contains(slice, "/") {
		return "", fmt.Errorf("invalid slice name: %s", slice)
	}

	var path, prefix string
	sliceName := strings.TrimSuffix(slice, suffix)
	// if input was -.slice, we should just return root now
	if sliceName == "-" {
		return "/", nil
	}
	for _, component := range strings.Split(sliceName, "-") {
		// test--a.slice isn't permitted, nor is -test.slice.
		if component == "" {
			return "", fmt.Errorf("invalid slice name: %s", slice)
		}

		// Append the component to the path and to the prefix.
		path += "/" + prefix + component + suffix
		prefix += component + "-"
	}
	return path, nil
}
278501
func Expand(dir string, r io.Reader) error {
	files, err := loadArchiveFiles(r)
	if err != nil {
		return err
	}

	// Get the name of the chart
	var chartName string
	for _, file := range files {
		if file.Name == "Chart.yaml" {
			ch, err := UnmarshalChartfile(file.Data)
			if err != nil {
				return err
			}
			chartName = ch.GetName()
		}
	}
	if chartName == "" {
		return errors.New("chart name not specified")
	}

	// Find the base directory
	chartdir, err := securejoin.SecureJoin(dir, chartName)
	if err != nil {
		return err
	}

	// Copy all files verbatim. We don't parse these files because parsing can remove
	// comments.
	for _, file := range files {
		outpath, err := securejoin.SecureJoin(chartdir, file.Name)
		if err != nil {
			return err
		}

		// Make sure the necessary subdirs get created.
		basedir := filepath.Dir(outpath)
		if err := os.MkdirAll(basedir, 0755); err != nil {
			return err
		}

		if err := ioutil.WriteFile(outpath, file.Data, 0644); err != nil {
			return err
		}
	}
	return nil
}
1158132
func (s *IndicesPutMappingService) ExpandWildcards(expandWildcards string) *IndicesPutMappingService {
	s.expandWildcards = expandWildcards
	return s
}
602678
func expand(sources []string) []string {
	for i, s := range sources {
		// first expand the environment
		sources[i] = os.ExpandEnv(s)
	}
	return sources
}
1187916
func (f *FlattenOpts) ExpandOpts(skipSchemas bool) *swspec.ExpandOptions {
	return &swspec.ExpandOptions{RelativeBase: f.BasePath, SkipSchemas: skipSchemas}
}
191457
func (s *FieldCapsService) ExpandWildcards(expandWildcards string) *FieldCapsService {
	s.expandWildcards = expandWildcards
	return s
}
921282
func (c *EnvCommand) Expand(expander SingleWordExpander) error {
	return expandKvpsInPlace(c.Env, expander)
}
199295
func expandStringList(configured []interface{}) []*string {
	vs := make([]*string, 0, len(configured))
	for _, v := range configured {
		val, ok := v.(string)
		if ok && val != "" {
			vs = append(vs, aws.String(v.(string)))
		}
	}
	return vs
}
1336429
func expandHome(p string) string {
	if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
		home := os.Getenv("HOME")
		if home == "" {
			if usr, err := user.Current(); err == nil {
				home = usr.HomeDir
			}
		}
		if home != "" {
			p = home + p[1:]
		}
	}
	return filepath.Clean(p)
}
1086766
func expandPath(s string) string {
	if s == "" {
		return ""
	}

	e, err := homedir.Expand(s)
	if err != nil {
		return s
	}
	return e
}
58956
func expandNamedQuery(m *DbMap, query string, keyGetter func(key string) reflect.Value) (string, []interface{}) {
	var (
		n    int
		args []interface{}
	)
	return keyRegexp.ReplaceAllStringFunc(query, func(key string) string {
		val := keyGetter(key[1:])
		if !val.IsValid() {
			return key
		}
		args = append(args, val.Interface())
		newVar := m.Dialect.BindVar(n)
		n++
		return newVar
	}), args
}
230409
func (name Name) Expand() []Name {
	switch name {
	case ObjectAccessedAll:
		return []Name{ObjectAccessedGet, ObjectAccessedHead}
	case ObjectCreatedAll:
		return []Name{ObjectCreatedCompleteMultipartUpload, ObjectCreatedCopy, ObjectCreatedPost, ObjectCreatedPut}
	case ObjectRemovedAll:
		return []Name{ObjectRemovedDelete}
	default:
		return []Name{name}
	}
}
1004248
func (u UnionCategoryExpander) Expand(category string) ([]schema.GroupResource, bool) {
	ret := []schema.GroupResource{}
	ok := false

	// Expand the category for each CategoryExpander in the list and merge/combine the results.
	for _, expansion := range u {
		curr, currOk := expansion.Expand(category)

		for _, currGR := range curr {
			found := false
			for _, existing := range ret {
				if existing == currGR {
					found = true
					break
				}
			}
			if !found {
				ret = append(ret, currGR)
			}
		}
		ok = ok || currOk
	}

	return ret, ok
}
262871
func (b *ByteBuf) Expansion(n int) {
	if free := b.Writeable(); free < n {
		newBuf := b.pool.Alloc(b.Capacity() + n)
		offset := b.writerIndex - b.readerIndex
		copy(newBuf, b.buf[b.readerIndex:b.writerIndex])
		b.readerIndex = 0
		b.writerIndex = offset
		b.pool.Free(b.buf)
		b.buf = newBuf
	}
}