How to use the schematics.types.ListType function in schematics

To help you get started, we’ve selected a few schematics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PermaData / rill / rill / engine / types.py View on Github external
SchematicsTypeHandler.register_type(bytes,
                                        schematics.types.StringType)
    SchematicsTypeHandler.register_type(decimal.Decimal,
                                        schematics.types.DecimalType)
    SchematicsTypeHandler.register_type(datetime.datetime,
                                        schematics.types.DateTimeType)
    SchematicsTypeHandler.register_type(datetime.date,
                                        schematics.types.DateType)
    # FIXME: create a schematics NoneType?
    # SchematicsTypeHandler.register_type(NoneType,
    #                                     schematics.types.BaseType)

    # compound types

    SchematicsTypeHandler.register_type(list,
                                        schematics.types.ListType(
                                            schematics.types.BaseType))

    SchematicsTypeHandler.register_type(tuple,
                                        schematics.types.ListType(
                                            schematics.types.BaseType))
github onicagroup / runway / runway / cfngin / config / __init__.py View on Github external
required = BooleanType(default=True)


class Target(Model):
    """Target model.

    Attributes:
        name (StringType)
        required_by (ListType)
        requires (ListType)

    """

    name = StringType(required=True)
    required_by = ListType(StringType, serialize_when_none=False)
    requires = ListType(StringType, serialize_when_none=False)


class Stack(Model):
    """Stack model.

    Attributes:
        class_path (StringType)
        description (StringType)
        enabled (BooleanType)
        in_progress_behavior (StringType)
        locked (BooleanType)
        name (StringType)
        parameters (DictType)
        profile (StringType)
        protected (BooleanType)
        region (StringType)
github stanfordnqp / spins-b / spins / invdes / problem_graph / optplan / schema_em.py View on Github external
eps_fg: Foreground permittivity.
        eps_bg: Background permittivity.
        mesh: Meshing information. This describes how the simulation region
            should be meshed.
        sim_region: Rectangular prism simulation domain.
        selection_matrix_type: The type of selection matrix to form. This
            is subject to change.
    """
    type = schema_utils.polymorphic_model_type("simulation_space")
    eps_fg = types.PolyModelType(EpsilonSpec)
    eps_bg = types.PolyModelType(EpsilonSpec)
    mesh = types.PolyModelType(MESH_TYPES)
    sim_region = types.ModelType(optplan.Box3d)
    boundary_conditions = types.ListType(
        types.PolyModelType(BOUNDARY_CONDITION_TYPES), min_size=6, max_size=6)
    pml_thickness = types.ListType(types.IntType(), min_size=6, max_size=6)
    selection_matrix_type = types.StringType(
        default=SelectionMatrixType.DIRECT.value,
        choices=tuple(select_type.value for select_type in SelectionMatrixType),
    )


