示例#1
0
class TriangleSchema(colander.Schema):
    a = colander.SchemaNode(colander.Float(),
                            validator=colander.Range(
                                min=0, min_err='Side length must be positive'),
                            default=5)
    b = colander.SchemaNode(colander.Float(),
                            validator=colander.Range(
                                min=0, min_err='Side length must be positive'),
                            default=5)
    theta = colander.SchemaNode(
        colander.Float(),
        validator=colander.Range(
            min=0,
            max=180,
            min_err='Angle must be positive',
            max_err='Angle must be less than 180 degrees'),
        default=45)
    label_a = colander.SchemaNode(colander.String(), missing='')
    label_b = colander.SchemaNode(colander.String(), missing='')
    label_c = colander.SchemaNode(colander.String(), missing='')
    label_angle_A = colander.SchemaNode(colander.String(), missing='')
    label_angle_B = colander.SchemaNode(colander.String(), missing='')
    label_angle_C = colander.SchemaNode(colander.String(), missing='')
    show_angle_A = colander.SchemaNode(
        colander.Bool(),
        widget=FancyCheckboxInput(label='Render Angle (A)'),
        default=True)
    show_angle_B = colander.SchemaNode(
        colander.Bool(),
        widget=FancyCheckboxInput(label='Render Angle (B)'),
        default=True)
    show_angle_C = colander.SchemaNode(
        colander.Bool(),
        widget=FancyCheckboxInput(label='Render Angle (C)'),
        default=True)
示例#2
0
class SkipForm(colander.MappingSchema):
    skip_type = colander.SchemaNode(colander.String(encoding='utf-8'),
                                    title="Skip Type",
                                    description="A to Z",
                                    validator=deferred_skip_type_validator)
    small_length = colander.SchemaNode(colander.Float(),
                                       title="Small Length (m)")
    large_length = colander.SchemaNode(colander.Float(),
                                       title="Large Length (m)")
    small_breadth = colander.SchemaNode(colander.Float(),
                                        title="Small Breadth (m)")
    large_breadth = colander.SchemaNode(colander.Float(),
                                        title="Large Breadth (m)")

    def validator(self, node, value):
        exc = colander.Invalid(node, "")
        valid = True
        if value['small_length'] > value['large_length']:
            valid = False
            exc['small_length'] = "The small length must be less than the " \
                                  "large length"

        if value['small_breadth'] > value['large_breadth']:
            valid = False
            exc['small_breadth'] = "The small breadth must be less than the " \
                                   "large breadth"

        if not valid:
            raise exc
示例#3
0
 class venue(colander.MappingSchema):
     # city = colander.SchemaNode(colander.String())
     lon = colander.SchemaNode(colander.Float())
     repinned = colander.SchemaNode(colander.Boolean())
     lat = colander.SchemaNode(colander.Float())
     id = colander.SchemaNode(colander.Float())
     name = colander.SchemaNode(colander.String())
示例#4
0
class LBFGSBParametersSchema(StrictMappingSchema):

    """Parameters for the L-BFGS-B optimizer.

    See :class:`moe.optimal_learning.python.python_version.optimization.LBFGSBParameters`

    """

    approx_grad = colander.SchemaNode(
            colander.Boolean(),
            )
    max_func_evals = colander.SchemaNode(
            colander.Int(),
            validator=colander.Range(min=1),
            )
    max_metric_correc = colander.SchemaNode(
            colander.Int(),
            validator=colander.Range(min=1),
            )
    factr = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=1.0),
            )
    pgtol = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=0.0),
            )
    epsilon = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=0.0),
            )
示例#5
0
class NewtonParametersSchema(StrictMappingSchema):

    """Parameters for the newton optimizer.

    See :class:`moe.optimal_learning.python.cpp_wrappers.optimization.NewtonParameters`

    """

    max_num_steps = colander.SchemaNode(
            colander.Int(),
            validator=colander.Range(min=1),
            )
    gamma = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=1.0),
            )
    time_factor = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=1.0e-16),
            )
    max_relative_change = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=0.0, max=1.0),
            )
    tolerance = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=0.0),
            )
