Returns a list of ComponentResult from the json_data
552423
def _create_component_results(json_data, result_key):
    
    component_results = []
    for key, value in list(json_data.items()):
        if key not in [result_key, "meta"]:
            component_result = ComponentResult(
                key,
                value["result"],
                value["api_code"],
                value["api_code_description"]
            )

            component_results.append(component_result)

    return component_results
456251
def get_entities_by_components(self, *components):
        '''
        
        '''
        return list(filter(lambda entity:
                           set(components) <=
                           set(map(type, entity.get_components())),
                           self._entities))
108867
public static function __getProcessInputComponents($data)
    {
        $showInvisible = Kwf_Component_Data_Root::getShowInvisible();

        $cacheId = 'procI-'.$data->componentId;
        $success = false;
        if (!$showInvisible) { //don't cache in preview
            $cacheContents = Kwf_Cache_Simple::fetch($cacheId, $success);
            //cache is cleared in Kwf_Component_Events_ProcessInputCache
        }
        if (!$success) {
            $datas = array();
            foreach (self::_findProcessInputComponents($data) as $p) {
                $plugins = array();
                $c = $p;
                do {
                    foreach ($c->getPlugins('Kwf_Component_Plugin_Interface_SkipProcessInput') as $i) {
                        $plugins[] = array(
                            'pluginClass' => $i,
                            'componentId' => $c->componentId
                        );
                    }
                    $isPage = $c->isPage;
                    $c = $c->parent;
                } while ($c && !$isPage);
                $datas[] = array(
                    'data' => $p,
                    'plugins' => $plugins,
                );
            }
            if (!$showInvisible) {
                $cacheContents = array();
                foreach ($datas as $p) {
                    $cacheContents[] = array(
                        'data' => $p['data']->kwfSerialize(),
                        'plugins' => $p['plugins'],
                    );
                }
                Kwf_Cache_Simple::add($cacheId, $cacheContents);
            }
        } else {
            $datas = array();
            foreach ($cacheContents as $d) {
                $datas[] = array(
                    'data' => Kwf_Component_Data::kwfUnserialize($d['data']),
                    'plugins' => $d['plugins'],
                );
            }
        }
        //ask SkipProcessInput plugins if it should be skipped
        //evaluated every time
        $process = array();
        foreach ($datas as $d) {
            foreach ($d['plugins'] as $p) {
                $plugin = Kwf_Component_Plugin_Abstract::getInstance($p['pluginClass'], $p['componentId']);
                if ($plugin->skipProcessInput($d['data'])) {
                    continue 2;
                }
            }
            $process[] = $d['data'];
        }

        return $process;
    }
348744
def json_string(self):
        
        def visit_children(node):
            """ Recursively visit the fragments_tree """
            output_fragments = []
            for child in node.children_not_empty:
                fragment = child.value
                text = fragment.text_fragment
                output_fragments.append({
                    "id": text.identifier,
                    "language": text.language,
                    "lines": text.lines,
                    "begin": gf.time_to_ssmmm(fragment.begin),
                    "end": gf.time_to_ssmmm(fragment.end),
                    "children": visit_children(child)
                })
            return output_fragments
        output_fragments = visit_children(self.fragments_tree)
        return gf.safe_unicode(
            json.dumps({"fragments": output_fragments}, indent=1, sort_keys=True)
        )
1101601
def create_from_json(cls, json_data):
        
        block = Block()
        block_info = json_data["block_info"]
        block.block_id = block_info["block_id"]
        block.num_bins = block_info["num_bins"] if "num_bins" in block_info else None
        block.property_type = block_info["property_type"] if "property_type" in block_info else None
        block.meta = json_data["meta"] if "meta" in json_data else None

        block.component_results = _create_component_results(json_data, "block_info")

        return block
1071826
def get_info(self, component):
        

        # Grab it, clean it and ship it
        work_results = self._get_work_results('info', component)
        return self.data_store.clean_for_serialization(work_results)