@optplan.register_node_type()
class WaveguideMode(optplan.ProblemGraphNode):
    """Represents basic information for a waveguide mode.

    This class is not intended to be instantiable.

    Attributes:
        center: Waveguide center.
        extents: Width and height of waveguide mode region.
        normal: Normal direction of the waveguide. Note that this is also the
github cloudtools / stacker / stacker / config / __init__.py View on Github external
stacker_bucket_region = StringType(serialize_when_none=False)

    stacker_cache_dir = StringType(serialize_when_none=False)

    sys_path = StringType(serialize_when_none=False)

    package_sources = ModelType(PackageSources, serialize_when_none=False)

    service_role = StringType(serialize_when_none=False)

    pre_build = ListType(ModelType(Hook), serialize_when_none=False)

    post_build = ListType(ModelType(Hook), serialize_when_none=False)

    pre_destroy = ListType(ModelType(Hook), serialize_when_none=False)

    post_destroy = ListType(ModelType(Hook), serialize_when_none=False)

    tags = DictType(StringType, serialize_when_none=False)

    template_indent = StringType(serialize_when_none=False)

    mappings = DictType(
        DictType(DictType(StringType)), serialize_when_none=False)

    lookups = DictType(StringType, serialize_when_none=False)

    targets = ListType(
        ModelType(Target), serialize_when_none=False)

    stacks = ListType(
github onicagroup / runway / runway / cfngin / config / __init__.py View on Github external
namespace_delimiter = StringType(serialize_when_none=False)
    package_sources = ModelType(PackageSources, serialize_when_none=False)
    persistent_graph_key = StringType(serialize_when_none=False)
    post_build = ListType(ModelType(Hook), serialize_when_none=False)
    post_destroy = ListType(ModelType(Hook), serialize_when_none=False)
    pre_build = ListType(ModelType(Hook), serialize_when_none=False)
    pre_destroy = ListType(ModelType(Hook), serialize_when_none=False)
    service_role = StringType(serialize_when_none=False)
    stacker_bucket = StringType(serialize_when_none=False)
    stacker_bucket_region = StringType(serialize_when_none=False)
    stacker_cache_dir = StringType(serialize_when_none=False)
    stacks = ListType(
        ModelType(Stack), default=[])
    sys_path = StringType(serialize_when_none=False)
    tags = DictType(StringType, serialize_when_none=False)
    targets = ListType(
        ModelType(Target), serialize_when_none=False)
    template_indent = StringType(serialize_when_none=False)

    def __init__(self, raw_data=None, trusted_data=None,
                 deserialize_mapping=None, init=True, partial=True,
                 strict=True, validate=False, app_data=None, lazy=False,
                 **kwargs):
        """Extend functionality of the parent class.

        Manipulation here allows us to _clone_ the values of legacy stacker
        field into their new names. Doing so we can retain support for Stacker
        configs and CFNgin configs.

        """
        if raw_data:  # this can be empty when running unittests
            for field_suffix in ['bucket', 'bucket_region', 'cache_dir']:
github brianz / serverless-design-patterns / ch2 / serverless / cupping / models / cupping.py View on Github external
class ScoresType(DictType):
    def validate_nonempty(self, value):
        if not value:
            raise ValidationError('This field is required.')
        return value


class CuppingModel(Model):
    id = IntType()
    session_id = IntType()
    name = StringType(max_length=128, min_length=1, required=True)
    scores = ScoresType(DecimalType, required=True)
    overall_score = DecimalType(required=True, min_value=0, max_value=100,
            serialized_name='overallScore')
    descriptors = ListType(StringType)
    defects = ListType(StringType)
    notes = StringType()
    is_sample = BooleanType(default=False, serialized_name='isSample')

    @staticmethod
    def from_row(cupping):
        attrs = {k: v for k, v in cupping.__dict__.items() if not k.startswith('_')}
        return CuppingModel(attrs, strict=False)
github iterait / shepherd / shepherd / sheep / base_sheep.py View on Github external
import zmq.asyncio
from zmq.error import ZMQBaseError
from schematics import Model
from schematics.types import StringType, IntType, ListType


class BaseSheep(metaclass=abc.ABCMeta):
    """
    A base class for container adapters - classes that allow launching different kinds of containers.
    """

    class Config(Model):
        type: str = StringType(required=True)
        port: int = IntType(required=True)
        devices: List[str] = ListType(StringType, default=lambda: [])

    _config: Config

    def __init__(self, socket: zmq.asyncio.Socket, sheep_data_root: str):
        """
        Create new :py:class:`BaseSheep`.

        :param socket: socket for feeding sheep's runner with InputMessages
        :param sheep_data_root: sheep data root with job working directories
        """
        self._config: Optional[self.Config] = None
        self.socket: zmq.asyncio.Socket = socket
        self.jobs_queue: Queue = Queue()  # queue of jobs to be processed
        self.model_name: Optional[str] = None  # current model name
        self.model_version: Optional[str] = None  # current model version
        self.sheep_data_root: Optional[str] = sheep_data_root
github apt-itude / rules_pip / src / piprules / lockfile.py View on Github external
import errno
import json
import logging
import os
import sys

import schematics

from piprules import util


LOG = logging.getLogger(__name__)


class _SortedListType(schematics.types.ListType):

    def convert(self, value, context=None):
        value = super(_SortedListType, self).convert(value, context=context)
        return sorted(value)


class Requirement(schematics.models.Model):

    version = schematics.types.StringType(required=True)
    is_direct = schematics.types.BooleanType(required=True)
    source = schematics.types.StringType(required=True)
    dependencies = _SortedListType(
        schematics.types.StringType,
        default=[],
    )
github cloudtools / stacker / stacker / config / __init__.py View on Github external
namespace_delimiter = StringType(serialize_when_none=False)

    stacker_bucket = StringType(serialize_when_none=False)

    stacker_bucket_region = StringType(serialize_when_none=False)

    stacker_cache_dir = StringType(serialize_when_none=False)

    sys_path = StringType(serialize_when_none=False)

    package_sources = ModelType(PackageSources, serialize_when_none=False)

    service_role = StringType(serialize_when_none=False)

    pre_build = ListType(ModelType(Hook), serialize_when_none=False)

    post_build = ListType(ModelType(Hook), serialize_when_none=False)

    pre_destroy = ListType(ModelType(Hook), serialize_when_none=False)

    post_destroy = ListType(ModelType(Hook), serialize_when_none=False)

    tags = DictType(StringType, serialize_when_none=False)

    template_indent = StringType(serialize_when_none=False)

    mappings = DictType(
        DictType(DictType(StringType)), serialize_when_none=False)

    lookups = DictType(StringType, serialize_when_none=False)