示例#6
0
 def colander_literal_type(self, data_input):
     # LOGGER.debug('data input type = %s', data_input.dataType)
     if 'boolean' in data_input.dataType:
         return colander.Boolean()
     elif 'integer' in data_input.dataType:
         return colander.Integer()
     elif 'float' in data_input.dataType:
         return colander.Float()
     elif 'double' in data_input.dataType:
         return colander.Float()
     elif 'decimal' in data_input.dataType:
         return colander.Decimal()
     elif 'string' in data_input.dataType:
         return colander.String()
     elif 'dateTime' in data_input.dataType:
         return colander.DateTime()
     elif 'date' in data_input.dataType:
         return colander.Date()
     elif 'time' in data_input.dataType:
         return colander.Time()
     elif 'duration' in data_input.dataType:
         # TODO: check correct type
         # http://www.w3.org/TR/xmlschema-2/#duration
         return colander.Time()
     # guessing from default
     elif hasattr(data_input, 'defaultValue'):
         try:
             dateutil.parser.parse(data_input.defaultValue)
         except Exception:
             return colander.String()
         else:
             return colander.DateTime()
     else:
         return colander.String()
示例#7
0
class Geolocation(colander.MappingSchema):
    lon = colander.SchemaNode(colander.Float(),
                              validator=colander.Range(-180, 180),
                              missing=TOKYO_GEOLOCATION['lon'])
    lat = colander.SchemaNode(colander.Float(),
                              validator=colander.Range(-90, 90),
                              missing=TOKYO_GEOLOCATION['lat'])
示例#8
0
 def _addAnnotateSchema(self, schema):
     schema.add(colander.SchemaNode(colander.Float(),
                                    missing=0.0,
                                    name='ms_intensity_cutoff'))
     schema.add(colander.SchemaNode(colander.Float(),
                                    missing=0.0,
                                    name='msms_intensity_cutoff'))
     schema.add(colander.SchemaNode(colander.Integer(),
                                    validator=colander.Range(0, 4),
                                    name='max_broken_bonds'))
     schema.add(colander.SchemaNode(colander.Integer(),
                                    validator=colander.Range(0, 4),
                                    name='max_water_losses'))
     schema.add(colander.SchemaNode(colander.String(),
                                    missing=colander.null,
                                    validator=colander.OneOf(['pubchem',
                                                              'kegg',
                                                              'hmdb',
                                                              ]),
                                    name='structure_database'
                                    ))
     schema.add(colander.SchemaNode(colander.Integer(),
                                    missing=colander.null,
                                    validator=colander.Range(min=1),
                                    name='min_refscore'))
     schema.add(colander.SchemaNode(colander.Integer(),
                                    missing=colander.null,
                                    validator=colander.Range(min=1),
                                    name='max_mz'))
     schema.add(colander.SchemaNode(colander.Boolean(),
                                    missing=False,
                                    name='excl_halo'))
     schema.add(colander.SchemaNode(self.File(),
                                    missing=colander.null,
                                    name='ids_file'))
示例#9
0
class DemoObjSchema(base_schema.ObjTypeSchema):
    filename = FilenameSchema(
        save=True,
        update=True,
        isdatafile=True,
        test_equal=False,
    )

    foo_float = colander.SchemaNode(colander.Float(), save=True, update=True)

    foo_float_array = colander.SequenceSchema(colander.SchemaNode(
        colander.Float()),
                                              read_only=True)

    timeseries = colander.SequenceSchema(colander.TupleSchema(children=[
        colander.SchemaNode(colander.DateTime(default_tzinfo=None)),
        colander.SchemaNode(colander.Float())
    ]),
                                         read_only=True)

    variable = base_schema.GeneralGnomeObjectSchema(
        acceptable_schemas=[TimeseriesDataSchema, TimeseriesVectorSchema],
        save=True,
        update=True,
        save_reference=True,
    )

    variables = colander.SequenceSchema(base_schema.GeneralGnomeObjectSchema(
        acceptable_schemas=[TimeseriesDataSchema, TimeseriesVectorSchema]),
                                        save=True,
                                        update=True,
                                        save_reference=True)
