:param scope_string: The required scopes.
        :type scope_string: Union[str, list]
        :return: The tokens with all requested scopes.
        :rtype: :class:`esi.managers.TokenQueryset`
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
497626
def tokens(self, format_string):
        
        if format_string not in self.format_string_cache:
            if python2 and isinstance(format_string, str):
                format_string = format_string.decode("utf-8")
            tokens = list(re.finditer(self.reg_ex, format_string))
            self.format_string_cache[format_string] = tokens
        return self.format_string_cache[format_string]
921559
def _call_scope(self, scope, *args, **kwargs):
        
        query = self.get_query()

        # We will keep track of how many wheres are on the query before running the
        # scope so that we can properly group the added scope constraints in the
        # query as their own isolated nested where statement and avoid issues.
        original_where_count = len(query.wheres)

        result = getattr(self._model, scope)(self, *args, **kwargs)

        if self._should_nest_wheres_for_scope(query, original_where_count):
            self._nest_wheres_for_scope(
                query, [0, original_where_count, len(query.wheres)]
            )

        return result or self
1211408
def list_groups(self, scope_ids=None, recurse=None, deleted=None, properties=None):
        
        query_parameters = {}
        if scope_ids is not None:
            query_parameters['scopeIds'] = self._serialize.query('scope_ids', scope_ids, 'str')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query('recurse', recurse, 'bool')
        if deleted is not None:
            query_parameters['deleted'] = self._serialize.query('deleted', deleted, 'bool')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        response = self._send(http_method='GET',
                              location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('[Identity]', self._unwrap_collection(response))
898537
def scope_choices(self, exclude_internal=True):
        
        return [
            (k, scope) for k, scope in sorted(self.scopes.items())
            if not exclude_internal or not scope.is_internal
        ]
251953
def get_scopes(self, vpnid='.*'):
        """"""
        request_url = self._build_url(['Scope'], vpn=vpnid)
        return self._do_request('GET', request_url)
1102873
def has_scope(self, scope):
        """"""
        if not self.is_oauth_session():
            return False
        if '*' in self._authentication:
            return True
        if isinstance(scope, six.string_types):
            scope = [scope]
        return all(s in self._authentication for s in scope)
781040
def _prefix_scope(self, scope):
        
        if self.protocol_scope_prefix:
            if isinstance(scope, tuple):
                return scope[0]
            elif scope.startswith(self.protocol_scope_prefix):
                return scope
            else:
                return '{}{}'.format(self.protocol_scope_prefix, scope)
        else:
            if isinstance(scope, tuple):
                return scope[0]
            else:
                return scope
169304
def is_in_scope(cls, want_scope: str, have_scopes: List[Scope]) -> bool:
        
        if not want_scope:
            return True
        if want_scope in have_scopes or want_scope.split(':')[0] in have_scopes:
            return True
        elif want_scope.startswith('read'):
            return cls.is_in_scope(want_scope.replace('read', 'write'), have_scopes)
        elif want_scope.startswith('write'):
            return cls.is_in_scope(want_scope.replace('write', 'admin'), have_scopes)
        else:
            return False
169353
function loadScopes(scopes) {
  var scopeMapping = {};
  if (typeof scopes === 'object') {
    for (var s in scopes) {
      var routes = [];
      var entries = scopes[s];
      debug('Scope: %s routes: %j', s, entries);
      if (Array.isArray(entries)) {
        for (var j = 0, k = entries.length; j < k; j++) {
          var route = entries[j];
          if (typeof route === 'string') {
            routes.push({methods: ['all'], path: route,
              regexp: pathToRegexp(route, [], {end: false})});
          } else {
            var methods = helpers.normalizeList(methods);
            if (methods.length === 0) {
              methods.push('all');
            }
            methods = methods.map(toLowerCase);
            routes.push({methods: methods,
              path: route.path,
              regexp: pathToRegexp(route.path, [], {end: false})});
          }
        }
      } else {
        debug('Routes must be an array: %j', entries);
      }
      scopeMapping[s] = routes;
    }
  } else if (typeof scopes === 'string') {
    scopes = helpers.normalizeList(scopes);
    for (var i = 0, n = scopes.length; i < n; i++) {
      scopeMapping[scopes[i]] = [
        {methods: 'all', path: '/.+', regexp: /\/.+/}
      ];
    }
  }
  return scopeMapping;
}
529178
def scopes(cls):
        
        # Why do we need this? This should either
        # * Be bubbled to the places where it is used (AcidXBlock).
        # * Be automatic. Look for all members of a type.
        return [cls.USAGE, cls.DEFINITION, cls.TYPE, cls.ALL]
845128
def _strip_scope(msg):
    '''
    
    '''
    ret = []
    for line in msg.splitlines():
        if not line.endswith('.scope'):
            ret.append(line)
    return '\n'.join(ret).strip()
1330924
public List<String> getScopes(final int scopeIndex) {
    this.checkInitialized();
    return this.scopes.getOrDefault(Integer.valueOf(scopeIndex), SemanticHighlightingRegistry.UNKNOWN_SCOPES);
  }
1117175
def scope(s):
    
    if '@' not in s:
        raise ValueError("Unscoped string")
    (local_part, _, domain_part) = s.partition('@')
    return domain_part
12123
def scope(scope_type: str) -> Callable:
    

    def dec(egg_: T) -> T:
        egg_.__haps_custom_scope = scope_type
        return egg_

    return dec
513481
def scopes_as(self, new_scopes):
        
        old_scopes, self.scopes = self.scopes, new_scopes
        yield
        self.scopes = old_scopes
746451
public List<List<String>> getAllScopes() {
    this.checkInitialized();
    final ImmutableList.Builder<List<String>> builder = ImmutableList.<List<String>>builder();
    final Consumer<Integer> _function = (Integer it) -> {
      List<String> _get = this.scopes.get(it);
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("No scopes are available for index: ");
      _builder.append(it);
      builder.add(Preconditions.<List<String>>checkNotNull(_get, _builder));
    };
    this.scopes.keySet().forEach(_function);
    return builder.build();
  }