/*
Get a listing of items in a space
555042
protected Iterator<String> getSpaceContents(String spaceId) {
        for (int i = 0; i < maxRetries; i++) {
            try {
                return s3Provider.getSpaceContents(spaceId, null);
            } catch (Exception e) {
                log.warn("Exception encountered attempting to get contents " +
                         "for streaming space: " + spaceId +
                         ", error message: " + e.getMessage());
                wait(i);
            }
        }
        throw new DuraCloudRuntimeException("Exceeded retries attempting to " +
                                            "get space contents for " + spaceId);
    }
1361477
function(count){
      var result = [];

      if (count)
        for (var objectId in this.items_)
          if (result.push(this.items_[objectId]) >= count)
            break;

      return result;
    }
532005
def _get_spaces(self):
        
        guid = self.api.config.get_organization_guid()
        uri = '/v2/organizations/%s/spaces' % (guid)
        return self.api.get(uri)
1124285
public String getSpaceContents(String spaceID,
                                   String storeID,
                                   String prefix,
                                   long maxResults,
                                   String marker) throws ResourceException {
        Element spaceElem = new Element("space");
        spaceElem.setAttribute("id", spaceID);

        try {
            StorageProvider storage = storageProviderFactory.getStorageProvider(storeID);

            List<String> contents = storage.getSpaceContentsChunked(spaceID,
                                                                    prefix,
                                                                    maxResults,
                                                                    marker);
            if (contents != null) {
                for (String contentItem : contents) {
                    Element contentElem = new Element("item");
                    contentElem.setText(contentItem);
                    spaceElem.addContent(contentElem);
                }
            }
        } catch (NotFoundException e) {
            throw new ResourceNotFoundException("build space XML for", spaceID, e);
        } catch (Exception e) {
            storageProviderFactory.expireStorageProvider(storeID);
            throw new ResourceException("build space XML for", spaceID, e);
        }

        Document doc = new Document(spaceElem);
        XMLOutputter xmlConverter = new XMLOutputter();
        return xmlConverter.outputString(doc);
    }
496695
public List<O> getItems(int count, int offset) {
        return getDatastore().find(clazz).offset(offset).limit(count).asList();
    }
137896
function(workspace) {
    var containerBlock = workspace.newBlock('lists_create_with_container');
    containerBlock.initSvg();
    var connection = containerBlock.getInput('STACK').connection;
    for (var i = 0; i < this.itemCount_; i++) {
      var itemBlock = workspace.newBlock('lists_create_with_item');
      itemBlock.initSvg();
      connection.connect(itemBlock.previousConnection);
      connection = itemBlock.nextConnection;
    }
    return containerBlock;
  }
295853
function listitem(text) {
  if (inList()) {

    // capture value in trailing "text" - unescape makes regexp work
    var m = unescapeQuotes(text).match(/^(.*)\s+"([^"]*)"\s*$/);

    var txt = m ? escapeQuotes(m[1]) : text;
    var val = m ? escapeQuotes(m[2]) : text;

    return renderOption(txt, val);
  }
  return fallback.listitem.call(this, text);
}
519013
function find(items, pred) {
  var len = items.length,
      i = -1;

  while(++i < len) {
    if (pred(items[i], i)) {
      return items[i];
    }
  }

  return null;
}
829254
def list( items, mode = :rows, option = nil )
    items = items.to_ary.map do |item|
      ERB.new(item, nil, "%").result(binding)
    end
    
    case mode
    when :inline
      option = " or " if option.nil?
      
      case items.size
      when 0
        ""
      when 1
        items.first
      when 2
        "#{items.first}#{option}#{items.last}"
      else
        items[0..-2].join(", ") + "#{option}#{items.last}"
      end
    when :columns_across, :columns_down
      max_length = actual_length(
        items.max { |a, b| actual_length(a) <=> actual_length(b) }
      )

      if option.nil?
        limit  = @wrap_at || 80
        option = (limit + 2) / (max_length + 2)
      end

      items     = items.map do |item|
        pad = max_length + (item.length - actual_length(item))
        "%-#{pad}s" % item
      end
      row_count = (items.size / option.to_f).ceil
      
      if mode == :columns_across
        rows = Array.new(row_count) { Array.new }
        items.each_with_index do |item, index|
          rows[index / option] << item
        end

        rows.map { |row| row.join("  ") + "\n" }.join
      else
        columns = Array.new(option) { Array.new }
        items.each_with_index do |item, index|
          columns[index / row_count] << item
        end
      
        list = ""
        columns.first.size.times do |index|
          list << columns.map { |column| column[index] }.
                          compact.join("  ") + "\n"
        end
        list
      end
    else
      items.map { |i| "#{i}\n" }.join
    end
  end
769896
def get_open_spaces(board):
  """"""
  open_spaces = []
  for i in range(3):
    for j in range(3):
      if board[i][j] == 0:
        open_spaces.append(encode_pos(i, j))
  return open_spaces
1060520
function(item) {
      var parts = item.displayName.split('.');
      for (var i = parts.length - 1; i > 0; i--) {
        var name = parts.slice(0, i).join('.');
        if (itemsByName[name]) {
          return itemsByName[name];
        }
      }
    }
375278
function getItem(itemName) {
  if (data[itemName]) {
    return data[itemName];
  } else if (localExists()) {
    var itemStr = window.sessionStorage.getItem(itemName);
    // Check that str is not null before parsing
    if (itemStr) {
      var isObj = false;
      var itemObj = null;
      // Try parsing to object
      try {
        itemObj = JSON.parse(itemStr);
        isObj = true;
      } catch (err) {
        // Parsing failed, this must just be a string
        // logger.log({message: 'String could not be parsed.', error: err, func: 'getItem', obj: 'storage'})
        isObj = false;
      }
      if (isObj) {
        return itemObj;
      }
    }
    return itemStr;
  } else {
    return null;
  }
}
1196059
public static function listing($items, $glue = ' &amp; ', $sep = ', ') {
        if (is_array($items)) {
            $lastItem = array_pop($items);

            if (count($items) === 0) {
                return $lastItem;
            }

            $items = implode($sep, $items);
            $items = $items . $glue . $lastItem;
        }

        return $items;
    }
1081625
protected List<String> getSpaces(String host, ContentStore store)
        throws ContentStoreException {
        List<String> spaceList;
        String spaces = dupHosts.get(host);
        if (spaces.equals(ALL_SPACES)) { // Need to compare all spaces
            spaceList = new ArrayList<>(store.getSpaces());
            spaceList.removeAll(ADMIN_SPACES);
        } else { // Only compare specific set of spaces
            String[] spacesToCompare = spaces.split(",");
            spaceList = Arrays.asList(spacesToCompare);
        }
        return spaceList;
    }
704969
function () {
                    var results = new Array(this.length);
                    for (var i = 0, len = this.length; i < len; i++) {
                        var item = this.getItem(i);
                        if (item) {
                            results[i] = item.data;
                        }
                    }
                    return results;
                }
1104133
function gatherHeaders(item) {
    var ret, i, l;
    if (isHashArray(item)) {
        //lets assume a multidimesional array with item 0 bing the title
        i = -1;
        l = item.length;
        ret = [];
        while (++i < l) {
            ret[i] = item[i][0];
        }
    } else if (isArray(item)) {
        ret = item;
    } else {
        ret = keys(item);
    }
    return ret;
}
802245
def get_spaces(self):
        
        self.spaces = []
        for resource in self._get_spaces()['resources']:
            self.spaces.append(resource['entity']['name'])

        return self.spaces