示例#10
0
class BookMarkSchema(colander.MappingSchema):
    """
        Schema for bookmarks
    """
    type_id = colander.SchemaNode(colander.Integer(),
                                  validator=deferred_type_id_validator)
    description = colander.SchemaNode(colander.String())
    ht = colander.SchemaNode(colander.Float())
    tva = colander.SchemaNode(colander.Float())
示例#11
0
 class group(colander.MappingSchema):
     who = colander.SchemaNode(colander.String())
     join_mode = colander.SchemaNode(colander.String())
     id = colander.SchemaNode(colander.Integer())
     name = colander.SchemaNode(colander.String())
     urlname = colander.SchemaNode(colander.String())
     group_lon = colander.SchemaNode(colander.Float())
     group_lat = colander.SchemaNode(colander.Float())
     created = colander.SchemaNode(colander.Integer())
示例#12
0
 class venue(colander.MappingSchema):
     city = colander.SchemaNode(colander.String())
     lon = colander.SchemaNode(colander.Float())
     repinned = colander.SchemaNode(colander.Boolean())
     lat = colander.SchemaNode(colander.Float())
     id = colander.SchemaNode(colander.Float())
     name = colander.SchemaNode(colander.String())
     address_1 = colander.SchemaNode(colander.String())
     country = colander.SchemaNode(colander.String())
示例#13
0
class ValidPositionSchema(colander.MappingSchema, ValidatorNode):
    """A schema which validates the fields present in a position."""

    lat = colander.SchemaNode(colander.Float(),
                              missing=None,
                              validator=colander.Range(constants.MIN_LAT,
                                                       constants.MAX_LAT))
    lon = colander.SchemaNode(colander.Float(),
                              missing=None,
                              validator=colander.Range(constants.MIN_LON,
                                                       constants.MAX_LON))
class RouteView(colander.MappingSchema):

    name = colander.SchemaNode(colander.String(),
                               title="Название:",
                               validator=colander.Length(max=50))
    distance = colander.SchemaNode(colander.Float(),
                                   title="Расстояние (км):",
                                   validator=colander.Range(0, 10000))

    base_price = colander.SchemaNode(colander.Float(),
                                     title="Стоимость (грн):",
                                     validator=colander.Range(0, 1000000))
示例#15
0
class LandLordAddressView(colander.MappingSchema):
    address = colander.SchemaNode(colander.String(), title="Address:", validator=colander.Length(max=300))

    number_of_seats = colander.SchemaNode(colander.Integer(), title="Number of Seats:")   
    has_dinner = colander.SchemaNode(colander.Boolean(), title="Dinner:")
    has_language_cources = colander.SchemaNode(colander.Boolean(), title="Langeage Cources:")
    has_transfer = colander.SchemaNode(colander.Boolean(), title="Transfer:")

    additional = colander.SchemaNode(colander.String(), title="Additional:")
    price = colander.SchemaNode(colander.Float(), title="Price:")
    special_price = colander.SchemaNode(colander.Float(), title="Special Price:")
    special_price_min_num = colander.SchemaNode(colander.Integer(), title="Special Price Minimum Order Number:")
示例#16
0
class SearchRequestSchema(colander.MappingSchema):
    """Validates search query parameters."""
    lat = colander.SchemaNode(colander.Float(),
                              missing=37.7860099,
                              validator=colander.Range(-90, 90))

    lng = colander.SchemaNode(colander.Float(),
                              missing=-122.4025387,
                              validator=colander.Range(-180, 180))

    type = colander.SchemaNode(colander.String(),
                               missing="bike",
                               validator=colander.OneOf(
                                   ['bike', 'film', 'food']))
