Recursively lists given urns. Results are cached.
184363
def RecursiveMultiListChildren(self, urns):
    """"""
    result = {}

    checked_urns = set()
    not_cached_urns = []
    urns_to_check = urns
    while True:
      found_children = []

      for urn in urns_to_check:
        try:
          children = result[urn] = self._children_lists_cache[urn]
          found_children.extend(children)
        except KeyError:
          not_cached_urns.append(urn)

      checked_urns.update(urns_to_check)
      urns_to_check = set(found_children) - checked_urns

      if not urns_to_check:
        break

    for urn, children in FACTORY.RecursiveMultiListChildren(not_cached_urns):
      result[urn] = self._children_lists_cache[urn] = children

    return result
488804
def list(context, resource, **kwargs):
    """"""
    data = utils.sanitize_kwargs(**kwargs)
    id = data.pop('id', None)
    subresource = data.pop('subresource', None)

    if subresource:
        uri = '%s/%s/%s/%s' % (context.dci_cs_api, resource, id, subresource)
    else:
        uri = '%s/%s' % (context.dci_cs_api, resource)

    return context.session.get(uri, timeout=HTTP_TIMEOUT, params=data)
277218
def _query_iterator(cursor, chunksize, columns, index_col=None,
                        coerce_float=True, parse_dates=None):
        """"""

        while True:
            data = cursor.fetchmany(chunksize)
            if type(data) == tuple:
                data = list(data)
            if not data:
                cursor.close()
                break
            else:
                yield _wrap_result(data, columns, index_col=index_col,
                                   coerce_float=coerce_float,
                                   parse_dates=parse_dates)
499493
def get_many(self, uris):
        
        nodes = {}

        for uri in uris:
            try:
                node = self.get(uri)
            except NodeDoesNotExist:
                continue
            else:
                nodes[uri] = node

        return nodes
786717
def list_url?(u = nil, parsed: nil)
      return false if (u.nil? || u.empty?) && parsed.nil?
      parsed ||= parse_url(u)
      child_type = parsed[:child_type]
      parsed[:type] == 'lists' && (child_type.nil? || child_type.empty?)
    end
318232
def MultiOpen(self, urns, aff4_type=None, mode="r"):
    """"""
    not_opened_urns = []
    _ValidateAFF4Type(aff4_type)

    for urn in urns:
      key = self._ObjectKey(urn, mode)
      try:
        result = self._objects_cache[key]
        if aff4_type is not None and not isinstance(result, aff4_type):
          continue
        yield result

      except KeyError:
        not_opened_urns.append(urn)

    if not_opened_urns:
      for obj in FACTORY.MultiOpen(
          not_opened_urns, follow_symlinks=False, mode=mode, token=self._token):
        key = self._ObjectKey(obj.urn, mode)
        self._objects_cache[key] = obj

        if aff4_type is not None and not isinstance(obj, aff4_type):
          continue

        yield obj
692913
def getparams(self, result):
        """"""

        for key in self._cache:
            if self._cache[key][2] == result:
                args, kwargs, _ = self._cache[key]
                return args, kwargs

        else:
            raise ValueError('Result is not cached')
622120
function (url) {
	var result;

	LIST.some(function (state) {
		var params = state.pattern.match(url);

		if (params) {
			result       = state;
			state.params = params;
			return true;
		}
	});

	if (result) {
		var state        = result,
			parent_index = state.name.lastIndexOf('.'), parent_name;

		while (parent_index !== -1) {
			parent_name  = state.name.substring(0, parent_index);
			state.parent = STATES[parent_name];
			state        = state.parent;

			parent_index = state.name.lastIndexOf('.');
		}

		return result;
	}
}
1178614
def list_chunks(l, n):
    
    if n < 1:
        n = 1
    return [l[i:i + n] for i in range(0, len(l), n)]
1259999
def list(self, limit=None, marker=None, name=None, visibility=None,
            member_status=None, owner=None, tag=None, status=None,
            size_min=None, size_max=None, sort_key=None, sort_dir=None,
            return_raw=False):
        
        uri = "/%s" % self.uri_base
        qs = utils.dict_to_qs(dict(limit=limit, marker=marker, name=name,
                visibility=visibility, member_status=member_status,
                owner=owner, tag=tag, status=status, size_min=size_min,
                size_max=size_max, sort_key=sort_key, sort_dir=sort_dir))
        if qs:
            uri = "%s?%s" % (uri, qs)
        return self._list(uri, return_raw=return_raw)
