Render data descriptor.

    The rendering is based on descriptor schema and input context.

    :param data: data instance
    :type data: :class:`resolwe.flow.models.Data` or :class:`dict`
496096
def render_descriptor(data):
    
    if not data.descriptor_schema:
        return

    # Set default values
    for field_schema, field, path in iterate_schema(data.descriptor, data.descriptor_schema.schema, 'descriptor'):
        if 'default' in field_schema and field_schema['name'] not in field:
            dict_dot(data, path, field_schema['default'])
1223552
def render(self, data, accepted_media_type=None, renderer_context=None):
        
        if 'SWAGGER_JSON_PATH' in os.environ:
            with io.open(os.environ['SWAGGER_JSON_PATH'], 'rb') as f:
                return f.read()
        else:
            return super(ConditionalOpenAPIRenderer, self).render(data, accepted_media_type, renderer_context)
1012614
def render_diff_data(data)
      content_tag(:div, class: "card card--list diff diff-#{data[:type]}") do
        if [:i18n, :i18n_html].include?(data[:type])
          render_diff_value(
            "&nbsp;",
            data[:type],
            nil,
            data: {
              old_value: data[:old_value].to_s.gsub("</p>", "</p>\n"),
              new_value: data[:new_value].to_s.gsub("</p>", "</p>\n")
            }
          )
        else
          render_diff_value(data[:old_value], data[:type], :removal) +
            render_diff_value(data[:new_value], data[:type], :addition)
        end
      end
    end
492654
def render_default(data, format=:markdown, name='render_default.md')
      # set instance vars so we're able to render data without a wiki or page.
      @format = format
      @name   = name

      chain = [:Metadata, :PlainText, :Emoji, :TOC, :RemoteCode, :Code, :Sanitize, :WSD, :Tags, :Render]

      filter_chain = chain.map do |r|
        Gollum::Filter.const_get(r).new(self)
      end

      process_chain data, filter_chain
    end
1126137
def prepare_static_data(self, data):
        
        d = self.obj.to_dict()
        d.update(data.copy())
        for f in self.get_fields():
            if f['static'] and f['name'] in d:
                v = make_view_field(f, self.obj, self.types_convert_map, self.fields_convert_map, d[f['name']])
                d[f['name']] = v['display']
        return d
228884
def pretty_render(data, format='text', indent=0):
    
    if format == 'json':
        return render_json(data)
    elif format == 'html':
        return render_html(data)
    elif format == 'xml':
        return render_xml(data)
    else:
        return dict_to_plaintext(data, indent=indent)
1228121
function renderExample (divId, example) {
  var graph = graphs[example]

  var canvas = new Canvas(divId, {
    node: {
      DefaultNode: Node,
      InvalidNode,
      ToggleNode
    },
    util: { typeOfNode }
  })

  canvas.render(graph.view)

  dflow.fun(graph)()
}
178595
def render_data(context, templateContent, proxyMode, rendered_data, menukey='menubar'):
    """"""

    if proxyMode:
        # Update csrf_tokens
        csrf = unicode(context['csrf_token'])
        tag = u'{~__PLUGIT_CSRF_TOKEN__~}'
        rendered_data = unicode(rendered_data, 'utf-8').replace(tag, csrf)

        result = rendered_data  # Render in proxy mode
        menu = None  # Proxy mode plugit do not have menu

    else:
        # Render it
        template = Template(templateContent)
        result = template.render(context)
        menu = _get_node(template, context, menukey)

    return (result, menu)
