Replace my :attr:`scopes` for the duration of the with block.

        My global scope is not replaced.

        Args:
            new_scopes (list of dict-likes): The new :attr:`scopes` to use.
513481
def scopes_as(self, new_scopes):
        
        old_scopes, self.scopes = self.scopes, new_scopes
        yield
        self.scopes = old_scopes
118694
def to_names(scope):
    
    return [
        name
        for (name, value) in SCOPE_NAME_DICT.iteritems()
        if check(value, scope)
    ]
977420
def _collect_scopes(handlers, scopes, user, client):
    
    results = set()

    data = {'user': user, 'client': client}

    def visitor(scope_name, func):
        claim_names = func(data)
        # If the claim_names is None, it means that the scope is not authorized.
        if claim_names is not None:
            results.add(scope_name)

    _visit_handlers(handlers, visitor, 'scope', scopes)

    return results
1218318
def scope=(input)
      @scope = (input.instance_of?(Redistat::Scope)) ? input : Scope.new(input)
    end
270727
def tasks_in_scope(scope)
      prefix = scope.join(":")
      tasks.select { |t|
        /^#{prefix}:/ =~ t.name
      }
    end
639940
def add_arg_scope(func):
  
  @functools.wraps(func)
  def func_with_args(*args, **kwargs):
    current_scope = _current_arg_scope()
    current_args = kwargs
    key_func = (func.__module__, func.__name__)
    if key_func in current_scope:
      current_args = current_scope[key_func].copy()
      current_args.update(kwargs)
    return func(*args, **current_args)
  _add_op(func)
  return func_with_args
384356
def prepend_name_scope(name, import_scope):
  """"""
  # Based on tensorflow/python/framework/ops.py implementation.
  if import_scope:
    try:
      str_to_replace = r"([\^]|loc:@|^)(.*)"
      return re.sub(str_to_replace, r"\1" + import_scope + r"/\2",
                    tf.compat.as_str_any(name))
    except TypeError as e:
      # If the name is not of a type we can process, simply return it.
      logging.warning(e)
      return name
  else:
    return name
1268140
function addScope (scope) {
  if (!scope) {
    return
  }
  var oldScope = new Set(this.scope.split(' '))
  var newScope
  // Convert the incoming new scopes to a Set
  if (typeof scope === 'string') {
    newScope = new Set(scope.split(' '))
  } else if (Array.isArray(scope)) {
    newScope = new Set(scope)
  } else {
    throw new RangeError('Trying to add an invalid scope object')
  }
  oldScope.forEach(function (item) {
    newScope.add(item)
  })
  // Convert back to string
  this.scope = Array.from(newScope).join(' ')
}
1349466
def extract_scopes(self, request):
        
        payload = self.extract_payload(request)
        if not payload:
            return None

        scopes_attribute = self.config.scopes_name()
        return payload.get(scopes_attribute, None)
562489
def _get_scopes(self):
        
        if self._read_only:
            scopes = (READ_ONLY_SCOPE,)
        else:
            scopes = (DATA_SCOPE,)

        if self._admin:
            scopes += (ADMIN_SCOPE,)

        return scopes
401357
def use_refresh_token(self, refresh_token, scope=None):
        # type (str, Optional[List[str]]) -> Tuple[se_leg_op.access_token.AccessToken, Optional[str]]
        

        if refresh_token not in self.refresh_tokens:
            raise InvalidRefreshToken('{} unknown'.format(refresh_token))

        refresh_token_info = self.refresh_tokens[refresh_token]
        if 'exp' in refresh_token_info and refresh_token_info['exp'] < int(time.time()):
            raise InvalidRefreshToken('{} has expired'.format(refresh_token))

        authz_info = self.access_tokens[refresh_token_info['access_token']]

        if scope:
            if not requested_scope_is_allowed(scope, authz_info['granted_scope']):
                logger.debug('trying to refresh token with superset scope, requested_scope=%s, granted_scope=%s',
                             scope, authz_info['granted_scope'])
                raise InvalidScope('Requested scope includes non-granted value')
            scope = ' '.join(scope)
            logger.debug('refreshing token with new scope, old_scope=%s -> new_scope=%s', authz_info['scope'], scope)
        else:
            # OAuth 2.0: scope: "[...] if omitted is treated as equal to the scope originally granted by the resource owner"
            scope = authz_info['granted_scope']

        new_access_token = self._create_access_token(authz_info['sub'], authz_info[self.KEY_AUTHORIZATION_REQUEST],
                                                     authz_info['granted_scope'], scope)

        new_refresh_token = None
        if self.refresh_token_threshold \
                and 'exp' in refresh_token_info \
                and refresh_token_info['exp'] - int(time.time()) < self.refresh_token_threshold:
            # refresh token is close to expiry, issue a new one
            new_refresh_token = self.create_refresh_token(new_access_token.value)
        else:
            self.refresh_tokens[refresh_token]['access_token'] = new_access_token.value

        logger.debug('refreshed tokens, new_access_token=%s new_refresh_token=%s old_refresh_token=%s',
                     new_access_token, new_refresh_token, refresh_token)
        return new_access_token, new_refresh_token
580308
def new_scope(names)
      values = names.collect { |n| self[n] }
      self.class.new(names, values, self)
    end
324475
def require_scopes(self, scope_string):
        
        scopes = _process_scopes(scope_string)
        if not scopes:
            # asking for tokens with no scopes
            return self.filter(scopes__isnull=True)
        from .models import Scope
        scope_pks = Scope.objects.filter(name__in=scopes).values_list('pk', flat=True)
        if not len(scopes) == len(scope_pks):
            # there's a scope we don't recognize, so we can't have any tokens for it
            return self.none()
        tokens = self.all()
        for pk in scope_pks:
            tokens = tokens.filter(scopes__pk=pk)
        return tokens
397021
def bind(self, *args, **kw):
    
    new_self = self.copy()
    new_scopes = Object.translate_to_scopes(*args, **kw)
    new_self._scopes = tuple(reversed(new_scopes)) + new_self._scopes
    return new_self
1263284
def without_global_scope(self, scope):
        
        if isinstance(scope, basestring):
            del self._scopes[scope]

            return self

        keys = []
        for key, value in self._scopes.items():
            if scope == value.__class__ or isinstance(scope, value.__class__):
                keys.append(key)

        for key in keys:
            del self._scopes[key]

        return self
957069
def create_response_dic(self):
        
        dic = {}

        for scope in self.scopes:
            if scope in self._scopes_registered():
                dic.update(getattr(self, 'scope_' + scope)())

        dic = self._clean_dic(dic)

        return dic
294563
def wrap_with_scope(func, scope_name=None):
    ''''''
    if scope_name is None:
        scope_name = get_current_scope().name
    return lambda *args, scope=scope_name, **kwargs: \
           _call_with_scope(func, scope, args, kwargs)