180156
def _child_as_list(self, pk, ck):
        
        return [self._values[pk][ck][k]
                for k in sorted(self._values[pk][ck].keys(),
                                key=lambda x: int(x))]
269088
function list (req, res, next) {
    // Resource chain
    var chain = db.get(name)

    // Remove q, _start, _end, ... from req.query to avoid filtering using those
    // parameters
    var _q = req.query._q
    var _offset = req.query._offset
    var _end = req.query._end
    var _page = req.query._page
    var _sort = req.query._sort
    var _limit = req.query._limit
    var _embed = req.query._embed
    var _expand = req.query._expand
    var _fields = req.query._fields
    var _filter = req.query._filter
    delete req.query._q
    delete req.query._offset
    delete req.query._end
    delete req.query._sort
    delete req.query._limit
    delete req.query._embed
    delete req.query._expand
    delete req.query._fields

    // Automatically delete query parameters that can't be found
    // in the database
    Object.keys(req.query).forEach(function (query) {
      var arr = db.get(name).value()
      for (var i in arr) {
        if (
          _.has(arr[i], query) ||
          query === 'callback' ||
          query === '_' ||
          query.indexOf('_lte') !== -1 ||
          query.indexOf('_gte') !== -1 ||
          query.indexOf('_ne') !== -1 ||
          query.indexOf('_like') !== -1
        ) return
      }
      delete req.query[query]
    })

    if (_q) {
      // Full-text search
      _q = _q.toLowerCase()

      chain = chain.filter(function (obj) {
        for (var key in obj) {
          var value = obj[key]
          if (db._.deepQuery(value, _q)) {
            return true
          }
        }
      })
    }

    var filterMapping = {}

    if (_filter) {
      var filters = _filter.split(',')
      filters.forEach(function (filter) {
        var filterParts = filter.split(operatorsRegex)
        if (filterParts.length !== 3) {
          return
        }
        var key = filterParts[0]
        var op = filterParts[1]
        var value = filterParts[2]

        if (!filterMapping[key + op]) {
          filterMapping[key + op] = {value: []}
        }

        filterMapping[key + op].value.push(value)
        filterMapping[key + op].op = op
      })
    }

    Object.keys(filterMapping).forEach(function (key) {
      var values = filterMapping[key].value

      chain = chain.filter(function (element) {
        return values
            .map(utils.toNative)
            .map(function (value) {
              var op = filterMapping[key].op
              var isDifferent = key.indexOf('!=') !== -1 // op === '!='
              var isRange = key.indexOf('<') !== -1 || key.indexOf('>') !== -1 || key.indexOf('<=') !== -1 || key.indexOf('>=') !== -1 //     op === '<' || op === '>' || op === '<=' || op === '>='
              var isLike = key.indexOf('~') !== -1 || key.indexOf('~=') !== -1 || key.indexOf('=~') !== -1  // op === '~' || op === "~=" || op === '=~'
              var isIn = key.indexOf('|=') !== -1
              var path = key.replace(operatorsRegex, '')
              var elementValue = _.get(element, path)

              if (isRange) {
                switch (op) {
                  case '<':
                    return elementValue < value
                  case '>':
                    return elementValue > value
                  case '<=':
                    return elementValue <= value
                  case '>=':
                    return elementValue >= value
                  default:
                    return false
                }
              } else if (isDifferent) {
                return value !== elementValue
              } else if (isLike) {
                return new RegExp(value, 'i').test(elementValue)
              } else if (isIn) {
                var inValues = value.toString().split('|')
                inValues = _.map(inValues, function (val) {
                  return utils.toNative(val)
                })
                if (Array.isArray(elementValue)) {
                  return _.intersection(elementValue, inValues).length > 0
                } else {
                  return _.includes(inValues, elementValue)
                }
              } else {
                return _.matchesProperty(path, value)(element)
              }
            }).reduce(function (a, b) {
              return a || b
            })
      })
    })

    // Sort
    if (_sort) {
      var sortsParams = _sort.split(',')

      var sortMapping = {}
      sortsParams.forEach(function (sortParam) {
        var order = sortParam[0] === '-' ? 'desc' : 'asc'
        var sortField = sortParam.substring(1)
        sortMapping[sortField] = order
      })

      chain = chain.orderBy(_.keys(sortMapping), _.values(sortMapping)) // TODO iteration order is not guaranteed
    }

    // Slice result
    if (_end || _limit || _page) {
      res.setHeader('X-Total-Count', chain.size())
      res.setHeader('Access-Control-Expose-Headers', 'X-Total-Count')
    }

    if (_page) {
      _page = parseInt(_page, 10)
      _page = _page >= 1 ? _page : 1
      _limit = parseInt(_limit, 10) || 10
      var page = utils.getPage(chain.value(), _page, _limit)
      var links = {}
      var fullURL = getFullURL(req)

      if (page.first) {
        links.first = fullURL.replace('page=' + page.current, 'page=' + page.first)
      }

      if (page.prev) {
        links.prev = fullURL.replace('page=' + page.current, 'page=' + page.prev)
      }

      if (page.next) {
        links.next = fullURL.replace('page=' + page.current, 'page=' + page.next)
      }

      if (page.last) {
        links.last = fullURL.replace('page=' + page.current, 'page=' + page.last)
      }

      res.links(links)
      chain = _.chain(page.items)
    } else if (_end) {
      _offset = parseInt(_offset, 10) || 0
      _end = parseInt(_end, 10)
      chain = chain.slice(_offset, _end)
    } else if (_limit) {
      _offset = parseInt(_offset, 10) || 0
      _limit = parseInt(_limit, 10)
      chain = chain.slice(_offset, _offset + _limit)
    }

    if (_fields) {
      chain = chain.map(function (element) {
        return _.pick(element, _fields.split(','))
      })
    }
    // embed and expand
    chain = chain
      .cloneDeep()
      .forEach(function (element) {
        embed(element, _embed)
        expand(element, _expand)
      })

    res.locals.data = chain.value()
    next()
  }
