Exemplo n.º 1
0
class TemperatureTSSchema(PropertySchema):
    timeseries = SequenceSchema(
        TupleSchema(children=[
            SchemaNode(DateTime(default_tzinfo=None), missing=drop),
            SchemaNode(Float(), missing=0)
        ],
                    missing=drop))
    varnames = SequenceSchema(SchemaNode(String(), missing=drop))
Exemplo n.º 2
0
def _validate_list_schema(schema: SequenceSchema, cstruct: list, request: Request, location="body"):
    if location != "body":  # for now we only support location == body
        return
    child_cstructs = schema.cstruct_children(cstruct)
    try:
        request.validated = schema.deserialize(child_cstructs)
    except Invalid as err:
        _add_colander_invalid_error_to_request(err, request, location)
Exemplo n.º 3
0
class TimeSeriesPropSchema(PropertySchema):
    time = TimeSchema(missing=drop)
    data = SequenceSchema(SchemaNode(Float()), missing=drop)
    timeseries = SequenceSchema(TupleSchema(children=[
        SchemaNode(DateTime(default_tzinfo=None), missing=drop),
        SchemaNode(Float(), missing=0)
    ],
                                            missing=drop),
                                missing=drop)
Exemplo n.º 4
0
class VectorVariableSchema(VariableSchemaBase):
    varnames = SequenceSchema(
        SchemaNode(String()),
        read_only=True
    )
    variables = SequenceSchema(
        GeneralGnomeObjectSchema(
            acceptable_schemas=[VariableSchema, base_schema.ObjTypeSchema]
        ), save_reference=True
    )
Exemplo n.º 5
0
def _validate_list_schema(schema: SequenceSchema,
                          cstruct: list,
                          request: Request,
                          location='body'):
    if location != 'body':  # for now we only support location == body
        return
    child_cstructs = schema.cstruct_children(cstruct)
    try:
        request.validated = schema.deserialize(child_cstructs)
    except Invalid as err:
        _add_colander_invalid_error_to_request(err, request, location)
Exemplo n.º 6
0
class TSVectorPropSchema(VectorPropSchema):
    timeseries = SequenceSchema(TupleSchema(children=[
        SchemaNode(DateTime(default_tzinfo=None), missing=drop),
        TupleSchema(children=[
            SchemaNode(Float(), missing=0),
            SchemaNode(Float(), missing=0)
        ])
    ],
                                            missing=drop),
                                missing=drop)
    #     variables = SequenceSchema(TupleSchema(SchemaNode(Float())))
    varnames = SequenceSchema(SchemaNode(String(), missing=drop), missing=drop)
Exemplo n.º 7
0
class IceImageSchema(BaseOutputterSchema):
    ice_movers = SequenceSchema(
        GeneralGnomeObjectSchema(acceptable_schemas=[IceMoverSchema]),
        save=True,
        update=True,
        save_reference=True)
    '''
Exemplo n.º 8
0
class TimeseriesVectorSchema(base_schema.ObjTypeSchema):
    units = SchemaNode(String(), missing=drop, save=True, update=True)
    time = TimeSchema(save=True, update=True, save_reference=True)
    variables = SequenceSchema(TimeseriesDataSchema(),
                               save=True,
                               update=True,
                               save_reference=True)
Exemplo n.º 9
0
class SubstanceSchema(ObjTypeSchema):
    initializers = SequenceSchema(
        GeneralGnomeObjectSchema(
            acceptable_schemas=[InitWindagesSchema,
                                DistributionBaseSchema
                                ]
        ),
        save=True, update=True, save_reference=True
    )
    is_weatherable = SchemaNode(Boolean(), read_only=True)
Exemplo n.º 10
0
class CurrentJsonSchema(BaseOutputterSchema):
    current_movers = SequenceSchema(
        GeneralGnomeObjectSchema(acceptable_schemas=[
            CatsMoverSchema, ComponentMoverSchema, GridCurrentMoverSchema,
            CurrentCycleMoverSchema, WindMoverSchema
        ]),
        save=True,
        update=True,
        save_reference=True)
    '''