34515
def system_describe_data_objects(input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/system/describeDataObjects', input_params, always_retry=always_retry, **kwargs)
690033
def render(self, rect, data):
        """"""
        size = self.get_minimum_size(data)

        # Find how much extra space we have.
        extra_width = rect.w - size.x
        extra_height = rect.h - size.y

        # Distribute the extra space into the correct rows and columns.
        if self.scaling_col is None or not 0 <= self.scaling_col < self.cols:
            width_per_col = extra_width / float(self.cols)
            col_widths = [
                width + width_per_col
                for width in self.col_widths
                ]
        else:
            col_widths = self.col_widths[:]
            col_widths[self.scaling_col] += extra_width

        if self.scaling_row is None or not 0 <= self.scaling_row < self.rows:
            height_per_row = extra_height / float(self.rows)
            row_heights = [
                height + height_per_row
                for height in self.row_heights
                ]
        else:
            row_heights = self.row_heights[:]
            row_heights[self.scaling_row] += extra_height

        # Find the (start, end) positions of each row and column.
        col_xs = []
        last_x = rect.left + self.outside_margin
        for width in col_widths:
            col_xs.append((last_x, last_x + width))
            last_x += width + self.margin
        row_ys = []
        last_y = rect.top - self.outside_margin
        for height in row_heights:
            row_ys.append((last_y, last_y - height))
            last_y -= height + self.margin

        # Now we can loop over the elements and have them rendered.
        for col, row, cols, rows, element in self.elements:
            x_start = col_xs[col][0]
            y_start = row_ys[row][0]
            x_end = col_xs[col+cols-1][1]
            y_end = row_ys[row+rows-1][1]
            element.render(datatypes.Rectangle(
                x_start, y_end, x_end-x_start, y_start-y_end
                ), data)

        # And finally we can draw the rules
        def _get_value(array, index, sign):
            """Returns the value of the index in the given array, where
            the array (like col_xs and row_ys), consists of start-end pairs
            of values."""
            if index <= 0:
                # Special case, it is the start of the first range
                return array[0][0]-self.outside_margin*sign
            elif index >= len(array):
                # Special case, it is the end of the last range
                return array[-1][1]+self.outside_margin*sign
            else:
                # Otherwise it is the blend of a start and end.
                return (array[index-1][1] + array[index][0])*0.5

        for start_col, start_row, end_col, end_row, width, color in self.rules:
            x_start = _get_value(col_xs, start_col, 1)
            y_start = _get_value(row_ys, start_row, -1)
            x_end = _get_value(col_xs, end_col, 1)
            y_end = _get_value(row_ys, end_row, -1)
            data['output'].line(
                x_start, y_start, x_end, y_end,
                stroke=color,
                stroke_width=width
                )
1246094
def _render(self, data, formula_def):
        '''
        
        '''
        # FORMULA can contain a renderer option
        renderer = formula_def.get('renderer', self.opts.get('renderer', 'jinja|yaml'))
        rend = salt.loader.render(self.opts, {})
        blacklist = self.opts.get('renderer_blacklist')
        whitelist = self.opts.get('renderer_whitelist')
        template_vars = formula_def.copy()
        template_vars['opts'] = self.opts.copy()
        return compile_template(
            ':string:',
            rend,
            renderer,
            blacklist,
            whitelist,
            input_data=data,
            **template_vars
        )
470358
def render(data, saltenv='base', sls='', argline='', **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    translate_newlines = kwargs.get('translate_newlines', False)
    return _decrypt_object(data, translate_newlines=translate_newlines)
249205
def render_to_response(self, context, **response_kwargs):
        
        serializer = GeoJSONSerializer()
        response = self.response_class(**response_kwargs)
        queryset = self.get_queryset()

        options = dict(properties=self.properties,
                       precision=self.precision,
                       simplify=self.simplify,
                       srid=self.srid,
                       geometry_field=self.geometry_field,
                       force2d=self.force2d,
                       bbox=self.bbox,
                       bbox_auto=self.bbox_auto,
                       use_natural_keys=self.use_natural_keys,
                       with_modelname=self.with_modelname)
        serializer.serialize(queryset, stream=response, ensure_ascii=False,
                             **options)
        return response
228901
def render(self, data, accepted_media_type=None, renderer_context=None):
        
        renderer_context = renderer_context or {}
        callback = self.get_callback(renderer_context)
        json = super(JSONPRenderer, self).render(data, accepted_media_type,
                                                 renderer_context)
        return callback.encode(self.charset) + b'(' + json + b');'
680117
function render(output, data, node) {
        // data is a model id
        var manager = Jupyter.notebook && Jupyter.notebook.kernel && Jupyter.notebook.kernel.widget_manager;
        if (!manager) {
            node.textContent = "Error rendering Jupyter widget: missing widget manager";
            return;
        }

        // Missing model id means the view was removed. Hide this element.
        if (data.model_id === '') {
            node.style.display = 'none';
            return;
        }

        var model = manager.get_model(data.model_id);
        if (model) {
            model.then(function(model) {
                return manager.display_model(void 0, model, {output: output});
            }).then(function(view) {
                var id = view.cid;
                output._jupyterWidgetViews = output._jupyterWidgetViews || [];
                output._jupyterWidgetViews.push(id);
                views[id] = view;
                PhosphorWidget.Widget.attach(view.pWidget, node);

                // Make the node completely disappear if the view is removed.
                view.once('remove', () => {
                    // Since we have a mutable reference to the data, delete the
                    // model id to indicate the view is removed.
                    data.model_id = '';
                    node.style.display = 'none';
                })
            });
        } else {
            node.textContent = 'A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.';
        }
    }
185836
def outputdata(self, data):
        
        if not isinstance(data, bytes):
            data = str(data).encode(self.encoding)
        self.output(MemoryStream(data))
557777
def render(name, data):
        """"""
        # this raises OverflowError if Py_ssize_t can't handle the atom data
        size = len(data) + 8
        if size <= 0xFFFFFFFF:
            return struct.pack(">I4s", size, name) + data
        else:
            return struct.pack(">I4sQ", 1, name, size + 8) + data