Source code for plynx.demo.types

"""PLynx Operations defined as python code. Produce basic types."""
import math

import plynx.node





@plynx.node.output(name='int', var_type=int)
@plynx.node.output(name='str', var_type=str)
@plynx.node.output(name='dict', var_type=dict)
@plynx.node.output(name='float', var_type=float)
@plynx.node.output(name='bool', var_type=bool)
@plynx.node.output(name='color', var_type="color")
@plynx.node.operation(
    title="All types",
    description="Echo all types",
[docs]) def all_types(): """Make basic values for each type.""" return { "int": 42, "str": "Hello world", "dict": {"foo": "woo"}, "float": math.pi, "bool": True, "color": "#FF0000",
} @plynx.node.input(name='value', var_type=int) @plynx.node.operation( title="Print Int value", @plynx.node.input(name='value', var_type=str) @plynx.node.operation( title="Print String value", @plynx.node.input(name='value', var_type=dict) @plynx.node.operation( title="Print Dict value", @plynx.node.input(name='value', var_type=float) @plynx.node.operation( title="Print Float value", @plynx.node.input(name='value', var_type=bool) @plynx.node.operation( title="Print Bool value", @plynx.node.input(name='value', var_type="color") @plynx.node.operation( title="Print Color value", @plynx.node.input(name='value', var_type="py-json-file") @plynx.node.output(name='value', var_type=dict) @plynx.node.operation( title="File to Dict",
[docs]) def file_to_dict(value): """Transform file object to dict""" return { "value": value,
} @plynx.node.input(name='value', var_type=dict) @plynx.node.output(name='value', var_type="py-json-file") @plynx.node.operation( title="Dict to File",
[docs]) def dict_to_file(value): """transform dict to file object""" return { "value": value,
}
[docs]GROUP = plynx.node.utils.Group( title="Test Python built-in types", items=[ all_types, print_int, print_str, print_dict, print_float, print_bool, print_color, file_to_dict, dict_to_file,
] )