Converts from item found in DOAJ results to BentoSearch::ResultItem
345029
def hash_to_item(hash)
      item = ResultItem.new

      bibjson = hash["bibjson"] || {}

      item.unique_id  = hash["id"]

      # Hard-code to Article, we don't get any format information
      item.format     = "Article"

      item.title      = bibjson["title"]


      item.start_page = bibjson["start_page"]
      item.end_page   = bibjson["end_page"]

      item.year       = bibjson["year"]
      if (year = bibjson["year"].to_i) && (month = bibjson["month"].to_i)
        if year != 0 && month != 0
          item.publication_date = Date.new(bibjson["year"].to_i, bibjson["month"].to_i)
        end
      end

      item.abstract   = sanitize(bibjson["abstract"]) if bibjson.has_key?("abstract")

      journal           = bibjson["journal"] || {}
      item.volume       = journal["volume"]
      item.issue        = journal["number"]
      item.source_title = journal["title"]
      item.publisher    = journal["publisher"]
      item.language_str = journal["language"].try(:first)

      (bibjson["identifier"] || []).each do |id_hash|
        case id_hash["type"]
        when "doi"
          item.doi = id_hash["id"]
        when "pissn"
          item.issn = id_hash["id"]
        end
      end

      (bibjson["author"] || []).each do |author_hash|
        if author_hash.has_key?("name")
          author = Author.new(:display => author_hash["name"])
          item.authors << author
        end
      end

      # I _think_ DOAJ articles results always only have one link,
      # and it may always be of type 'fulltext'
      link_hash             = (bibjson["link"] || []).first
      if link_hash && link_hash["url"]
        item.link             = link_hash["url"]
        item.link_is_fulltext = true if link_hash["type"] == "fulltext"
      end

      return item
    end
69759
function (index) {
    var rawItem;
    var position = positions[index];

    try {
      rawItem = readEntry(position.start, position.end);
      return JSON.parse(rawItem);
    } catch (ex) {
      debug("ERROR reading item: %s -> %s", ex, rawItem);
    }
  }
735777
def item_set_goto(itemset, inputsymbol, productionset):
    """"""
    resultset = LR0ItemSet()
    for item in itemset.itemlist:
        if item.next_symbol() == inputsymbol:
            newitem = LR0Item(item.rule, item.position + 1)
            resultset.append_item(newitem)
    return _build_item_closure(resultset, productionset)
27689
def GetExportedResult(self,
                        original_result,
                        converter,
                        metadata=None,
                        token=None):
    """"""

    exported_results = list(
        converter.Convert(
            metadata or ExportedMetadata(), original_result, token=token))

    if not exported_results:
      raise ExportError("Got 0 exported result when a single one "
                        "was expected.")

    if len(exported_results) > 1:
      raise ExportError("Got > 1 exported results when a single "
                        "one was expected, seems like a logical bug.")

    return exported_results[0]
237832
function mapXSetItems (items) {
  let results = [];
  for (let i = 0; i < items.length; i += 1) {
    results.push({
      timestamp: items[i][0],
      field: items[i][1][0],
      value: items[i][1][1]
    });
  }
  return results;
}
1203073
def _mapped_result(self, r):
        
        # Apply result_post funcs for pulling out sandbox properties
        for func in self._pproc:
            func(r)
        # If we haven't asked for specific properties, just return object
        if not self._prop_dict:
            result = r
        else:
            result = dict()
            # Map aliased keys back to original key
            for k, v in self._prop_dict.items():
                try:
                    result[k] = self._mapped_result_path(v[1:], data=r[v[0]])
                except (IndexError, KeyError, ValueError):
                    result[k] = None
        return result
1365692
def getitem(source, index):
    
    if isinstance(index, builtins.slice):
        return slice.raw(source, index.start, index.stop, index.step)
    if isinstance(index, int):
        return item.raw(source, index)
    raise TypeError("Not a valid index (int or slice)")
