def __init__(self, json_data):
        self.entityType	 = None   #string	audio album / audio single / internet / video
        self.title	 = None   #string	Title of the release
        self.type	 = None   #string	Release type. More specific than entityType
        self.date	 = None   #partial date	Release date
        self.label	 = None   #label	The label of the release
        self.catalogNr = None   	#string	Catalog number
        self.ean	 = None       #string	EAN code
        self.picture	 = None       #picture	Picture of the release art
        self.tributes	 = None   #list of artist	Tributed artists
        self.performances = None	#list of performance	Release tracks
        self.external_uri = None	#Discogs

        self._initialize_fields_from_json_data({required("entityType"): voluptuous.any(u"audio album",
                                                                                        u"audio single",
                                                                                        u"internet",
                                                                                        u"video"),
                                                required("uri"):basestring,
                                                "title": unicode,
                                               "type": unicode,
                                               "date": isPartialDate,
                                               "label": coerce(ShsLabel),
                                               "catalogNr": unicode,
                                               "ean": _voluptuous_any_or_null(unicode),
                                               "picture": coerce(ShsPicture),
                                               "tributes": [coerce(ShsArtist)],
                                               "performances": [coerce(ShsPerformance)],
                                               "external_uri": [unicode], },
                                        json_data)
        self.json_data = json_data
    def __init__(self, json_data):
        self.entityType	 = None #string	performance / recording (in case it is recorded)
        self.title	 = None #string	title of the performance
        self.performer	 = None #performer	performer
        self.date	 = None #partial date	Performance or recording date. NOT the release date (see releases)
        self.releases	 = None #list of release	Releases on which the performance has been released
        self.works	 = None #list of work	Performed works. Usually just one work, except for medleys
        self.originals	 = None #list of work	In case of a cover: original performances per work. Each work has an additional attribute 'original' referring to the original performance and an attribute 'isRootWork' (which is true if the work is not an adaptation)
        self.covers	 = None # list of performance	In case of an original: list of covers
        self.derivedWorks = None #	list of work	In case of a cover: list of works derived from the work of the performance
        self.external_uri = None #	 	youtube videos
        self._initialize_fields_from_json_data({required("entityType"): voluptuous.any(u"performance",
                                                                                        u"recording"),
                                                required("uri"):basestring,
                                                "title": unicode,
                                               "performer": coerce(ShsPerformer),
                                               "date": isPartialDate,
                                               "releases":[coerce(ShsRelease)],
                                               "works": [coerce(ShsWork)],
                                               "originals": [coerce(ShsWork)],
                                               "covers": [coerce(ShsPerformance)],
                                               "derivedWorks": [coerce(ShsWork)],
                                               "external_uri": [unicode]},
                                        json_data)

        self.json_data = json_data
 def __init__(self, json_data):
     self.entityType	 = None    #string	song / poem / film / proza
     self.title	 = None    #string	title of the work
     self.language	 = None    #string	language of the work
     self.credits	 = None    #list of artist	credited artists
     self.originalCredits = None	#list of artist	artists credits for the works on which this work is based
     self.original	 = None    #performance	original performance
     self.basedOn	 = None    #list of work	works on which this work is based
     self.derivedWorks	 = None    #list of work	works derived from this work
     self.versions	 = None    #list of performance	versions of this work
     self._initialize_fields_from_json_data({required("entityType"): voluptuous.any(u"song",
                                                                                     u"poem",
                                                                                     u"film",
                                                                                     u"proza"),
                                     required("uri"):basestring,
                                     "title": unicode,
                                    "language": _voluptuous_any_or_null(unicode),
                                    "credits": [coerce(ShsArtist)],
                                    "originalCredits": [coerce(ShsArtist)],
                                    "original": coerce(ShsPerformance),
                                    "basedOn": [coerce(ShsWork)],
                                    "derivedWorks": [coerce(ShsWork)],
                                    "versions": [coerce(ShsPerformance)]},
                             json_data)
     self.json_data = json_data
    def __init__(self, json_data):
        self.name = None	#string	Name of the label
        self._initialize_fields_from_json_data({required("entityType"): "label",
                                                required("uri") : basestring,
                                                required("name"): unicode,
                                                "picture" : _voluptuous_any_or_null(coerce(ShsPicture))
                                                },

                                        json_data)
        self.json_data = json_data
 def __init__(self, json_data):
     self.entityType = None #Always 'picture'
     self.title = None
     self.url = None
     self._initialize_fields_from_json_data({required("entityType"): u"picture",
                                             "name": unicode,
                                             "url": unicode},
                                             json_data)
     self.json_data = json_data
    def __init__(self, json_data):
        self.entityType	 = None #string	artist / joint-artist
        self.commonName	 = None #string	The name by which the artist is mostly referred to
        self.picture	 = None #picture	(artist only) Picture of the artist
        self.birthDate	 = None #partial date	(artist only) Birth date of the artist
        self.deathDate	 = None #partial date	(artist only) Death date of the artist
        self.homeCountry = None #	string	(artist only) Country mostly associated with the artist
        self.comments	 = None #string	(artist only) Comments
        self.aliases	 = None #list of string	List of other names used by this artist
        self.relations	 = None #list of relation	(artist only) Related artists
        self.members	 = None #list of artist	(joint artist only) Artists that are part of the joint artist

        self.performances_uri = None
        self.creditedWorks_uri = None
        self.releases_uri = None

        self._getter_factory_functions = dict()

        self._initialize_fields_from_json_data({required("entityType"): voluptuous.any(u"artist"
                                                                                       , u"joint-artist"),
                                                required("uri"):basestring,
                                                "commonName": unicode,
                                               "picture": coerce(ShsPicture),
                                               "birthDate": isPartialDate,
                                               "deathDate": isPartialDate,
                                               "homeCountry": unicode,
                                               "comments": unicode,
                                               "aliases": [unicode],
                                               "relations": [coerce(ShsRelation)],
                                               "members": [coerce(ShsArtist)],
        },
                                        json_data)

        self._initialize_url_fields({"performances": lambda xs: [ShsPerformance(x) for x in xs],
                                     "creditedWorks": lambda xs: [ShsWork(x) for x in xs],
                                     "releases": lambda xs: [ShsRelease(x) for x in xs]},
                                    json_data)
        self.json_data = json_data
