stanza_content Package¶
stanza_content
Package¶
_error
Module¶
-
class
silf.backend.commons.api.stanza_content._error.
Error
(severity, error_type, message, field=None, **kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Represents error message.
>>> err = Error("warning", "device", "foo") >>> err <Error severity='warning' error_type='device' metadata='[('message', 'foo')]'> >>> err.field = "Foo" >>> err <Error severity='warning' error_type='device' metadata='[('field_name', 'Foo'), ('message', 'foo')]'> >>> err.__getstate__() == {'metadata': {'field_name': 'Foo', 'message': 'foo'}, 'severity': 'warning', 'error_type': 'device'} True
>>> Error.from_dict(err.__getstate__()) == err True
-
DEFAULTS
= {'metadata': {}}¶
-
DICT_CONTENTS
= {'metadata', 'severity', 'error_type'}¶
-
field
¶ Field to which this error is attached
-
message
¶
-
-
class
silf.backend.commons.api.stanza_content._error.
ErrorSuite
(errors=None)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
>>> err = ErrorSuite(errors=[ ... Error("warning", "device", "foo"), Error("warning", "device", "bar") ... ])
>>> err.__getstate__() == {'errors': [{'metadata': {'message': 'foo'}, 'severity': 'warning', 'error_type': 'device'}, {'metadata': {'message': 'bar'}, 'severity': 'warning', 'error_type': 'device'}]} True >>> err.setstate({'errors': []}) >>> err.errors [] >>> err.__setstate__({'errors': [{'metadata': {'message': 'foo'}, 'severity': 'warning', 'error_type': 'device'}, {'metadata': {'message': 'bar'}, 'severity': 'warning', 'error_type': 'device'}]}) >>> err.errors [<Error severity='warning' error_type='device' metadata='[('message', 'foo')]'>, <Error severity='warning' error_type='device' metadata='[('message', 'bar')]'>]
>>> ErrorSuite.from_dict(err.__getstate__()) == err True
-
DICT_CONTENTS
= {'errors'}¶
-
getstate
()¶
-
classmethod
join
(*args)¶ Returns
ErrorSuite
constructed from all errors in*args
.>>> error1 = Error("warning", "device", "foo") >>> error2 = Error("warning", "device", "bar") >>> error3 = Error("warning", "device", "baz") >>> ErrorSuite.join(ErrorSuite(errors=[error1, error2]), ErrorSuite(errors=[error3])) <ErrorSuite errors=[<Error severity='warning' error_type='device' metadata='[('message', 'foo')]'>, <Error severity='warning' error_type='device' metadata='[('message', 'bar')]'>, <Error severity='warning' error_type='device' metadata='[('message', 'baz')]'>] >
Parameters: args – List of ErrorSuite
.Return type: ErrorSuite
-
setstate
(state)¶
-
_json_mapper
Module¶
Does serialization to json.
Serialization example
>>> from silf.backend.commons.api import *
>>> import json
>>> selection = ModeSelection(mode = "foo")
>>> json.dumps(selection.__getstate__())
'{"mode": "foo"}'
Deserialization example
>>> ModeSelection.from_dict(json.loads('{"mode": "foo"}'))
<ModeSelection mode=foo>
-
exception
silf.backend.commons.api.stanza_content._json_mapper.
SerializationException
¶ Bases:
silf.backend.commons.api.exceptions.SilfException
Exception raised during serialization to or from json. It normally signifies programming error.
-
class
silf.backend.commons.api.stanza_content._json_mapper.
FromStateMixin
¶ Bases:
object
-
classmethod
from_dict
(state)¶ Creates instance of this class using provided state dictionatry :param state: state from which to create instance :return: Created instance :rtype:cls
-
classmethod
-
class
silf.backend.commons.api.stanza_content._json_mapper.
JsonMapped
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.FromStateMixin
Json class that has well-known set of properties. Each property has known type (that can optionally be checked).
This class should be subclassed like that:
>>> class TmpTestJsonMapped(JsonMapped): ... ... DICT_CONTENTS = {'foo'} ... ... def __init__(self, foo): ... super().__init__() ... self.foo = foo >>> foo = TmpTestJsonMapped(foo="bar") >>> foo.__getstate__() {'foo': 'bar'}
This class can automagically set atributes in __init__ method
>>> class TmpTestJsonMapped(JsonMapped): ... ... DICT_CONTENTS = {'foo'} ... ... def __init__(self, **kwargs): ... super().__init__(**kwargs) >>> foo = TmpTestJsonMapped(foo="bar") >>> foo.__getstate__() {'foo': 'bar'} >>> foo = TmpTestJsonMapped(bar="bar") Traceback (most recent call last): ValueError: Invalid __init__ parameter bar
-
DEFAULTS
= {}¶ Dictionaty containing default values for some of the properties.
-
DICT_CONTENTS
= set()¶ Defines set of properties that need to be in state dicts (for both serialization and deserialization)
-
getstate
()¶ Iternal function that should be overriden, it returns state dictionary, that will be transformed to json:
>>> foo = TestJsonMapped(foo="bar") >>> foo.getstate() == {'foo': 'bar'} True
Default implementation just filters the __dict__ property, so any additional items are removed:
>>> foo.bar = 'baz' >>> foo.getstate() == {'foo': 'bar'} True
-
setstate
(state)¶ Iternal function that should be overriden by subclasses.
Note
This function should not be called directly, rather use
__setstate__()
that checks state dicitonary for invalid keys.Default implementation just does:
for k, v in state.items(): setattr(self, k, v)
>>> foo = TestJsonMapped("foo")
This function performs no checks whatsoever!
>>> foo.setstate({'foo': 'bar', 'bar': 'baz'}) >>> foo.bar 'baz'
-
-
class
silf.backend.commons.api.stanza_content._json_mapper.
FlatDictJsonMapped
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.FromStateMixin
Represents type that serializes to json object that can contain any property, but all properties are of the same type.
>>> class TmpTestFlatDictJsonMapped(FlatDictJsonMapped): ... INTERNAL_DICT_NAME = "foos" ... INTERNAL_VALUE_CLASS = TestJsonMapped
Init method can take optional keyword named as
INTERNAL_DICT_NAME
>>> flat = TmpTestFlatDictJsonMapped( … foo = TestJsonMapped(foo=’bar’), … bar = TestJsonMapped(foo=’baz’)) >>> sorted(flat.foos.items()) # doctest: +ELLIPSIS [(‘bar’, <Foo foo=baz>), (‘foo’, <Foo foo=bar>)]It implements get state:
>>> flat.__getstate__() == {'foo': {'foo': 'bar'}, 'bar': {'foo': 'baz'}} True >>> flat.foos = {} >>> flat.foos {}
And set state:
>>> flat.__setstate__({'foo': {'foo': 'bar'}, 'bar': {'foo': 'baz'}}) >>> sorted(flat.foos.items()) [('bar', <Foo foo=baz>), ('foo', <Foo foo=bar>)]
-
INTERNAL_DICT_NAME
= None¶ Name of property that contains internal dictionary that will hold mapping.
-
INTERNAL_VALUE_CLASS
= None¶ Class to which all properties will be deserialized
-
deserialize_internal_item
(item)¶ Deserializes :attr:INTERNAL_VALUE_CLASS. by default it calls item.from_dict.
-
get
(*args, **kwargs)¶
-
internal_dict
¶
-
classmethod
join
(*args)¶ Joins series of instances of this class into single instance, checking for eventual duplicate keys;
>>> from silf.backend.commons.api import ResultSuite, Result
>>> a = ResultSuite(foo=Result(value=[5]), foobar=Result(value=[1, 2, 3])) >>> b = ResultSuite(bar=Result(value=[10]), barbar=Result(value=[1, 2, 3]))
>>> ResultSuite.join(a, b) <ResultSuite bar=<Result pragma=append value=[10] > barbar=<Result pragma=append value=[1, 2, 3] > foo=<Result pragma=append value=[5] > foobar=<Result pragma=append value=[1, 2, 3] > >
>>> ResultSuite.join(a, b, a) Traceback (most recent call last): ValueError: We are joining instances of <class 'silf.backend.commons.api.misc.ResultSuite'>, these instances should not contain duplicate data, however they did. Duplicate keys were ['foo', 'foobar']. Debug data is: [{"foo": {"pragma": "append", "value": [5]}, "foobar": {"pragma": "append", "value": [1, 2, 3]}}, {"bar": {"pragma": "append", "value": [10]}, "barbar": {"pragma": "append", "value": [1, 2, 3]}}, {"foo": {"pragma": "append", "value": [5]}, "foobar": {"pragma": "append", "value": [1, 2, 3]}}].
-
serialize_internal_item
(item)¶ Serializes :attr:INTERNAL_VALUE_CLASS. by default it calls item.__getstate__.
-
_misc
Module¶
-
class
silf.backend.commons.api.stanza_content._misc.
Setting
(value=None, current=False)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Single setting object. It serializes to following JSON:
>>> setting = Setting(value=15.4, current=True)
Serialization format
>>> setting.__getstate__() == {'current': True, 'value': 15.4} True >>> setting.__setstate__({'current': True, 'value': 15.4}) >>> setting.current True >>> setting.value 15.4
It can deserialize from dictionary without current item: >>> setting.__setstate__({‘value’: 15.4}) >>> setting.current False >>> setting.value 15.4
Check equality:
>>> setting2 = Setting.from_dict(setting.__getstate__()) >>> setting2 == setting True
Setting incorrect type for current raises an exception >>> setting = Setting(value=15.4, current=”dupa”) Traceback (most recent call last): silf.backend.commons.api.exceptions.SerializationException: Current property must be either True or False >>> setting.__setstate__({“value” :5, ‘current’:”dupa”}) Traceback (most recent call last): silf.backend.commons.api.exceptions.SerializationException: Current property must be either True or False
-
DEFAULTS
= {'current': False}¶
-
DICT_CONTENTS
= {'value', 'current'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
SettingSuite
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.FlatDictJsonMapped
Contains a set of settings.
Serializes to following JSON:
>>> settings_set = SettingSuite( ... foo = Setting(value = 13), ... bar = Setting(value= "Kotek!", current=True) ... )
<SettingSuite bar=<Setting current=True value=Kotek! > foo=<Setting current=False value=13 > >
Serialization format>>> settings_set.__getstate__() == {'foo': {'current': False, 'value': 13}, 'bar': {'current': True, 'value': 'Kotek!'}} True
Test equality:
>>> setting_set2 = SettingSuite.from_dict(settings_set.__getstate__()) >>> setting_set2 == settings_set True
-
INTERNAL_DICT_NAME
= 'settings'¶
-
settings
= {}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
InputFieldSuite
(controls=(), **kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.FlatDictJsonMapped
Contains a set of controls.
>>> from silf.backend.commons.api import *
>>> control_set = InputFieldSuite( ... controls = [NumberControl("foo", "Insert foo"), ... NumberControl("bar", "Insert bar")] ... ) >>> control_set.__getstate__() == { ... 'foo': {'validations': {}, 'live': False, 'type': 'number', 'name': 'foo', 'metadata': {'label': 'Insert foo'}, "order": 0}, ... 'bar': {'live': False, 'type': 'number', 'name': 'bar', 'metadata': {'label': 'Insert bar'}, 'validations': {}, "order": 1} ... } True
Test equality:
>>> InputFieldSuite.from_dict(control_set.__getstate__()) == control_set True
>>> control_set.__setstate__({"foo" : 15}) Traceback (most recent call last): ValueError: Can deserialize only dict, got 15 (type: <class 'int'>)
-
INTERNAL_DICT_NAME
= 'controls'¶
-
INTERNAL_VALUE_CLASS
= None¶
-
controls
= {}¶
-
deserialize_internal_item
(item)¶
-
serialize_internal_item
(item)¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
OutputField
(html_class, name, label=None, **kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Represents a Result field.
Default values are applied when constructing, and while using __setstate__
>>> result = OutputField("chart", "betaArray") >>> result <Result class=chart name=['betaArray'] type=array metadata={} settings={}>
>>> result.__setstate__({"class": "chart", "name": ["betaArray"]}) >>> result <Result class=chart name=['betaArray'] type=array metadata={} settings={}> >>> result.settings {}
Some metadata properties can ve accessed as properties:
>>> result.label = "foo" >>> result <Result class=chart name=['betaArray'] type=array metadata={'label': 'foo'} settings={}>
Json property named class is avilable as html_class property
>>> result.html_class = "integer-indicator"
Serialization format
>>> result.__getstate__() == {'metadata': {'label': 'foo'}, 'class': 'integer-indicator', 'settings': {}, 'type': 'array', 'name': ['betaArray']} True >>> result.html_class 'integer-indicator'
Check equality:
>>> OutputField.from_dict(result.__getstate__()) == result True
>>> result = OutputField("chart", "betaArray") >>> result.__getstate__() == {'class': 'chart', 'name': ['betaArray'], 'metadata': {}, 'type': 'array', 'settings': {}} True >>> result.setstate( {'class': 'chart', 'name': ['gammaArray'], 'metadata': {}, 'type': 'array', 'settings': {}}) >>> result <Result class=chart name=['gammaArray'] type=array metadata={} settings={}>
-
DEFAULTS
= {'metadata': {}, 'settings': {}, 'type': 'array'}¶
-
DICT_CONTENTS
= {'metadata', 'name', 'settings', 'class', 'type'}¶
-
getstate
()¶ Override parent implementation to dynamically translate labels inside of metadata dict :return:
-
html_class
¶
-
label
¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ChartField
(html_class, name, label=None, axis_x_label=None, axis_y_label=None, **kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._misc.OutputField
-
axis_x_label
¶
-
axis_y_label
¶
-
getstate
()¶ Override parent implementation to dynamically translate labels inside of metadata dict :return:
-
-
class
silf.backend.commons.api.stanza_content._misc.
OutputFieldSuite
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.FlatDictJsonMapped
Holds suite of output results:
>>> suite = OutputFieldSuite(foo = OutputField("foo", ["foo"])) >>> suite.output_fields {'foo': <Result class=foo name=['foo'] type=array metadata={} settings={}>} >>> suite.__getstate__() == {'foo': {'class': 'foo', 'metadata': {}, 'name': ['foo'], 'settings': {}, 'type': 'array'}} True
Check equality:
>>> suite == OutputFieldSuite.from_dict(suite.__getstate__()) True
>>> suite.__setstate__({'bar': {'class': 'foo', 'metadata': {}, 'name': ['bar'], 'settings': {}, 'type': 'array'}}) >>> suite.output_fields {'bar': <Result class=foo name=['bar'] type=array metadata={} settings={}>}
TEST ERRORS
>>> suite = OutputFieldSuite(foo = OutputField("foo", ["foo", "baz"])) Traceback (most recent call last): silf.backend.commons.api.exceptions.ConfigurationException: Following errors encountered: ["Error --- control foo takes input from more than one result (that is: ['foo', 'baz']) this is disallowed"]
-
INTERNAL_DICT_NAME
= 'output_fields'¶
-
INTERNAL_VALUE_CLASS
¶ alias of
OutputField
-
output_fields
= None¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
Mode
(label, description=None, order=None, **kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Encapsulates single mode.
>>> mode = Mode("foo", description="Foo mode", order=1) >>> mode.__getstate__() == {'description': 'Foo mode', 'label': 'foo', 'order': 1} True >>> mode.setstate({'description': 'Bar mode', 'label': 'bar'}) >>> mode <Mode 'bar' description='Bar mode'>
Check Equality:
>>> mode == Mode.from_dict(mode.__getstate__()) True
-
DEFAULTS
= {'description': None, 'order': None}¶
-
DICT_CONTENTS
= {'description', 'order', 'label'}¶
-
getstate
()¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ModeSuite
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.FlatDictJsonMapped
Encapsulates suite of modes.
>>> suite = ModeSuite(foo= Mode("Foo Mode", "descr"), bar = Mode("Bar Mode", "descr")) >>> suite.__getstate__() == { ... 'foo': {'label': 'Foo Mode', 'description': 'descr', 'order': None}, ... 'bar': {'label': 'Bar Mode', 'description': 'descr', 'order': None} ... } True >>> suite.__setstate__({'bar': {'label': 'Bar Mode', 'description': 'descr'}}) >>> suite.modes {'bar': <Mode 'Bar Mode' description='descr'>}
Check equality:
>>> suite == ModeSuite.from_dict(suite.__getstate__()) True
Nice example:
>>> suite = ModeSuite(time = Mode("Pomiar czasu", "Mierz zliczenia, i kończ pomiar po upływie ustalonego czasu.", order=0), counts = Mode("Pomiar zliczeń", "Mierz czas potrzebny do uzyskania ustalonej liczby zliczeń", order=1)) >>> suite.__getstate__() == { ... 'counts': { ... 'description': 'Mierz czas potrzebny do uzyskania ustalonej liczby zliczeń', ... 'label': 'Pomiar zliczeń', ... 'order' : 1 ... }, ... 'time': { ... 'description': 'Mierz zliczenia, i kończ pomiar po upływie ustalonego czasu.', ... 'label': 'Pomiar czasu', ... 'order': 0 ... } ... } True
-
INTERNAL_DICT_NAME
= 'modes'¶
-
modes
= {}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ModeSelection
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Encapsulates mode selection:
>>> mode = ModeSelection(mode = "foo") >>> mode.__getstate__() {'mode': 'foo'} >>> mode.setstate( {'mode': 'bar'}) >>> mode.mode 'bar'
Check Equality:
>>> mode == ModeSelection.from_dict(mode.__getstate__()) True
-
DICT_CONTENTS
= {'mode'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ModeSelected
(mode, experimentId=None, settings=None, resultDescription=None, **kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Response after user selects mode:
>>> from silf.backend.commons.api import ControlSuite, NumberControl >>> from silf.backend.commons.api.stanza_content._misc import *
>>> c = ControlSuite( ... NumberControl("foo", "Insert foo", max_value=10), ... NumberControl("bar", "Insert bar") ... )
>>> resp = ModeSelected("foo", 'dfae1382-1746-4b5e-851e-93dff62b01ba', ... settings=c.to_input_field_suite(), ... resultDescription=OutputFieldSuite(betaArray = OutputField("array", name=["betaArray"])) ... )
>>> resp.resultDescription <OutputFieldSuite betaArray=<Result class=array name=['betaArray'] type=array metadata={} settings={}> >
>>> resp.__getstate__() == { ... 'settings': { ... 'foo': {'validations': {'max_value': 10}, 'live': False, 'metadata': {'label': 'Insert foo'}, 'name': 'foo', 'type': 'number', "order": 0}, ... 'bar': {'live': False, 'metadata': {'label': 'Insert bar'}, 'name': 'bar', 'type': 'number', 'validations': {}, "order": 1} ... }, ... 'experimentId': 'dfae1382-1746-4b5e-851e-93dff62b01ba', ... 'mode': 'foo', ... 'resultDescription': { ... 'betaArray': {'metadata': {}, 'class': 'array', 'settings': {}, 'name': ['betaArray'], 'type': 'array'}}} True
Check Equality:
>>> resp == ModeSelected.from_dict(resp.__getstate__()) True
>>> resp = ModeSelected("foo", 'dfae1382-1746-4b5e-851e-93dff62b01ba', ... settings=c, ... resultDescription=OutputFieldSuite(betaArray = OutputField("array", name=["betaArray"])) ... )
-
DICT_CONTENTS
= {'mode', 'settings', 'resultDescription', 'experimentId'}¶
-
getstate
()¶
-
setstate
(state)¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
SeriesStartedStanza
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Message sent when we start the single measurement session..
>>> settings_set = SettingSuite( ... foo = Setting(value = 13), ... bar = Setting(value= "Kotek!", current=True) ... ) >>> series_started = SeriesStartedStanza(seriesId = "fac96014-e88f-4bab-af2c-32fd0cf14d20", initialSettings=settings_set, label="Seria z foo=12") >>> series_started <SeriesStartedStanza initialSettings=<SettingSuite bar=<Setting current=True value=Kotek! > foo=<Setting current=False value=13 > > metadata={'label': 'Seria z foo=12'} seriesId=fac96014-e88f-4bab-af2c-32fd0cf14d20 > >>> series_started.__getstate__() == {'initialSettings': {'foo': {'current': False, 'value': 13}, 'bar': {'current': True, 'value': 'Kotek!'}}, 'metadata': {'label': 'Seria z foo=12'}, 'seriesId': 'fac96014-e88f-4bab-af2c-32fd0cf14d20'} True
Test equality:
>>> series_started == SeriesStartedStanza.from_dict(series_started.__getstate__()) True
-
DEFAULTS
= {'metadata': {}}¶
-
DICT_CONTENTS
= {'metadata', 'initialSettings', 'seriesId'}¶
-
getstate
()¶
-
initialSettings
= <SettingSuite >¶
-
label
¶
-
seriesId
= ''¶
-
setstate
(state)¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
Result
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Single result type.
>>> res = Result(value = [1, 2, 3, 4], pragma = "transient") >>> res.__getstate__() == {'pragma': 'transient', 'value': [1, 2, 3, 4]} True >>> res.__setstate__({"value" : "foobar"}) >>> res <Result pragma=append value=foobar > >>> res.__getstate__() == {'pragma': 'append', 'value': 'foobar'} True >>> res = Result(value = [[1, 1], [2, 2]], pragma="transient") >>> res.__getstate__() == {'pragma': 'transient', 'value': [[1, 1], [2, 2]]} True
-
DEFAULTS
= {'pragma': 'append'}¶
-
DEFAULT_PRAGMA
= 'append'¶
-
DICT_CONTENTS
= {'value', 'pragma'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ResultSuite
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.FlatDictJsonMapped
Set of results.
>>> suite = ResultSuite(foo = Result(value = [1, 2, 3, 4]), bar = Result(value = True)) >>> suite.__getstate__() == {'foo': {'value': [1, 2, 3, 4], 'pragma': 'append'}, 'bar': {'value': True, 'pragma': 'append'}} True
-
INTERNAL_DICT_NAME
= 'results'¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ResultsStanza
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Message containing a set of results sent to user.
>>> results_stanza = ResultsStanza(seriesId = "96beeb7e-3209-400a-892a-bf3201aa4658", results = ResultSuite(foo = Result(value = [1, 2, 3, 4]), bar = Result(value = True))) >>> results_stanza.__getstate__() == {'seriesId': '96beeb7e-3209-400a-892a-bf3201aa4658', 'results': {'foo': {'value': [1, 2, 3, 4], 'pragma': 'append'}, 'bar': {'value': True, 'pragma': 'append'}}} True >>> results_stanza2 = ResultsStanza.from_dict({'seriesId': '96beeb7e-3209-400a-892a-bf3201aa4658', 'results': {'foo': {'value': [1, 2, 3, 4], 'pragma': 'append'}, 'bar': {'value': True, 'pragma': 'append'}}}) >>> results_stanza == results_stanza2 True
-
DICT_CONTENTS
= {'results', 'seriesId'}¶
-
getstate
()¶
-
setstate
(state)¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
CheckStateStanza
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Response for checking of experiment state.
>>> state = CheckStateStanza(state = "off") >>> state.__getstate__() == {'seriesId': None, 'state': 'off', 'experimentId': None} True >>> state = CheckStateStanza(state = "off", experimentId = 'f5d1762e-f528-4ca1-bee4-97512c22ae6a', seriesId = 'eeb23307-69dc-4745-83da-db22f3dfa557') >>> state.__getstate__() == {'seriesId': 'eeb23307-69dc-4745-83da-db22f3dfa557', 'state': 'off', 'experimentId': 'f5d1762e-f528-4ca1-bee4-97512c22ae6a'} True
Check equality:
>>> state == CheckStateStanza.from_dict(state.__getstate__()) True
-
DEFAULTS
= {'seriesId': None, 'experimentId': None}¶
-
DICT_CONTENTS
= {'experimentId', 'state', 'seriesId'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
SeriesStopped
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Sent when someone stops series
>>> state = SeriesStopped(seriesId = "f5d1762e-f528-4ca1-bee4-97512c22ae6a") >>> state.__getstate__() == {'seriesId': 'f5d1762e-f528-4ca1-bee4-97512c22ae6a'} True
-
DEFAULTS
= {'seriesId': None}¶
-
DICT_CONTENTS
= {'seriesId'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
VideoElement
(video_type=None, camera_url=None, label=None, **kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._misc.OutputField
>>> video = VideoElement("image", "http://someserver/path") >>> video.__getstate__() == {'name': [], 'type': 'array', 'metadata': {}, 'settings': {'camera_type': 'image', 'camera_url': 'http://someserver/path'}, 'class': 'camera'} True
-
camera_type
¶
-
camera_url
¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ProtocolVersions
(version_list)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
-
DEFAULTS
= {'versions': None}¶
-
DICT_CONTENTS
= {'versions'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
ProtocolVersion
(**kwargs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
-
DEFAULTS
= {'version': None}¶
-
DICT_CONTENTS
= {'version'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
Language
(lang)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Represents single language chosen by experiment in which user data is translated
-
DICT_CONTENTS
= {'lang'}¶
-
-
class
silf.backend.commons.api.stanza_content._misc.
Languages
(langs)¶ Bases:
silf.backend.commons.api.stanza_content._json_mapper.JsonMapped
Represents stanza with list of possible languages used by user
-
DICT_CONTENTS
= {'langs'}¶
-