// Imports returns all the packages that have to be imported for the
488147
func (g Generator) Imports() map[string]string {
	imports := imports.New(g.Package())
	for _, m := range g.Methods() {
		s := m.signature()
		imports.AddImportsFrom(s.Params())
		imports.AddImportsFrom(s.Results())
	}
	return imports.Imports()
}
1354823
func (b *Builder) importPackage(dir string, userRequested bool) (*tc.Package, error) {
	klog.V(5).Infof("importPackage %s", dir)
	var pkgPath = importPathString(dir)

	// Get the canonical path if we can.
	if buildPkg := b.buildPackages[dir]; buildPkg != nil {
		canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath)
		klog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage)
		pkgPath = canonicalPackage
	}

	// If we have not seen this before, process it now.
	ignoreError := false
	if _, found := b.parsed[pkgPath]; !found {
		// Ignore errors in paths that we're importing solely because
		// they're referenced by other packages.
		ignoreError = true

		// Add it.
		if err := b.addDir(dir, userRequested); err != nil {
			return nil, err
		}

		// Get the canonical path now that it has been added.
		if buildPkg := b.buildPackages[dir]; buildPkg != nil {
			canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath)
			klog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage)
			pkgPath = canonicalPackage
		}
	}

	// If it was previously known, just check that the user-requestedness hasn't
	// changed.
	b.userRequested[pkgPath] = userRequested || b.userRequested[pkgPath]

	// Run the type checker.  We may end up doing this to pkgs that are already
	// done, or are in the queue to be done later, but it will short-circuit,
	// and we can't miss pkgs that are only depended on.
	pkg, err := b.typeCheckPackage(pkgPath)
	if err != nil {
		switch {
		case ignoreError && pkg != nil:
			klog.V(2).Infof("type checking encountered some issues in %q, but ignoring.\n", pkgPath)
		case !ignoreError && pkg != nil:
			klog.V(2).Infof("type checking encountered some errors in %q\n", pkgPath)
			return nil, err
		default:
			return nil, err
		}
	}

	return pkg, nil
}
1334846
func (env *Env) Import(r io.Reader) error {
	scanner := bufio.NewScanner(r)
	for scanner.Scan() {
		line := scanner.Text()
		if strings.HasPrefix(line, "#") || len(line) == 0 {
			continue
		}
		l := strings.SplitN(line, "=", 2)
		if len(l) == 1 {
			return fmt.Errorf("Invalid line: %q", line)
		}
		env.data[l[0]] = l[1]

	}

	return scanner.Err()
}
138405
func (p *Importer) Import(path string) (*types.Package, error) {
	return p.ImportFrom(path, ".", 0) // use "." rather than "" (see issue #24441)
}
1019395
func (sd structDef) Imports() []string {
	ip := map[string]struct{}{}

	if sd.needFmt() {
		ip[`"fmt"`] = struct{}{}
	}
	if sd.OneLineDef == "" {
		ip[`"gopkg.in/validator.v2"`] = struct{}{}
	}

	// libraries
	for _, fd := range sd.Fields {
		if fd.fieldType == "json.RawMessage" {
			ip[`"encoding/json"`] = struct{}{}
		} else if lib := libImportPath(globRootImportPath, fd.fieldType, globLibRootURLs); lib != "" {
			ip[lib] = struct{}{}
		}
	}
	return commons.MapToSortedStrings(ip)
}
1035945
func ImportConfigs(c context.Context) (string, error) {
	cfg, rev, err := fetchConfigs(c)
	if err != nil {
		return "", errors.Annotate(err, "failed to fetch project configs").Err()
	}
	if err := importIdentities(c, cfg); err != nil {
		return "", errors.Annotate(err, "failed to import project configs").Err()
	}
	return rev, nil
}
1093311
func (t *UniversalTranslator) Import(format ImportExportFormat, dirnameOrFilename string) error {

	fi, err := os.Stat(dirnameOrFilename)
	if err != nil {
		return err
	}

	processFn := func(filename string) error {

		f, err := os.Open(filename)
		if err != nil {
			return err
		}
		defer f.Close()

		return t.ImportByReader(format, f)
	}

	if !fi.IsDir() {
		return processFn(dirnameOrFilename)
	}

	// recursively go through directory
	walker := func(path string, info os.FileInfo, err error) error {

		if info.IsDir() {
			return nil
		}

		switch format {
		case FormatJSON:
			// skip non JSON files
			if filepath.Ext(info.Name()) != ".json" {
				return nil
			}
		}

		return processFn(path)
	}

	return filepath.Walk(dirnameOrFilename, walker)
}
199180
func Imports(p []string) func(r *Rego) {
	return func(r *Rego) {
		r.imports = append(r.imports, p...)
	}
}
831068
func importSorted(imports map[string]string) []Import {
	names := make([]string, 0, len(imports))
	for n := range imports {
		names = append(names, n)
	}
	sort.Strings(names)
	result := make([]Import, len(names))
	for i, n := range names {
		result[i] = Import{n, imports[n]}
	}
	return result
}
1036962
func (w *Wrapper) importDirsUsed() []string {
	used := []string{}
	for _, imp := range w.ImportDirs {
		for _, proto := range w.ProtoFiles {
			if strings.HasPrefix(proto, imp) {
				used = append(used, imp)
				break
			}
		}
	}
	return used
}
1292995
func (c *InternalClient) Import(ctx context.Context, index, field string, shard uint64, bits []pilosa.Bit, opts ...pilosa.ImportOption) error {
	span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.Import")
	defer span.Finish()

	if index == "" {
		return pilosa.ErrIndexRequired
	} else if field == "" {
		return pilosa.ErrFieldRequired
	}

	// Set up import options.
	options := &pilosa.ImportOptions{}
	for _, opt := range opts {
		err := opt(options)
		if err != nil {
			return errors.Wrap(err, "applying option")
		}
	}

	buf, err := c.marshalImportPayload(index, field, shard, bits)
	if err != nil {
		return fmt.Errorf("Error Creating Payload: %s", err)
	}

	// Retrieve a list of nodes that own the shard.
	nodes, err := c.FragmentNodes(ctx, index, shard)
	if err != nil {
		return fmt.Errorf("shard nodes: %s", err)
	}

	// Import to each node.
	for _, node := range nodes {
		if err := c.importNode(ctx, node, index, field, buf, options); err != nil {
			return fmt.Errorf("import node: host=%s, err=%s", node.URI, err)
		}
	}

	return nil
}
853962
func allPackages(pattern string) []string {
	pkgs := matchPackages(pattern)
	if len(pkgs) == 0 {
		fmt.Fprintf(os.Stderr, "warning: %q matched no packages\n", pattern)
	}
	return pkgs
}
830051
func (m Methods) Imports() []string {
	var pkgImports []string
	for _, method := range m {
		pkgImports = append(pkgImports, method.Imports...)
	}
	if len(pkgImports) > 0 {
		pkgImports = uniqueNonEmptyStrings(pkgImports)
		sort.Strings(pkgImports)
	}
	return pkgImports
}
1358696
func (ks *KeyStore) Import(keyJSON []byte, passphrase, newPassphrase string) (accounts.Account, error) {
	key, err := DecryptKey(keyJSON, passphrase)
	if key != nil && key.PrivateKey != nil {
		defer zeroKey(key.PrivateKey)
	}
	if err != nil {
		return accounts.Account{}, err
	}
	return ks.importKey(key, newPassphrase)
}
587374
func getAllDeps(importPath string, cmds []string) []string {
	subpackagePrefix := importPath + "/"

	var depsSlice []string
	for _, useAllFiles := range []bool{false, true} {
		printLoadingError := func(path string, err error) {
			if err != nil && !useAllFiles {
				// Lots of errors because of UseAllFiles.
				log.Printf("error loading package %s: %s", path, err)
			}
		}

		deps := map[string]struct{}{}
		roots := map[string]struct{}{
			importPath: {},
		}

		// Add the command packages. Note that external command packages are
		// considered dependencies.
		for _, pkg := range cmds {
			roots[pkg] = struct{}{}

			if !strings.HasPrefix(pkg, subpackagePrefix) {
				deps[pkg] = struct{}{}
			}
		}

		buildContext := build.Default
		buildContext.CgoEnabled = true
		buildContext.UseAllFiles = useAllFiles

		// Add the subpackages.
		for path := range buildutil.ExpandPatterns(&buildContext, []string{subpackagePrefix + "..."}) {
			_, err := buildContext.Import(path, "", 0)
			if _, ok := err.(*build.NoGoError); ok {
				continue
			}
			printLoadingError(path, err)
			roots[path] = struct{}{}
		}

		var addTransitiveClosure func(string)
		addTransitiveClosure = func(path string) {
			pkg, err := buildContext.Import(path, "", 0)
			printLoadingError(path, err)

			importPaths := append([]string(nil), pkg.Imports...)
			if _, ok := roots[path]; ok {
				importPaths = append(importPaths, pkg.TestImports...)
				importPaths = append(importPaths, pkg.XTestImports...)
			}

			for _, path := range importPaths {
				if path == "C" {
					continue // "C" is fake
				}

				// Resolve the import path relative to the importing package.
				if bp2, _ := buildContext.Import(path, pkg.Dir, build.FindOnly); bp2 != nil {
					path = bp2.ImportPath
				}

				// Exclude our roots. Note that commands are special-cased above.
				if _, ok := roots[path]; ok {
					continue
				}
				slash := strings.IndexByte(path, '/')
				stdLib := slash == -1 || strings.IndexByte(path[:slash], '.') == -1
				// Exclude the standard library.
				if stdLib {
					continue
				}
				if _, ok := deps[path]; !ok {
					deps[path] = struct{}{}
					addTransitiveClosure(path)
				}
			}
		}

		for path := range roots {
			addTransitiveClosure(path)
		}
		addTransitiveClosure(importPath)

		depsSlice = append(depsSlice, setToSlice(deps)...)
	}

	return depsSlice
}
813529
func (engine *Engine) Import(r io.Reader) ([]sql.Result, error) {
	var results []sql.Result
	var lastError error
	scanner := bufio.NewScanner(r)

	semiColSpliter := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
		if atEOF && len(data) == 0 {
			return 0, nil, nil
		}
		if i := bytes.IndexByte(data, ';'); i >= 0 {
			return i + 1, data[0:i], nil
		}
		// If we're at EOF, we have a final, non-terminated line. Return it.
		if atEOF {
			return len(data), data, nil
		}
		// Request more data.
		return 0, nil, nil
	}

	scanner.Split(semiColSpliter)

	for scanner.Scan() {
		query := strings.Trim(scanner.Text(), " \t\n\r")
		if len(query) > 0 {
			engine.logSQL(query)
			result, err := engine.DB().Exec(query)
			results = append(results, result)
			if err != nil {
				return nil, err
			}
		}
	}

	return results, lastError
}
715724
func Import(s *Snapshot) *Histogram {
	h := New(s.LowestTrackableValue, s.HighestTrackableValue, int(s.SignificantFigures))
	h.counts = s.Counts
	totalCount := int64(0)
	for i := int32(0); i < h.countsLen; i++ {
		countAtIndex := h.counts[i]
		if countAtIndex > 0 {
			totalCount += countAtIndex
		}
	}
	h.totalCount = totalCount
	return h
}