示例#17
0
class BloodPressureCrudViews(IndividualRecordCRUDView, CRUDView):
    model = BloodPressure
    schema = SQLAlchemySchemaNode(BloodPressure,
                                  includes=[
                                      'time', 'systolic', 'diastolic',
                                      colander.SchemaNode(colander.Float(),
                                                          name='heart_rate',
                                                          title='Heart rate',
                                                          missing=None)
                                  ])

    title = 'blood pressure'
    url_path = '/blood_pressure'
    list_display = ('time', 'systolic', 'diastolic', heart_rate)

    def get_list_query(self):
        query = super(BloodPressureCrudViews, self).get_list_query()

        return query.order_by(BloodPressure.time.desc())

    def dictify(self, obj):

        appstruct = super(BloodPressureCrudViews, self).dictify(obj)

        if obj.heart_rate is not None:
            appstruct['heart_rate'] = obj.heart_rate.rate

        return appstruct
 class Person(Base):
     __tablename__ = 'person'
     #Fully customised schema node
     id = Column(sqlalchemy.Integer,
                 primary_key=True,
                 info={
                     'colanderalchemy': {
                         'typ': colander.Float(),
                         'title': 'Person ID',
                         'description': 'The Person identifier.',
                         'widget': 'Empty Widget'
                     }
                 })
     #Explicitly set as a default field
     name = Column(
         sqlalchemy.Unicode(128),
         nullable=False,
         info={'colanderalchemy': {
             'default': colander.required
         }})
     #Explicitly excluded from resulting schema
     surname = Column(sqlalchemy.Unicode(128),
                      nullable=False,
                      info={'colanderalchemy': {
                          'exclude': True
                      }})
示例#19
0
class ExpenseKmConfig(ExpenseConfig):
    """
        Schema for the configuration of vehicle related expenses
    """
    amount = colander.SchemaNode(colander.Float(),
                                 title=u"Tarif",
                                 description=u"Tarif au km")
示例#20
0
class PeriodForm(colander.MappingSchema):
    id = colander.SchemaNode(colander.Integer(),
                             widget=deform.widget.HiddenWidget(),
                             missing=None)

    date = colander.SchemaNode(colander.Date())
    temperature_time = colander.SchemaNode(colander.Time(), missing=None)
    temperature = colander.SchemaNode(colander.Float(), missing=None)

    period_intensity = colander.SchemaNode(
        colander.Integer(),
        widget=deform.widget.SelectWidget(
            values=[(key, value)
                    for (key, value) in period_intensity_choices.items()]),
        missing=None)
    cervical_fluid = colander.SchemaNode(
        colander.Integer(),
        widget=deform.widget.SelectWidget(
            values=[(key, value)
                    for (key, value) in cervical_fluid_choices.items()]),
        missing=None)
    lh_surge = colander.SchemaNode(
        colander.Integer(),
        widget=deform.widget.SelectWidget(
            values=[(key, value)
                    for (key, value) in lh_surge_choices.items()]),
        missing=None)

    notes = colander.SchemaNode(colander.String(),
                                widget=deform.widget.TextAreaWidget(),
                                missing=None)
示例#21
0
class EventSchema(colander.MappingSchema):
    """Schema for new event data validation"""
    name = colander.SchemaNode(colander.String(),
                               validator=colander.Length(max=255))
    long = colander.SchemaNode(colander.Float(),
                               validator=colander.Range(-180, 180))
    lat = colander.SchemaNode(colander.Float(),
                              validator=colander.Range(-90, 90))
    description = colander.SchemaNode(colander.String(),
                                      validator=colander.Length(max=20000))
    start_date = colander.SchemaNode(colander.DateTime())
    end_date = colander.SchemaNode(colander.DateTime(), missing=colander.drop)
    main_image = colander.SchemaNode(colander.String(), missing=colander.drop)
    category = colander.SchemaNode(colander.String(),
                                   validator=colander.Length(max=255))
    tags = Tags(missing=colander.drop)
