Exemplo n.º 1
0
class FixedFunc(FormatFunc):
    """``[0.1.6]/textrenderer.ts#L365``"""

    _model_name = T.Unicode("FixedFuncModel").tag(sync=True)

    digits = T.Int().tag(sync=True)
    missing = T.Unicode().tag(sync=True)
Exemplo n.º 2
0
class FormatFunc(WXYZBase):
    """ [0.1.6]/textrenderer.ts#L308
    """

    _model_module = T.Unicode(module_name).tag(sync=True)
    _model_module_version = T.Unicode(module_version).tag(sync=True)
    _view_module = T.Unicode(module_name).tag(sync=True)
    _view_module_version = T.Unicode(module_version).tag(sync=True)

    _model_name = T.Unicode("FormatFuncModel").tag(sync=True)
Exemplo n.º 3
0
class StyleGrid(DataGrid):
    """A styled grid

    ``[0.1.6]/datagrid.ts#L64``
    """

    # pylint: disable=no-member

    _model_name = T.Unicode("StyleGridModel").tag(sync=True)
    _view_name = T.Unicode("StyleGridView").tag(sync=True)

    row_size = T.Int().tag(sync=True)
    column_size = T.Int().tag(sync=True)
    row_header_size = T.Int().tag(sync=True)
    column_header_size = T.Int().tag(sync=True)

    header_visibility = T.Enum(
        ["all", "row", "column", "none"], default_value="all"
    ).tag(sync=True)

    grid_style = W.trait_types.InstanceDict(GridStyle).tag(
        sync=True, **W.widget_serialization
    )

    cell_renderers = T.List(T.Instance(CellRenderer)).tag(
        sync=True, **W.widget_serialization
    )
Exemplo n.º 4
0
class TextRenderer(CellRenderer):
    """``[0.1.6]/textrenderer.ts#L21``"""

    _model_name = T.Unicode("TextRendererModel").tag(sync=True)

    format_func = T.Instance(FormatFunc, allow_none=True).tag(
        sync=True, **W.widget_serialization
    )

    background_color = EmptyAlphaColor("").tag(sync=True)
    font = T.Unicode("12px sans-serif").tag(sync=True)
    horizontal_alignment = T.Unicode("left").tag(sync=True)
    text_color = AlphaColor("#000000").tag(sync=True)
    vertical_alignment = T.Unicode("center").tag(sync=True)
Exemplo n.º 5
0
class Expand(Fn, JSONLDBase):
    """Expand a JSON document to a list of nodes"""

    _model_name = T.Unicode("ExpandModel").tag(sync=True)

    source = T.Dict(allow_none=True).tag(sync=True)
    expand_context = T.Dict(allow_none=True).tag(sync=True)
    value = T.List(allow_none=True).tag(sync=True)

    _observed_traits = ["source", "expand_context"]

    def the_function(self, source, expand_context):
        """actually expand"""
        return jsonld.expand(source, dict(expandContext=expand_context))
Exemplo n.º 6
0
class JSONE(Fn, JSONEBase):
    """Transform a JSON document"""

    _model_name = T.Unicode("JSONEModel").tag(sync=True)

    source = T.Any(allow_none=True).tag(sync=True)
    context = T.Any(allow_none=True).tag(sync=True)
    value = T.Any(allow_none=True).tag(sync=True)

    _observed_traits = ["source", "context"]

    def the_function(self, source, context):
        """actually render"""
        return jsone.render(deepcopy(source), deepcopy(context))
Exemplo n.º 7
0
class Frame(Fn, JSONLDBase):
    """Frame a JSON document"""

    _model_name = T.Unicode("FrameModel").tag(sync=True)

    source = T.Dict(allow_none=True).tag(sync=True)
    frame = T.Dict(allow_none=True).tag(sync=True)
    expand_context = T.Dict(allow_none=True).tag(sync=True)

    value = T.Dict(allow_none=True).tag(sync=True)

    _observed_traits = ["source", "frame", "expand_context"]

    def the_function(self, source, frame, expand_context):
        """actually frame"""
        return jsonld.frame(source, frame, dict(expandContext=expand_context))
