diff --git a/examples/simple_extensions.py b/examples/simple_extensions.py index 4c3c6617..955bc806 100644 --- a/examples/simple_extensions.py +++ b/examples/simple_extensions.py @@ -1,18 +1,11 @@ -from labthings.monkey import patch_all - -patch_all() - import logging import math import random import time -from labthings.core.utilities import path_relative_to -from labthings.server import fields -from labthings.server.extensions import BaseExtension -from labthings.server.find import find_component -from labthings.server.quick import create_app -from labthings.server.view import ActionView, PropertyView +from labthings import ActionView, PropertyView, create_app, fields, find_component +from labthings.extensions import BaseExtension +from labthings.utilities import path_relative_to logging.basicConfig(level=logging.DEBUG) diff --git a/examples/simple_thing.py b/examples/simple_thing.py index 851b32e0..653b0da4 100644 --- a/examples/simple_thing.py +++ b/examples/simple_thing.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import time -from labthings import create_app, fields, find_component, semantics +from labthings import create_app, fields, find_component from labthings.example_components import PretendSpectrometer from labthings.json import encode_json from labthings.views import ActionView, PropertyView, op @@ -19,10 +19,12 @@ # Wrap in a semantic annotation to autmatically set schema and args -@semantics.moz.LevelProperty(100, 500, example=200) class DenoiseProperty(PropertyView): """Value of integration_time""" + schema = fields.Int(required=True, minimum=100, maximum=500) + semtype = "LevelProperty" + @op.readproperty def get(self): # When a GET request is made, we'll find our attached component diff --git a/src/labthings/semantics/__init__.py b/src/labthings/semantics/__init__.py deleted file mode 100644 index 629579c6..00000000 --- a/src/labthings/semantics/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import moz -from .base import Semantic diff --git a/src/labthings/semantics/base.py b/src/labthings/semantics/base.py deleted file mode 100644 index e4aa3070..00000000 --- a/src/labthings/semantics/base.py +++ /dev/null @@ -1,21 +0,0 @@ -class Semantic: - """ """ - - def __call__(self, viewcls): - # Use the class name as the semantic type - viewcls.semtype = self.__class__.__name__ - return viewcls - - -# BASIC PROPERTIES -class Property(Semantic): - """ """ - - def __init__(self, schema): - self.schema = schema - - def __call__(self, viewcls): - # Use the class name as the semantic type - viewcls.semtype = self.__class__.__name__ - viewcls.schema = self.schema - return viewcls diff --git a/src/labthings/semantics/moz.py b/src/labthings/semantics/moz.py deleted file mode 100644 index 913ecca0..00000000 --- a/src/labthings/semantics/moz.py +++ /dev/null @@ -1,37 +0,0 @@ -from .. import fields -from .base import Property - - -# BASIC PROPERTIES -class BooleanProperty(Property): - """https://iot.mozilla.org/schemas/#BooleanProperty""" - - def __init__(self, **kwargs): - schema = fields.Bool(required=True, **kwargs) - Property.__init__(self, schema) - - -class LevelProperty(Property): - """https://iot.mozilla.org/schemas/#LevelProperty""" - - def __init__(self, minimum, maximum, **kwargs): - schema = fields.Int(required=True, minimum=minimum, maximum=maximum, **kwargs,) - - Property.__init__(self, schema) - - -# INHERITED PROPERTIES - - -class BrightnessProperty(LevelProperty): - """https://iot.mozilla.org/schemas/#BrightnessProperty""" - - def __init__(self, **kwargs): - LevelProperty.__init__(self, 0, 100, unit="percent", **kwargs) - - -class OnOffProperty(BooleanProperty): - """https://iot.mozilla.org/schemas/#OnOffProperty""" - - def __init__(self, **kwargs): - BooleanProperty.__init__(self, **kwargs)