// OpenScope opens a new scope for variables.
//
// All changes to variables' values made within this scope are discarded when it
// is closed.
163409
func (v *Vars) OpenScope(th *starlark.Thread) {
	v.scopes = append(v.scopes, &scope{thread: th})
}
561017
func (m *Multi) Open(name string) (io.ReadCloser, error) {
	for _, loader := range m.loaders {
		if f, err := loader.Open(name); err == nil {
			return f, nil
		}
	}
	return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
}
276823
func NewScopes(in interface{}, context *compiler.Context) (*Scopes, error) {
	errors := make([]error, 0)
	x := &Scopes{}
	m, ok := compiler.UnpackMap(in)
	if !ok {
		message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
		errors = append(errors, compiler.NewError(context, message))
	} else {
		// repeated NamedScope additional_properties = 1;
		// MAP: Scope
		x.AdditionalProperties = make([]*NamedScope, 0)
		for _, item := range m {
			k, ok := compiler.StringValue(item.Key)
			if ok {
				v := item.Value
				pair := &NamedScope{}
				pair.Name = k
				var err error
				pair.Value, err = NewScope(v, compiler.NewContext(k, context))
				if err != nil {
					errors = append(errors, err)
				}
				x.AdditionalProperties = append(x.AdditionalProperties, pair)
			}
		}
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
290644
func (q AppsQuery) scope(db *gorm.DB) *gorm.DB {
	scope := composedScope{isNull("deleted_at")}

	if q.ID != nil {
		scope = append(scope, idEquals(*q.ID))
	}

	if q.Name != nil {
		scope = append(scope, fieldEquals("name", *q.Name))
	}

	if q.Repo != nil {
		scope = append(scope, fieldEquals("repo", *q.Repo))
	}

	return scope.scope(db)
}
219750
func (v *View) ExtractScope(point int) text.Region {
	v.lock.Lock()
	defer v.lock.Unlock()
	if v.syntax != nil {
		return v.syntax.ScopeExtent(point)
	}
	return text.Region{}
}
1018290
func ExtractScopes(opts ...interface{}) *opt.ScopesOption {
	for _, o := range opts {
		if v, ok := o.(*opt.ScopesOption); ok {
			return v
		}
	}
	return nil
}
751161
func (ctx *Context) PushScope(vars map[string]string, args []string) {
	scope := make(Arguments)

	for k, v := range vars {
		scope[k] = v
	}

	for i, v := range args {
		k := strconv.Itoa(i)
		scope[k] = v
	}

	if args != nil {
		scope["*"] = strings.Join(args[1:], " ") // all args
		scope["#"] = strconv.Itoa(len(args[1:])) // args[0] is the function name
	}

	ctx.scopes = append(ctx.scopes, scope)
}
737512
func (u *UniterAPI) LeaveScope(args params.RelationUnits) (params.ErrorResults, error) {
	result := params.ErrorResults{
		Results: make([]params.ErrorResult, len(args.RelationUnits)),
	}
	canAccess, err := u.accessUnit()
	if err != nil {
		return params.ErrorResults{}, err
	}
	for i, arg := range args.RelationUnits {
		unit, err := names.ParseUnitTag(arg.Unit)
		if err != nil {
			result.Results[i].Error = common.ServerError(common.ErrPerm)
			continue
		}
		relUnit, err := u.getRelationUnit(canAccess, arg.Relation, unit)
		if err == nil {
			err = relUnit.LeaveScope()
		}
		result.Results[i].Error = common.ServerError(err)
	}
	return result, nil
}
1267063
func (p *StorageProvider) Scope() storage.Scope {
	p.MethodCall(p, "Scope")
	return p.StorageScope
}
942350
func (s composedScope) scope(db *gorm.DB) *gorm.DB {
	for _, s := range s {
		db = s.scope(db)
	}

	return db
}
533010
func (o *IntrospectOAuth2TokenParams) WithScope(scope *string) *IntrospectOAuth2TokenParams {
	o.SetScope(scope)
	return o
}
717877
func (w *relationUnitsWatcher) mergeScope(changes *params.RelationUnitsChange, c *RelationScopeChange) error {
	docIds := make([]interface{}, len(c.Entered))
	for i, name := range c.Entered {
		key := w.sw.prefix + name
		docID := w.backend.docID(key)
		docIds[i] = docID
	}
	logger.Tracef("relationUnitsWatcher %q watching newly entered: %v, and unwatching left %v", w.sw.prefix, c.Entered, c.Left)
	if err := w.watcher.WatchMulti(settingsC, docIds, w.updates); err != nil {
		return errors.Trace(err)
	}
	for _, docID := range docIds {
		w.watching.Add(docID.(string))
	}
	for _, name := range c.Entered {
		key := w.sw.prefix + name
		if err := w.mergeSettings(changes, key); err != nil {
			return errors.Annotatef(err, "while merging settings for %q entering relation scope", name)
		}
		changes.Departed = remove(changes.Departed, name)
	}
	for _, name := range c.Left {
		key := w.sw.prefix + name
		docID := w.backend.docID(key)
		changes.Departed = append(changes.Departed, name)
		if changes.Changed != nil {
			delete(changes.Changed, name)
		}
		w.watcher.Unwatch(settingsC, docID, w.updates)
		w.watching.Remove(docID)
	}
	logger.Tracef("relationUnitsWatcher %q Change updated to: %# v", w.sw.prefix, changes)
	return nil
}
381647
func DetermineLDAPScope(scope string) (Scope, error) {
	switch scope {
	case "", scopeWholeSubtreeString:
		return ScopeWholeSubtree, nil
	case scopeSingleLevelString:
		return ScopeSingleLevel, nil
	case scopeBaseObjectString:
		return ScopeBaseObject, nil
	default:
		return -1, fmt.Errorf("invalid scope %q", scope)
	}
}
1063381
func (c credentialHeader) getScope() string {
	return strings.Join([]string{
		c.scope.date.Format(yyyymmdd),
		c.scope.region,
		c.scope.service,
		c.scope.request,
	}, "/")
}
534603
func (s *DockerVolumeConfiguration) SetScope(v string) *DockerVolumeConfiguration {
	s.Scope = &v
	return s
}
313537
func NewScope(args []string, tagname string) (app.Scope, error) {
	scope := &ArgScope{
		EventScope: scope.NewEventScope(),
		tagname:    tagname,
		data:       map[string]string{},
	}
	for i, value := range args {
		// position keys
		ikey := "$" + strconv.Itoa(i)
		scope.data[ikey] = value
		// reduce prefixes
		if strings.HasPrefix(value, "--") {
			value = value[2:]
		} else if strings.HasPrefix(value, "-") {
			value = value[1:]
		}
		// key:value
		index := strings.Index(value, "=")
		if index != -1 {
			key := value[:index]
			value = value[index+1:]
			scope.data[key] = value
		} else {
			scope.data[value] = "true"
		}
	}
	return scope, nil
}
1367516
func (c *Constant) Link(scope Scope) (err error) {
	if c.linked() {
		return nil
	}

	if c.Type, err = c.Type.Link(scope); err != nil {
		return compileError{Target: c.Name, Reason: err}
	}

	if c.Value, err = c.Value.Link(scope, c.Type); err != nil {
		return compileError{Target: c.Name, Reason: err}
	}

	return nil
}