604342
def results(self, key):
        """"""
        if not results_backend:
            return json_error_response("Results backend isn't configured")

        read_from_results_backend_start = now_as_float()
        blob = results_backend.get(key)
        stats_logger.timing(
            'sqllab.query.results_backend_read',
            now_as_float() - read_from_results_backend_start,
        )
        if not blob:
            return json_error_response(
                'Data could not be retrieved. '
                'You may want to re-run the query.',
                status=410,
            )

        query = db.session.query(Query).filter_by(results_key=key).one()
        rejected_tables = security_manager.rejected_datasources(
            query.sql, query.database, query.schema)
        if rejected_tables:
            return json_error_response(security_manager.get_table_access_error_msg(
                '{}'.format(rejected_tables)), status=403)

        payload = utils.zlib_decompress_to_string(blob)
        display_limit = app.config.get('DEFAULT_SQLLAB_LIMIT', None)
        if display_limit:
            payload_json = json.loads(payload)
            payload_json['data'] = payload_json['data'][:display_limit]
        return json_success(
            json.dumps(
                payload_json,
                default=utils.json_iso_dttm_ser,
                ignore_nan=True,
            ),
        )
263706
def to_a
      result = []
      @domains.values.each do |paths|
        paths.values.each do |cookies|
          cookies.values.inject result, :<<
        end
      end
      result
    end
646672
function findItem( path, items ) {
  var result = null;
  items.forEach( function ( item ) {
    if (!result && item instanceof MenuItem && item.paths.filter( function( value ) {
        return value === path;
      } ).length > 0)
      result = item;
    if (!result && item instanceof MenuNode) {
      var child = findItem( path, item.children );
      if (child)
        result = child;
    }
  } );
  return result;
}
496067
function (xxx, results) {
                var o
                ,   r
                ,   lookup = {}
                // map from results to keys
                for (var i = 0, l = results.rows.length; i < l; i++) {
					var rowObj = results.rows.item(i);
                    o = JSON.parse(rowObj.value)
                    var row_key = rowObj.id;
                    lookup[row_key] = o;
                    try{row_key = JSON.parse(row_key);}catch(exc){}
                    //o.key = row_key;
                    o.timestamp = rowObj.timestamp;
                }
                r = args.map(function(row_key) {return lookup[row_key];});
                if (!that.isArray(keyOrArray)) r = r.length ? r[0] : null
                if (cb) that.lambda(cb).call(that, r)
            }
699734
def getitem_by_path(d, path):
    
    return reduce(
        lambda d, k: d[k],
        path,
        d
    )
544331
def handle_collection_result(result)
    results = build_classes_from_result(result)
    while partial? && @options[:eager_partial]
      results.concat handle_partial
    end
    results
  end
1087626
def get_item(cls, hash_key, range_key=None):
        
        key = cls._encode_key(hash_key, range_key)
        raw_data = cls._get_connection().get_item(cls.get_table_name(), key)
        if 'Item' not in raw_data:
            raise ItemNotFoundException
        return cls.from_raw_data(raw_data['Item'])
614647
function resultRaw (results) {
    // throw error if results required and not retrieved
    if (this.args.required && !results.length) {
        // throw error
        throw this.error('no records found')
    }
    // if only ids were selected the return result object to fetch records
    if (this.select.isSelectOnlyIds) {
        // build result object
        var result = new ImmutableCoreModelResult({
            query: this,
            results: results,
        })
        // return result or all records if specified
        return this.args.all ? result.all() : result
    }
    // otherwise return ImmutableCoreModelInstance record(s)
    else {
        // query is for a single record
        if (this.args.limit === 1) {
            // return new instance or undefined
            return results.length
                ? this.newInstance(results[0])
                : undefined
        }
        // query is for multiple records
        else {
            return _.map(results, result => this.newInstance(result))
        }
    }
}
519427
function getListItems(listKey, from, to, callback) {
	this.redisClient.lrange(listKey, from, to, function(err, itemBytesArray) {
		if (err) { return callback(err, null) }
		if (!itemBytesArray) { return callback(null, []) }
		for (var items=[], i=0; i<itemBytesArray.length; i++) {
			items.push(itemBytesArray[i].toString())
		}
		callback(null, items)
	})
}
721191
private static function convertResult($result)
    {
        if (!is_array($result)) {
            return self::convert($result);
        }

        $results = [];

        foreach ($result as $item) {
            $results[] = self::convert($item);
        }

        return $results;
    }