Exemplo n.º 8
0
class Flatten(Fn, JSONLDBase):
    """Flatten a JSON document to a flat graph"""

    _model_name = T.Unicode("FlattenModel").tag(sync=True)

    source = T.Dict(allow_none=True).tag(sync=True)
    context = T.Dict(allow_none=True).tag(sync=True)
    expand_context = T.Dict(allow_none=True).tag(sync=True)

    value = T.Dict(allow_none=True).tag(sync=True)

    _observed_traits = ["source", "context", "expand_context"]

    def the_function(self, source, context, expand_context):
        """actually flatten"""
        return jsonld.flatten(source, context,
                              dict(expandContext=expand_context))
Exemplo n.º 9
0
class Compact(Fn, JSONLDBase):
    """Compact a JSON document with a context"""

    _model_name = T.Unicode("CompactModel").tag(sync=True)

    source = T.Dict(allow_none=True).tag(sync=True)
    context = T.Dict(allow_none=True).tag(sync=True)
    expand_context = T.Dict(allow_none=True).tag(sync=True)

    value = T.Dict(allow_none=True).tag(sync=True)

    _observed_traits = ["source", "context", "expand_context"]

    def the_function(self, source, context, expand_context):
        """actually compact"""
        return jsonld.compact(source, context,
                              dict(expandContext=expand_context))
Exemplo n.º 10
0
class Template(Fn, JinjaBase):
    """Transforms text source into text output with a given context"""

    _model_name = T.Unicode("TemplateModel").tag(sync=True)

    context = T.Union([T.Dict(), T.Instance(W.Widget)],
                      allow_none=True).tag(sync=True, **W.widget_serialization)

    _observed_traits = ["source", "context"]

    @T.observe("context")
    def _context_changed(self, *_):
        """handle connecting to widgets"""
        if self.context and self.context.observe:
            self.context.observe(self.the_observer)

    def the_function(self, source, context):
        """render a source given a context"""
        return jinja2.Template(source).render(context)
Exemplo n.º 11
0
class CellRenderer(DataGridBase):
    """``[0.1.6]/cellrenderer.ts#L29``"""

    _model_module = T.Unicode(module_name).tag(sync=True)
    _model_module_version = T.Unicode(module_version).tag(sync=True)
    _view_module = T.Unicode(module_name).tag(sync=True)
    _view_module_version = T.Unicode(module_version).tag(sync=True)
    _model_name = T.Unicode("CellRendererModel").tag(sync=True)

    region = T.Unicode("body").tag(sync=True)
    metadata = T.Dict().tag(sync=True)
Exemplo n.º 12
0
class StyleGrid(DataGrid):
    """ A styled grid
        [0.1.6]/datagrid.ts#L64
    """

    _model_name = T.Unicode("StyleGridModel").tag(sync=True)
    _view_name = T.Unicode("StyleGridView").tag(sync=True)

    row_size = T.Int().tag(sync=True)
    column_size = T.Int().tag(sync=True)
    row_header_size = T.Int().tag(sync=True)
    column_header_size = T.Int().tag(sync=True)

    void_color = AlphaColor("#F3F3F3").tag(sync=True)
    background_color = AlphaColor("#FFFFFF").tag(sync=True)
    grid_line_color = AlphaColor("rgba(20, 20, 20, 0.15)").tag(sync=True)
    header_background_color = AlphaColor("#F3F3F3").tag(sync=True)
    header_grid_line_color = AlphaColor("rgba(20, 20, 20, 0.25)").tag(sync=True)

    cell_renderers = T.List(T.Instance(CellRenderer)).tag(
        sync=True, **W.widget_serialization
    )