Exemplo n.º 11
0
class ElementTypeSchema(base_schema.ObjTypeSchema):
    def __init__(self, unknown='preserve', *args, **kwargs):
        super(ElementTypeSchema, self).__init__(*args, **kwargs)
        self.typ = base_schema.ObjType('preserve')

    initializers = SequenceSchema(GeneralGnomeObjectSchema(
        acceptable_schemas=[InitWindagesSchema, DistributionBaseSchema]),
                                  save=True,
                                  update=True,
                                  save_reference=True)
    standard_density = SchemaNode(Float(), read_only=True)
Exemplo n.º 12
0
class TimeSchema(base_schema.ObjTypeSchema):
    filename = FilenameSchema(
        isdatafile=True, test_equal=False, update=False
    )
    varname = SchemaNode(
        String(), read_only=True
    )
    data = SequenceSchema(
        SchemaNode(
            DateTime(default_tzinfo=None)
        )
    )
Exemplo n.º 13
0
class GridVectorPropSchema(VectorPropSchema):
    varnames = SequenceSchema(SchemaNode(String()))
    grid = PyGridSchema(missing=drop)
    data_file = SchemaNode(typ=Sequence(accept_scalar=True),
                           children=[SchemaNode(String())])
    grid_file = SchemaNode(typ=Sequence(accept_scalar=True),
                           children=[SchemaNode(String())])

    def __init__(self, json_='webapi', *args, **kwargs):
        if json_ == 'save':
            self.add(
                SchemaNode(typ=Sequence(),
                           children=[SchemaNode(EnvProp())],
                           name='variables'))
        super(GridVectorPropSchema, self).__init__(*args, **kwargs)
Exemplo n.º 14
0
def add_sequence_node(schema, sequence_node, single_key, plural_key=None, with_filter_by=False):
    if not sequence_node.name:
        sequence_node = sequence_node.clone(name=single_key)

    if with_filter_by:
        sequence_node = set_node_with_filter_by(sequence_node)

    single_node = SequenceSchema(Sequence(), sequence_node, missing=drop, name=single_key)
    schema.__class_schema_nodes__.append(single_node)
    schema.__all_schema_nodes__.append(single_node)

    if plural_key:
        if not sequence_node.name:
            sequence_node = sequence_node.clone(name=plural_key)

        plural_node = SequenceSchema(
            Sequence(),
            sequence_node,
            missing=drop,
            preparer=split_values,
            name=plural_key)
        schema.__class_schema_nodes__.append(plural_node)
        schema.__all_schema_nodes__.append(plural_node)

        sequence_finisher = SequenceFinisher(single_key, plural_key)
        if hasattr(schema, 'finisher'):
            if not is_nonstr_iter(schema.finisher):
                previous_finisher = schema.finisher
                def decorator(cls, appstruct):
                    appstruct = sequence_finisher(cls, appstruct)
                    return previous_finisher(cls, appstruct)
                schema.finisher = decorator
            else:
                schema.finisher.append(sequence_finisher)
        else:
            schema.finisher = [sequence_finisher]
Exemplo n.º 15
0
class PaginationInput(MappingSchema):
    page = PAGE.clone(missing=1)
    limit_per_page = LIMIT_PER_PAGE.clone(missing=20)
    order_by = SequenceSchema(Sequence(), ORDER_BY, missing=drop, preparer=split_values)
    finisher = [OrderFinisher]
Exemplo n.º 16
0
class PropertySchema(base_schema.ObjType):
    name = SchemaNode(String(), missing='default')
    units = SchemaNode(typ=Sequence(accept_scalar=True), children=[SchemaNode(String(), missing=drop), SchemaNode(String(), missing=drop)])
    time = SequenceSchema(SchemaNode(DateTime(default_tzinfo=None), missing=drop), missing=drop)
Exemplo n.º 17
0
class SpillJsonSchema(BaseOutputterSchema):
    _additional_data = SequenceSchema(SchemaNode(String()),
                                      missing=drop,
                                      save=True,
                                      update=True)