from voluptuous import Schema, required, Invalid
from voluptuous import coerce as my_coerce
from voluptuous import any as my_any
from voluptuous import all as my_all
from voluptuous import range as my_range

cd = {
        required('title'): str,
        'discs': int,
        'matrix': [str],
        'source': my_all(my_any('pro', 'aud')),
        'producer': str,
        'quality': my_all(my_any('perfect','excellent','average','poor')),
        'generation': my_all(my_any('master','high','medium','low')),
        'duration': my_all(my_coerce(float), float),
        'tracklists': [[str]],
        'date': {
            required('d'): my_all(int, my_range(min=1, max=31)),
            required('m'): my_all(int, my_range(min=1, max=12)),
            required('y'): my_all(int, my_range(min=1981, max=2050))
            }
}
cd_schema = Schema(cd)

#result = cd_schema({
#    'title': "My CD Title",
#    'discs': 2,
#    'matrix': ["cd1_code"],
#    'source': 'pro',
#    'producer': "The Godfather Records",
#    'quality': "perfect",
Ejemplo n.º 8
0
import json
import bottle
from bottle import route, run, request, abort
from pymongo import Connection
from bson.objectid import ObjectId

from voluptuous import Schema, required, all, range, match

connection = Connection('localhost', 27017)
db = connection.socialbearing

ver = "v1"

fullschema = Schema({
    required('device_uuid'):
    match(
        r'^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
    ),
    'device_model':
    unicode,
    required('buoys'): [{
        required('buoy_type'):
        unicode,
        'buoy_id':
        unicode,
        required('bearings'): [{
            required('timestamp'):
            all(long, range(min=0)),
            required('lat'):
            all(float, range(min=-180, max=180)),
Ejemplo n.º 9
0
from voluptuous import Schema, required, Invalid
from voluptuous import coerce as my_coerce
from voluptuous import any as my_any
from voluptuous import all as my_all
from voluptuous import range as my_range

cd = {
    required('title'): str,
    'discs': int,
    'matrix': [str],
    'source': my_all(my_any('pro', 'aud')),
    'producer': str,
    'quality': my_all(my_any('perfect', 'excellent', 'average', 'poor')),
    'generation': my_all(my_any('master', 'high', 'medium', 'low')),
    'duration': my_all(my_coerce(float), float),
    'tracklists': [[str]],
    'date': {
        required('d'): my_all(int, my_range(min=1, max=31)),
        required('m'): my_all(int, my_range(min=1, max=12)),
        required('y'): my_all(int, my_range(min=1981, max=2050))
    }
}
cd_schema = Schema(cd)

#result = cd_schema({
#    'title': "My CD Title",
#    'discs': 2,
#    'matrix': ["cd1_code"],
#    'source': 'pro',
#    'producer': "The Godfather Records",
#    'quality': "perfect",