Exemplo n.º 13
0
class Normalize(Fn, JSONLDBase):
    """Normalize a JSON document"""

    _model_name = T.Unicode("NormalizeModel").tag(sync=True)

    _observed_traits = ["source", "frame", "expand_context"]

    source = T.Dict(allow_none=True).tag(sync=True)
    expand_context = T.Dict(allow_none=True).tag(sync=True)
    format = T.Unicode(default_value="application/n-quads",
                       allow_none=True).tag(sync=True)

    value = T.Union([T.Dict(allow_none=True),
                     T.Unicode(allow_none=True)]).tag(sync=True)

    _observed_traits = ["source", "format", "expand_context"]

    def the_function(self, source, format, expand_context):
        """actually normalize"""
        return jsonld.normalize(
            source, dict(expandContext=expand_context, format=format))
Exemplo n.º 14
0
class GridStyle(W.Widget):
    """JSON-compatible Lumino `DataGrid` styles."""

    # pylint: disable=C0301
    _model_name = T.Unicode("GridStyleModel").tag(sync=True)
    _model_module = T.Unicode(module_name).tag(sync=True)
    _model_module_version = T.Unicode(module_version).tag(sync=True)

    # the part between these comments will be rewritten
    # BEGIN SCHEMAGEN:TRAITS IDataGridStyles @b911858621aef508319fec6b6d1cbe8afeeb8ffafe0646c0083d9491e3277e78
    backgroundColor = T.Unicode(
        help="""The background color for the body cells.

This color is layered on top of the `voidColor`.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    columnBackgroundColor = T.Union(
        [T.Tuple(), T.Enum([None])], allow_none=True, default_value=None
    ).tag(sync=True)
    cursorBorderColor = T.Unicode(
        help="""The border color for the cursor.""", allow_none=True, default_value=None
    ).tag(sync=True)
    cursorFillColor = T.Unicode(
        help="""The fill color for the cursor.""", allow_none=True, default_value=None
    ).tag(sync=True)
    gridLineColor = T.Unicode(
        help="""The color for the grid lines of the body cells.

The grid lines are draw on top of the cell contents.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerBackgroundColor = T.Unicode(
        help="""The background color for the header cells.

This color is layered on top of the `voidColor`.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerGridLineColor = T.Unicode(
        help="""The color for the grid lines of the header cells.

The grid lines are draw on top of the cell contents.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerHorizontalGridLineColor = T.Unicode(
        help="""The color for the horizontal grid lines of the header cells.

This overrides the `headerGridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerSelectionBorderColor = T.Unicode(
        help="""The border color for a header selection.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerSelectionFillColor = T.Unicode(
        help="""The fill color for a header selection.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerVerticalGridLineColor = T.Unicode(
        help="""The color for the vertical grid lines of the header cells.

This overrides the `headerGridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    horizontalGridLineColor = T.Unicode(
        help="""The color for the horizontal grid lines of the body cells.

This overrides the `gridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    rowBackgroundColor = T.Union(
        [T.Tuple(), T.Enum([None])],
        help="""Realized as a functor, a single value will affect all rows, while any other value will be return modulo the position.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    scrollShadow = T.Dict(
        help="""The drop shadow effect when the grid is scrolled.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    selectionBorderColor = T.Unicode(
        help="""The border color for a selection.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    selectionFillColor = T.Unicode(
        help="""The fill color for a selection.""", allow_none=True, default_value=None
    ).tag(sync=True)
    verticalGridLineColor = T.Unicode(
        help="""The color for the vertical grid lines of the body cells.

This overrides the `gridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    voidColor = T.Unicode(
        help="""The void color for the data grid.

This is the base fill color for the entire data grid.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
Exemplo n.º 15
0
class FormatFunc(DataGridBase):
    """``[0.1.6]/textrenderer.ts#L308``"""

    _model_name = T.Unicode("FormatFuncModel").tag(sync=True)