示例#22
0
class Connection(colander.MappingSchema):
    start = colander.SchemaNode(colander.String(), name='from')
    departure = colander.SchemaNode(colander.String())
    to = colander.SchemaNode(colander.String())
    arrival = colander.SchemaNode(colander.String())
    duration = colander.SchemaNode(colander.Float())
    legs = Legs()
示例#23
0
class ListOfExpectedImprovements(colander.SequenceSchema):

    """A list of floats all geq 0.0."""

    expected_improvement = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=0),
            )
示例#24
0
class ReportSearchSchema(colander.MappingSchema):
    def schema_type(self, **kw):
        return colander.Mapping(unknown='preserve')

    resource = colander.SchemaNode(StringToAppList(),
                                   validator=possible_applications_validator,
                                   missing=possible_applications)
    request_id = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                     colander.SchemaNode(colander.String()),
                                     missing=None)
    start_date = colander.SchemaNode(PermissiveDate(), missing=None)
    end_date = colander.SchemaNode(PermissiveDate(), missing=None)
    page = colander.SchemaNode(colander.Integer(),
                               validator=colander.Range(min=1),
                               missing=1)

    min_occurences = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                         colander.SchemaNode(
                                             colander.Integer()),
                                         missing=None)

    http_status = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                      colander.SchemaNode(colander.Integer()),
                                      missing=None)
    priority = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                   colander.SchemaNode(colander.Integer()),
                                   missing=None)
    error = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                colander.SchemaNode(colander.String()),
                                missing=None)
    url_path = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                   colander.SchemaNode(colander.String()),
                                   missing=None)
    url_domain = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                     colander.SchemaNode(colander.String()),
                                     missing=None)
    report_status = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                        colander.SchemaNode(colander.String()),
                                        missing=None)
    min_duration = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                       colander.SchemaNode(colander.Float()),
                                       missing=None)
    max_duration = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                       colander.SchemaNode(colander.Float()),
                                       missing=None)
示例#25
0
class ProfileSchema(colander.MappingSchema):
    applicationId = colander.SchemaNode(colander.String())
    candidateId = colander.SchemaNode(colander.Integer())
    isRetake = colander.SchemaNode(colander.Bool())
    invitationDate = colander.SchemaNode(colander.DateTime())
    applicationTime = colander.SchemaNode(colander.DateTime())
    speechToText = SpeechToTextSequence()
    videoLength = colander.SchemaNode(colander.Float())
    score = colander.SchemaNode(colander.Integer())
示例#26
0
 class Person(colander.MappingSchema):
     id = colander.SchemaNode(colander.Float(),
                              title='Person ID',
                              description='The Person identifier.',
                              missing=colander.drop,
                              widget='Empty Widget')
     name = colander.SchemaNode(colander.String(),
                                validator=colander.Length(0, 128),
                                default=colander.required)
示例#27
0
 def colander_literal_type(self, data_input):
     # LOGGER.debug('data input type = %s', data_input.dataType)
     if 'boolean' in data_input.dataType:
         return colander.Boolean()
     elif 'integer' in data_input.dataType:
         return colander.Integer()
     elif 'float' in data_input.dataType:
         return colander.Float()
     elif 'double' in data_input.dataType:
         return colander.Float()
     elif 'angle' in data_input.dataType:
         return colander.Float()
     elif 'decimal' in data_input.dataType:
         return colander.Decimal()
     elif 'string' in data_input.dataType:
         if data_input.maxOccurs > 1:
             # we are going to use a SelectWidget with multiple=True
             return colander.Set()
         elif data_input.identifier.endswith("FileUpload"):
             # we want to upload a file but just return a string containing
             # the path
             return deform.FileData()
         else:
             return colander.String()
     elif 'dateTime' in data_input.dataType:
         return colander.DateTime()
     elif 'date' in data_input.dataType:
         return colander.Date()
     elif 'time' in data_input.dataType:
         return colander.Time()
     elif 'duration' in data_input.dataType:
         # TODO: check correct type
         # http://www.w3.org/TR/xmlschema-2/#duration
         return colander.Time()
     # guessing from default
     elif hasattr(data_input, 'defaultValue'):
         try:
             dateutil.parser.parse(data_input.defaultValue)
         except Exception:
             return colander.String()
         else:
             return colander.DateTime()
     else:
         return colander.String()
