Пример #1
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))
Пример #2
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))
Пример #3
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))
Пример #4
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))
Пример #5
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)
Пример #6
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))
Пример #7
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)
Пример #8
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)