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))
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)
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)
class VectorVariableSchema(VariableSchemaBase): varnames = SequenceSchema( SchemaNode(String()), read_only=True ) variables = SequenceSchema( GeneralGnomeObjectSchema( acceptable_schemas=[VariableSchema, base_schema.ObjTypeSchema] ), save_reference=True )
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)
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)
class IceImageSchema(BaseOutputterSchema): ice_movers = SequenceSchema( GeneralGnomeObjectSchema(acceptable_schemas=[IceMoverSchema]), save=True, update=True, save_reference=True) '''
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)
class SubstanceSchema(ObjTypeSchema): initializers = SequenceSchema( GeneralGnomeObjectSchema( acceptable_schemas=[InitWindagesSchema, DistributionBaseSchema ] ), save=True, update=True, save_reference=True ) is_weatherable = SchemaNode(Boolean(), read_only=True)
class CurrentJsonSchema(BaseOutputterSchema): current_movers = SequenceSchema( GeneralGnomeObjectSchema(acceptable_schemas=[ CatsMoverSchema, ComponentMoverSchema, GridCurrentMoverSchema, CurrentCycleMoverSchema, WindMoverSchema ]), save=True, update=True, save_reference=True) '''
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)
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) ) )
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)
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]
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]
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)
class SpillJsonSchema(BaseOutputterSchema): _additional_data = SequenceSchema(SchemaNode(String()), missing=drop, save=True, update=True)