diff --git a/SiliconTorch/DecoratorTest.py b/SiliconTorch/DecoratorTest.py new file mode 100644 index 0000000000000000000000000000000000000000..f786f0ba89357402cec38e217f891d617ee306b5 --- /dev/null +++ b/SiliconTorch/DecoratorTest.py @@ -0,0 +1,42 @@ + + + +class MyDec: + + def __init__(*args, **kwargs): + print(f'__init__ed with: {args} aaand: {kwargs}') + + def __call__(self, *args, **kwargs): + print(f'called with: {args} aaand: {kwargs}') + + if callable(args[0]): + print('used as decorated with arguments') + return self.execute + else: + print('used as decorator WITHOUT arguments (a long time ago ;) )') + self.execute() + + def execute(*args, **kwargs): + print(f'executed with: {args} aaand: {kwargs}') + + + +class C: + + @MyDec + def decorated0(self, *args): + print(f'decorated0 called with: {args}') + return 'decorated0' + +print('\n' + '-'*120 + '\n') + +class D: + + @MyDec(name='ctor-test') + def decorated42(self, *args): + print(f'decorated42 called with: {args}') + return 'decorated42' + + +c = C() +d = D() diff --git a/SiliconTorch/Device.py b/SiliconTorch/Device.py index a14948a9b959effdc760f6409f3863c4d90c5334..f687df7220e4f3dd7dc938098c97f4d9920121e6 100644 --- a/SiliconTorch/Device.py +++ b/SiliconTorch/Device.py @@ -3,6 +3,9 @@ from typing import Any, Callable +# TODO: dev is stalled! +# at first, we'll design easier things to not loose focus on the project +# Just use simple properties and triggers to get the same (write-only) behavior class MQTTProperty: def __init__(self, name: str = None, initialValue: Any = None, getConvert: Callable[[str], Any] = None, setConvert: Callable[[Any], str] = None, readOnly = False): @@ -49,6 +52,27 @@ class MQTTProperty: + +class MQTTTrigger: + + def __init__(self): + pass + + + + + + + + + + + + + + + + class Device: def __init__(self, torch, name, online = True):