911658
def reltags(self, src, cache=None):
    '''
    
    '''
    if not self._tag_assocs:
      return set()

    # fucking python and it's terrible support for recursion makes this
    # far more complicated than it needs to be
    if cache == None:
      cache = {}

    q = _otq()
    q.append(src)
    updateq = _otq()


    while q:
      i = q.popleft()
      if i in cache:
        continue

      cache[i] = set()
      for (s,t) in self.transitions_to(i):
        q.append(s)
        if self.is_tagged(t,s,i):
          cache[i].add((self.tag(t,s,i),s, i))
        updateq.appendleft((i, s))

    while updateq:
      i = updateq.popleft()
      cache[i[0]].update(cache[i[1]])

    return cache[src]
868645
private Iterable<String> getAllIncluding(String index, Iterable<String> keys, IterableChain<String> result) {
        result.addAll(keys);
        for (String key : keys) {
            Iterable<String> values = get(index, key);
            if (values.iterator().hasNext()) {
                getAllIncluding(index, values, result);
            }
        }
        return result;
    }
1055541
def _base_get_list(self, url, limit=None, *, query=None, order_by=None,
                       batch=None):
        

        if limit is None or limit > self.protocol.max_top_value:
            batch = self.protocol.max_top_value

        params = {'$top': batch if batch else limit}

        if order_by:
            params['$orderby'] = order_by

        if query:
            if query.has_filters:
                warnings.warn(
                    'Filters are not allowed by the Api Provider '
                    'in this method')
                query.clear_filters()
            if isinstance(query, str):
                params['$filter'] = query
            else:
                params.update(query.as_params())

        response = self.con.get(url, params=params)
        if not response:
            return iter(())

        data = response.json()

        # Everything received from cloud must be passed as self._cloud_data_key
        items = (
            self._classifier(item)(parent=self, **{self._cloud_data_key: item})
            for item in data.get('value', []))
        next_link = data.get(NEXT_LINK_KEYWORD, None)
        if batch and next_link:
            return Pagination(parent=self, data=items,
                              constructor=self._classifier,
                              next_link=next_link, limit=limit)
        else:
            return items
293093
def chunk_list(l, n):
    """"""
    return [l[i:i + n] for i in range(0, len(l), n)]
271737
def list(gandi, limit, step):
    """"""
    output_keys = ['id', 'type', 'step']

    options = {
        'step': step,
        'items_per_page': limit,
        'sort_by': 'date_created DESC'
    }

    result = gandi.oper.list(options)
    for num, oper in enumerate(reversed(result)):
        if num:
            gandi.separator_line()
        output_generic(gandi, oper, output_keys)

    return result