예제 #1
0
class TableBlockSchema(WorksheetBlockSchema):
    mode = fields.Constant(BlockModes.table_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.List(fields.String(), required=True)
    rows = fields.List(fields.Dict(), required=True)
예제 #2
0
class ReportSchema(Schema):
    id = fields.Int()
    height = fields.Int()
    spotName = fields.Str()
    regionName = fields.Str()
    windDirection = fields.List(fields.Int())
    windSpeed = fields.List(fields.Float())
    tide = fields.Float()
    waterTempMin = fields.Float()
    waterTempMax = fields.Float()

    class Meta:
        type_ = 'reports'

    @pre_load()
    def before_load(self, data):
        # TODO: remove the land mines. eg accessing a list
        # when it might be an object.
        result = {}
        result['height'] = data.get('Sort', {}).get('height_max')
        result['id'] = data.get('Quickspot', {}).get('spotid')
        result['spotName'] = data.get('Quickspot', {}).get('spotname')
        result['regionName'] = data.get('Quickspot', {}).get('regionname')
        result['windDirection'] = data.get('Wind', {}).get('wind_direction')[0]
        result['windSpeed'] = data.get('Wind', {}).get('wind_speed')[0]
        result['tide'] = data.get('Tide', {}).get('dataPoints')[0]['height']
        result['waterTempMin'] = data.get('WaterTemp', {}).get('watertemp_min')
        result['waterTempMax'] = data.get('WaterTemp', {}).get('watertemp_max')
        return result
예제 #3
0
파일: schemas.py 프로젝트: pythseq/MegaQC
class TrendSchema(PlotSchema):
    """
    Data that can be used to generate a trend plot.
    """

    x = f.List(f.DateTime())
    y = f.List(f.Number())
class MarkupBlockSchema(WorksheetBlockSchema):
    """
    Schema for blocks that contain markup.
    Does not need refining, contains markup text as payload.
    """

    ids = fields.List(fields.Integer())
    sort_keys = fields.List(fields.Integer())
    mode = fields.Constant(BlockModes.markup_block)
    is_refined = fields.Bool(validate=validate.Equal(True))  # always refined
    text = fields.String()
예제 #5
0
class TableBlockSchema(WorksheetBlockSchema):
    mode = fields.Constant(BlockModes.table_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.List(fields.String(), required=True)
    rows = fields.List(fields.Dict(), required=True)
    sort_keys = fields.List(fields.Integer())
    first_bundle_source_index = fields.Integer(
    )  # index for the first bundle in source
    using_schemas = fields.List(fields.String())
예제 #6
0
class RecordsBlockSchema(BundleBlockSchema):
    mode = fields.Constant(BlockModes.record_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.Constant(('key', 'value'))
    rows = fields.Nested(RecordsRowSchema, many=True, required=True)
    sort_keys = fields.List(fields.Integer())
    first_bundle_source_index = fields.Integer(
    )  # index for the first bundle in source
    using_schemas = fields.List(fields.String())
예제 #7
0
class BundleContentsBlockSchema(WorksheetBlockSchema):
    mode = fields.Constant(BlockModes.BUNDLE_CONTENTS_MODE)
    path = fields.String()
    bundle = fields.Relationship(
        include_resource_linkage=True, type_='bundles', attribute='bundle_uuid', allow_none=True
    )
    max_lines = fields.Integer()

    status = fields.Nested(FetchStatusSchema)
    files = fields.List(fields.String())
    lines = fields.List(fields.String())
예제 #8
0
class SchemaBlockSchema(WorksheetBlockSchema):
    """
    Schema for user-defined schemas in worksheets
    """

    mode = fields.Constant(BlockModes.schema_block)
    schema_name = fields.String(required=True)
    header = fields.List(fields.String(), required=True)
    field_rows = fields.List(fields.Dict(), required=True)
    sort_keys = fields.List(fields.Integer())
    ids = fields.List(fields.Integer())
예제 #9
0
class BaseAnnotationSchema(SlydSchema):
    id = fields.Str()
    attribute = fields.Str(required=True)
    accept_selectors = fields.List(fields.Str(), default=[])
    reject_selectors = fields.List(fields.Str(), default=[])
    tagid = fields.Integer(required=True)
    text_content = fields.Str()
    selector = fields.Str()

    sample = fields.Relationship(
        related_url='/api/projects/{project_id}/spiders/{spider_id}/samples/'
        '{sample_id}',
        related_url_kwargs={
            'project_id': '<project_id>',
            'spider_id': '<spider_id>',
            'sample_id': '<sample_id>'
        },
        type_='samples',
        include_resource_linkage=True)
    parent = fields.Relationship(related_url_kwargs={
        'project_id': '<project_id>',
        'spider_id': '<spider_id>',
        'sample_id': '<sample_id>',
        'item_id': '<parent_id>'
    },
                                 type_='items',
                                 include_resource_linkage=True)

    @property
    def parent_id(self):
        return self.context.get('container_id', self.item_id)

    @pre_dump
    def _dump_parent_id(self, item):
        parent_id = None
        if 'parent' in item:
            parent_id = item['parent']['id']
        if not parent_id:
            parent_id = item.get('container_id', self.parent_id) or ''
        if (item['id'].split('#')[0] == parent_id
                or parent_id.split('#')[0] == item['id']):
            item.pop('parent', None)
            item.pop('parent_id', None)
            return
        if parent_id:
            item['parent'] = {'id': parent_id}
        if parent_id and item.get('parent_id') is None:
            item['parent_id'] = parent_id
예제 #10
0
class ItemSchema(Schema):

    id = fields.String(dump_only=True)
    name = fields.String(required=True,
                         validator=ma.validate.Length(min=3, max=20))
    description = fields.String()
    tags = fields.List(fields.String())
    upc = fields.String()
    color = fields.String()
    size = fields.String()
    weight = fields.String()
    dimension = fields.String()
    category = fields.String()
    image = fields.URL()

    manufactory = fields.String()
    meta = fields.Dict()

    status = fields.String(requred=True, default='deactive')

    created_date = fields.DateTime(dump_only=True)
    updated_date = fields.DateTime(dump_only=True)

    class Meta:
        type_ = 'items'
        strict = True
        inflect = common.dasherize
예제 #11
0
class BundleSchema(Schema):
    id = fields.String(validate=validate_uuid, attribute='uuid')
    uuid = fields.String(attribute='uuid')  # for backwards compatibility
    bundle_type = fields.String(
        validate=validate.OneOf({bsc.BUNDLE_TYPE
                                 for bsc in BUNDLE_SUBCLASSES}))
    command = fields.String(allow_none=True)
    data_hash = fields.String()
    state = fields.String()
    owner = fields.Relationship(include_data=True,
                                type_='users',
                                attribute='owner_id')
    metadata = fields.Dict()
    dependencies = fields.Nested(BundleDependencySchema, many=True)
    children = fields.Relationship(include_data=True,
                                   type_='bundles',
                                   id_field='uuid',
                                   many=True)
    group_permissions = fields.Relationship(include_data=True,
                                            type_='bundle-permissions',
                                            id_field='id',
                                            many=True)
    host_worksheets = fields.List(fields.Dict)
    args = fields.String()

    # Bundle permission of the authenticated user for convenience, read-only
    permission = fields.Integer()
    permission_spec = PermissionSpec(attribute='permission')

    class Meta:
        type_ = 'bundles'
class RestaurantSchema(Schema):
    id = fields.Str()
    metadata = fields.ResourceMeta()
    cuisine = fields.List(fields.Str)
    name = fields.Str()
    location = fields.Str()
    phone = fields.Str()
    display_phone = fields.Str()
    rating = fields.Float()
    price = fields.Str()
    is_closed = fields.Bool()
    photos = fields.List(fields.Str)
    website = fields.Str()

    class Meta:
        type_ = 'restaurants'
예제 #13
0
class ProcessSchema(EntitySchema):
    spatial_scope = fields.Str(attribute='SpatialScope')
    temporal_scope = fields.Str(attribute='TemporalScope')
    Classification = fields.List(fields.Str())

    reference_entity = fields.Relationship(
        self_url='/{ref_link}/reference',
        self_url_kwargs={'ref_link': '<link>'},
        related_url='/{ref_link}',
        related_url_kwargs={'ref_link': '<link>'},
        many=True,
        include_resource_linkage=True,
        type_='reference_exchange',
        id_field='link',
        schema=ReferenceExchangeSchema)

    exchanges = fields.Relationship(
        self_url='/{origin}/{id}/exchanges',
        self_url_kwargs={
            'id': '<external_ref>',
            'origin': '<origin>'
        },
    )

    class Meta:
        type_ = 'process'
        self_url_many = '/processes/'
예제 #14
0
class RouteInputSchema(JSONAPISchema):
    id = fields.UUID()
    origin = fields.Nested(GeoJSONSchema, required=True)
    origin_name = fields.String(required=True)
    destination = fields.Nested(GeoJSONSchema, required=True)
    destination_name = fields.String(required=True)
    waypoints = fields.List(fields.Float)
    waypoints_names = fields.List(fields.String)
    polyline = fields.Nested(GeoJSONSchema, required=True)
    bounds = fields.Dict()
    created = fields.DateTime(allow_none=True)

    class Meta:
        type_ = 'routes'
        strict = True
        inflect = dasherize
예제 #15
0
class StockSchema(Schema):

    id = fields.String(dump_only=True)
    name = fields.String(required=True,
                         validator=ma.validate.Length(min=3, max=20))
    description = fields.String()
    tags = fields.List(fields.String())

    status = fields.String(requred=True, default='deactive')

    owner = fields.Relationship(related_url='/users/{user_id}',
                                related_url_kwargs={'user_id': '<id>'},
                                many=False,
                                schema=common.UserSchema,
                                include_resource_linkage=True,
                                type_='users',
                                dump_only=True)
    building = fields.Relationship(
        related_url='/buildings/{building_id}',
        related_url_kwargs={'building_id': '<id>'},
        many=False,
        schema=common.BuildingSchema,
        include_resource_linkage=True,
        type_='buildings',
    )

    created_date = fields.DateTime(dump_only=True)
    updated_date = fields.DateTime(dump_only=True)

    class Meta:
        type_ = 'stocks'
        strict = True
        inflect = common.dasherize
예제 #16
0
class WorksheetSchema(Schema):
    id = fields.String(validate=validate_uuid, attribute='uuid')
    uuid = fields.String(attribute='uuid')  # for backwards compatibility
    name = fields.String(validate=validate_name)
    owner = fields.Relationship(include_resource_linkage=True,
                                type_='users',
                                attribute='owner_id')
    title = fields.String()
    frozen = fields.DateTime(allow_none=True)
    is_anonymous = fields.Bool()
    tags = fields.List(fields.String())
    group_permissions = fields.Relationship(include_resource_linkage=True,
                                            type_='worksheet-permissions',
                                            id_field='id',
                                            many=True)
    items = fields.Relationship(include_resource_linkage=True,
                                type_='worksheet-items',
                                id_field='id',
                                many=True)
    last_item_id = fields.Integer(dump_only=True)

    # Bundle permission of the authenticated user for convenience, read-only
    permission = fields.Integer()
    permission_spec = PermissionSpec(attribute='permission')

    class Meta:
        type_ = 'worksheets'
예제 #17
0
파일: shift.py 프로젝트: dtrodger/shift
class ShiftSchema(Schema):
    id = fields.String(required=True, dump_only=True, attribute='shift_id')
    description = fields.String()
    address = fields.String()
    city = fields.String()
    state = fields.String()
    postal_code = fields.String()
    country = fields.String()
    time_slots = fields.List(fields.Nested(TimeSlotsSchema))
    labels = fields.List(fields.String())

    class Meta:
        type_ = 'shift'
        self_view = 'ponos'
        self_view_many = 'ponos'
        strict = True
예제 #18
0
class AnnotationSchema(BaseAnnotationSchema):
    required = fields.Boolean(default=False)
    ignore = fields.Boolean(default=False)
    ignore_beneath = fields.Boolean(default=False)
    variant = fields.Integer(default=False)
    slice = fields.List(fields.Integer())
    pre_text = fields.Str()
    post_text = fields.Str()
    selection_mode = fields.Str()

    field = fields.Relationship(
        related_url='/api/projects/{project_id}/schemas/{schema_id}/fields/'
        '{field_id}',
        related_url_kwargs={
            'project_id': '<project_id>',
            'schema_id': '<schema_id>',
            'field_id': '<field.id>'
        },
        type_='fields',
        include_resource_linkage=True)
    extractors = fields.Relationship(
        related_url='/api/projects/{project_id}/extractors',
        related_url_kwargs={'project_id': '<project_id>'},
        many=True,
        include_resource_linkage=True,
        type_='extractors')

    class Meta:
        type_ = 'annotations'
예제 #19
0
class IdentitySchema(Schema):
    id = fields.String(dump_only=True)
    methods = fields.List(fields.String())
    password = fields.Nested(PasswordAuthSchema)

    class Meta:
        type_ = 'identity'
        strict = True
예제 #20
0
class TunnelSchema(Schema):
    class Meta:
        type_ = "tunnel"
        strict = True
        inflect = drinkingCamel

    id = fields.Str()
    port = fields.List(fields.Str())
    ssh_port = fields.Str()
    ip_address = fields.Str()
    allocated_tcp_ports = fields.List(fields.Str())
    subdomain = fields.Relationship(
        "/subdomains/{subdomain_id}",
        related_url_kwargs={"subdomain_id": "<subdomain_id>"},
        include_resource_linkage=True,
        type_="subdomain",
    )
예제 #21
0
class RecordsBlockSchema(BundleBlockSchema):
    mode = fields.Constant(BlockModes.record_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.Constant(('key', 'value'))
    rows = fields.Nested(RecordsRowSchema, many=True, required=True)
    sort_keys = fields.List(fields.Integer())
예제 #22
0
class BundlesSpecSchema(PlainSchema):
    uuid_spec_type = 'uuid_spec'

    spec_types = uuid_spec_type

    # Fields
    spec_type = fields.String(validate=validate.OneOf(set(spec_types)))
    bundle_infos = fields.List(fields.Dict())
    fetch_status = fields.Nested(FetchStatusSchema, required=True)
예제 #23
0
class DEPProfileSchema(Schema):
    """marshmallow schema for a DEP profile.

    See Also:
          - `/profile endpoint <https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/MobileDeviceManagementProtocolRef/4-Profile_Management/ProfileManagement.html#//apple_ref/doc/uid/TP40017387-CH7-SW6>`_.
    """

    profile_name = fields.String(required=True)
    """str: A human-readable name for the profile."""
    url = fields.Url(required=True)
    """str: The URL of the MDM server."""
    allow_pairing = fields.Boolean(default=True)
    is_supervised = fields.Boolean(default=False)
    """bool: If true, the device must be supervised"""
    is_multi_user = fields.Boolean(default=False)
    """bool: If true, tells the device to configure for Shared iPad."""
    is_mandatory = fields.Boolean(default=False)
    """bool: If true, the user may not skip applying the profile returned by the MDM server"""
    await_device_configured = fields.Boolean()
    """bool: If true, Setup Assistant does not continue until the MDM server sends DeviceConfigured."""
    is_mdm_removable = fields.Boolean()
    """bool: If false, the MDM payload delivered by the configuration URL cannot be removed by the user via the user 
    interface on the device"""
    support_phone_number = fields.String()
    """str: A support phone number for the organization."""
    auto_advance_setup = fields.Boolean()
    """bool: If set to true, the device will tell tvOS Setup Assistant to automatically advance though its screens."""
    support_email_address = fields.Email()
    """str: A support email address for the organization."""
    org_magic = fields.String()
    """str: A string that uniquely identifies various services that are managed by a single organization."""
    anchor_certs = fields.List(fields.String())
    """List[str]: Each string should contain a DER-encoded certificate converted to Base64 encoding. If provided, 
    these certificates are used as trusted anchor certificates when evaluating the trust of the connection 
    to the MDM server URL."""
    supervising_host_certs = fields.List(fields.String())
    """List[str]: Each string contains a DER-encoded certificate converted to Base64 encoding. If provided, 
    the device will continue to pair with a host possessing one of these certificates even when allow_pairing 
    is set to false"""
    skip_setup_items = fields.Nested(SetupAssistantStep, many=True)
    """Set[SetupAssistantStep]: A list of setup panes to skip"""
    department = fields.String()
    """str: The user-defined department or location name."""
    devices = fields.List(fields.String())
예제 #24
0
class SessionNotifySchema(Schema):
    subject = fields.Str(required=False, validate=validate.Length(max=250))
    message = fields.Str(required=False, validate=validate.Length(max=5000))
    bcc = fields.List(fields.String(), default=[])

    @validates_schema
    def validate_fields(self, data):
        if not data:
            return
        data['message'] = clean_html(data.get('message'), allow_link=True)
예제 #25
0
class SpiderSchema(SlydSchema):
    id = fields.Str(dump_only=True, load_from='name')
    name = fields.Str()
    start_urls = fields.List(fields.Str(), default=[])
    links_to_follow = fields.Str(default='patterns')
    follow_patterns = fields.List(fields.Str(), default=[])
    exclude_patterns = fields.List(fields.Str(), default=[])
    js_enabled = fields.Boolean(default=False)
    js_enable_patterns = fields.List(fields.Str(), default=[])
    js_disable_patterns = fields.List(fields.Str(), default=[])
    respect_nofollow = fields.Boolean(default=True)
    allowed_domains = fields.List(fields.Str(), default=[])
    login_url = fields.Str()
    login_user = fields.Str()
    login_password = fields.Str()
    perform_login = fields.Boolean(default=False)
    template_names = fields.List(fields.Str(), default=[])
    samples = fields.Relationship(
        related_url='/api/projects/{project_id}/spider/{spider_id}/samples',
        related_url_kwargs={
            'project_id': '<project_id>',
            'spider_id': '<spider_id>'
        },
        many=True,
        include_resource_linkage=True,
        type_='samples')
    project = fields.Relationship(
        related_url='/api/projects/{project_id}',
        related_url_kwargs={'project_id': '<project_id>'},
        type_='projects',
        include_resource_linkage=True)

    @pre_dump
    def _dump_login_data(self, item):
        init_requests = item.pop('init_requests', None)
        if init_requests:
            login_request = init_requests[0]
            item['login_url'] = login_request['loginurl']
            item['login_user'] = login_request['username']
            item['login_password'] = login_request['password']
        return item

    @post_load
    def _load_login_data(self, item):
        fields = ('login_url', 'login_user', 'login_password')
        if all(field in item and item[field] for field in fields):
            item['init_requests'] = [{
                'type': 'login',
                'loginurl': item.pop('login_url'),
                'username': item.pop('login_user'),
                'password': item.pop('login_password')
            }]
        for field in fields:
            item.pop(field, None)
        return item

    class Meta:
        type_ = 'spiders'
예제 #26
0
파일: placement.py 프로젝트: dtrodger/ad
class Placement(Schema):
    id = fields.String(required=True, dump_only=True, attribute='placement_id')
    name = fields.String()
    placement_period = fields.List(fields.Nested(PlacementPeriod))

    class Meta:
        type_ = 'placement'
        self_view = 'zelos'
        self_view_many = 'zelos'
        strict = True
예제 #27
0
파일: placement.py 프로젝트: dtrodger/ad
class PlacementPeriod(Schema):
    id = fields.String(dump_only=True, attribute='placement_id')
    start = fields.String()
    end = fields.DateTime()
    cmp = fields.Int()
    delivery = fields.List(fields.Nested(Delivery))
    budget = fields.Int()

    class Meta:
        type_ = 'placement_period'
예제 #28
0
class DirectionsQuerySchema(Schema):
    origin = fields.Str(required=True, validate=lambda s: bool(s))
    destination = fields.Str(required=True, validate=lambda s: bool(s))
    waypoints = fields.List(fields.Str)
    mode = fields.Str(default='driving',
                      validate=validate.OneOf(
                          ['driving', 'walking', 'bicycling', 'transit']))
    language = fields.Str(default='ru')

    class Meta:
        strict = True
예제 #29
0
파일: schemas.py 프로젝트: pythseq/MegaQC
class PlotSchema(JsonApiSchema):
    """
    Data that can be used to generate a plot.
    """
    class Meta:
        type_ = "plots"
        unknown = INCLUDE

    id = f.String(dump_only=True)
    type = f.String()
    x = f.List(f.Raw())
    y = f.List(f.Raw())
    text = f.List(f.Raw())
    hoverinfo = f.Str()
    line = f.Dict()
    mode = f.String()
    name = f.String()
    fill = f.String()
    fillcolor = f.String()
    showlegend = f.Bool()
예제 #30
0
    class StringJsonAttributePersonSchema(Schema):
        class Meta:
            type_ = "string_json_attribute_person"
            self_view = "api.string_json_attribute_person_detail"
            self_view_kwargs = {"person_id": "<id>"}

        id = fields.Integer(as_string=True, attribute="person_id")
        name = fields.Str(required=True)
        birth_date = fields.DateTime()
        address = fields.Nested(address_schema, many=False)
        tags = fields.List(fields.Dict())