1235724
function (item) {
            var key = this._getKeyForItem(item),
                list = this.$renderedItems;
            if (key) {
                list = this.$renderedItemsMap[key];
            }
            if (list) {
                var ri;
                for (var i = 0; i < list.length; i++) {
                    ri = list[i];
                    if (key || ri.item === item) {
                        return ri.component;
                    }
                }
            }
            return null;
        }
1002296
def all(self, components_in_and=True):
        ''''''
        self.components_in_and = components_in_and
        return [obj for obj in iter(self)]
311699
function getComponentsWithExamples(root) {
    const componentsPath = `${__dirname}/../${root}/components`;
    return fs.readdirSync(componentsPath).map(component => ({
        name: component,
        sources: [`${componentsPath}/${component}`, `${componentsPath}/${component}/examples`]
    })).filter(isDirectory).map(obj => obj.name);
}
12150
def json(self):
        """"""
        if self.search_results is None:
            return None

        result = []
        for row in self.search_results['rows']:
            obj = {}
            for index in range(0, len(self.search_results['fields'])):
                obj[self.search_results['fields'][index]] = row[index]
            result.append(obj)

        return result
542388
private static List<JsonObject> getJsonValueAsList(JsonValue value) {
        if (value != null) {
            if (value.getValueType() == ValueType.ARRAY) {
                return value.asJsonArray().getValuesAs(JsonObject.class);

            } else if (value.getValueType() == ValueType.OBJECT) {
                List<JsonObject> ret = new ArrayList<>();
                ret.add(value.asJsonObject());

                return ret;
            }
        }
        return null;
    }
1106211
protected void gatherComponentInfo (ComponentRepository crepo)
    {
        // get the list of all component classes
        Iterators.addAll(_classes, crepo.enumerateComponentClasses());

        for (int ii = 0; ii < _classes.size(); ii++) {
            // get the list of components available for this class
            ComponentClass cclass = _classes.get(ii);
            Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);

            while (iter.hasNext()) {
                Integer cid = iter.next();
                ArrayList<Integer> clist = _components.get(cclass);
                if (clist == null) {
                    _components.put(cclass, clist = Lists.newArrayList());
                }

                clist.add(cid);
            }
        }
    }
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,
            ),
        )
11152
function (query, results) {
        // Filter components out of the results.
        return YArray.filter(results, function (result) {
            return result.raw.resultType === 'component' ? false : result;
        });
    }
969806
def data(self):
        """"""
        data = super(DynamicListSerializer, self).data
        processed_data = ReturnDict(
            SideloadingProcessor(self, data).data,
            serializer=self
        ) if self.child.envelope else ReturnList(
            data,
            serializer=self
        )
        processed_data = post_process(processed_data)
        return processed_data
527369
def _viewset_results(self):
        """"""
        results = []
        try:
            response = self._viewset_method(
                self._viewset.request, *self._request.args, **self._request.kwargs
            )

            if response.status_code == 200:
                results = response.data

                if not isinstance(results, list):
                    if isinstance(results, dict):
                        # XXX: This can incidently match if a single
                        # object has results key
                        if 'results' in results and isinstance(
                            results['results'], list
                        ):
                            # Support paginated results.
                            results = results['results']
                        else:
                            results.setdefault(self._meta.primary_key, 1)
                            results = [collections.OrderedDict(results)]
                    else:
                        raise ValueError(
                            "Observable views must return a dictionary or a list of dictionaries!"
                        )
        except Http404:
            pass
        except django_exceptions.ObjectDoesNotExist:
            # The evaluation may fail when certain dependent objects (like users) are removed
            # from the database. In this case, the observer is stopped.
            pass

        return results
372537
public static List<DomesticResult> parseList(JsonNode json) {
        List<DomesticResult> results = new ArrayList<DomesticResult>();

        for (int i = 1; i <= MAX_RESULTS; i++) {
            String itemFieldName = String.format("g%d", i);

            if (json.has(itemFieldName)) {
                results.add(parseItem(json.get(itemFieldName)));
            } else {
                break;
            }
        }

        return results;
    }