示例#28
0
class RideForm(colander.MappingSchema):
    id = colander.SchemaNode(colander.Integer(),
                             widget=deform.widget.HiddenWidget(),
                             missing=None)
    equipment = colander.SchemaNode(colander.Integer(),
                                    default=get_default_equipment,
                                    widget=get_equipment_widget,
                                    missing=None)
    start_time = colander.SchemaNode(colander.DateTime(),
                                     widget=get_datetime_widget(),
                                     missing=None)
    end_time = colander.SchemaNode(colander.DateTime(),
                                   widget=get_datetime_widget(),
                                   missing=None)
    startloc = colander.SchemaNode(colander.String(),
                                   widget=get_location_widget,
                                   missing=None)
    endloc = colander.SchemaNode(colander.String(),
                                 widget=get_location_widget,
                                 missing=None)
    route = colander.SchemaNode(colander.String(), missing=None)
    rolling_time = colander.SchemaNode(colander.Time(),
                                       widget=get_timedelta_widget(),
                                       missing=None)
    total_time = colander.SchemaNode(colander.Time(),
                                     widget=get_timedelta_widget(),
                                     missing=None)
    distance = colander.SchemaNode(colander.Float(), missing=None)
    odometer = colander.SchemaNode(colander.Float(), missing=None)
    avspeed = colander.SchemaNode(colander.Float(), missing=None)
    maxspeed = colander.SchemaNode(colander.Float(), missing=None)
    trailer = colander.SchemaNode(colander.Boolean(), missing=None)
    surface = colander.SchemaNode(colander.Integer(),
                                  default=get_default_surface,
                                  widget=get_surface_widget,
                                  missing=None)
    ridergroup = colander.SchemaNode(colander.Integer(),
                                     default=get_default_ridergroup,
                                     widget=get_ridergroup_widget,
                                     missing=None)
    remarks = colander.SchemaNode(colander.String(),
                                  widget=deform.widget.TextAreaWidget(),
                                  missing=None)
示例#29
0
class SinglePoint(StrictMappingSchema):

    """A point object.

    **Required fields**

    :ivar point: (:class:`moe.views.schemas.base_schemas.ListOfFloats`) The point sampled (in the domain of the function)
    :ivar value: (*float64*) The value returned by the function
    :ivar value_var: (*float64 >= 0.0*) The noise/measurement variance (if any) associated with :attr:`value`

    """

    point = ListOfFloats()
    value = colander.SchemaNode(colander.Float())
    value_var = colander.SchemaNode(
            colander.Float(),
            validator=colander.Range(min=0.0),
            missing=0.0,
            )
示例#30
0
class ValidBboxSchema(colander.MappingSchema, ValidatorNode):
    """A schema which validates fields present in a bounding box."""

    max_lat = colander.SchemaNode(colander.Float(),
                                  missing=None,
                                  validator=colander.Range(
                                      constants.MIN_LAT, constants.MAX_LAT))
    min_lat = colander.SchemaNode(colander.Float(),
                                  missing=None,
                                  validator=colander.Range(
                                      constants.MIN_LAT, constants.MAX_LAT))

    max_lon = colander.SchemaNode(colander.Float(),
                                  missing=None,
                                  validator=colander.Range(
                                      constants.MIN_LON, constants.MAX_LON))
    min_lon = colander.SchemaNode(colander.Float(),
                                  missing=None,
                                  validator=colander.Range(
                                      constants.MIN_LON, constants.MAX_LON))