<s> from smartanthill . api . handler import APIPermission <EOL> from smartanthill . device . api import APIDeviceHandlerBase <EOL> from smartanthill . device . arg import PinArg , PinLevelArg <EOL> from smartanthill . device . operation . base import OperationBase , OperationType <EOL> class APIHandler ( APIDeviceHandlerBase ) : <EOL> PERMISSION = APIPermission . UPDATE <EOL> KEY = "<STR_LIT>" <EOL> REQUIRED_PARAMS = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def handle ( self , data ) : <EOL> return self . launch_operation ( data [ '<STR_LIT>' ] , <EOL> OperationType . WRITE_DIGITAL_PIN , data ) <EOL> class Operation ( OperationBase ) : <EOL> TYPE = OperationType . WRITE_DIGITAL_PIN <EOL> def process_data ( self , data ) : <EOL> args = [ ] <EOL> for _key , _value in data . items ( ) : <EOL> if "<STR_LIT>" not in _key : <EOL> continue <EOL> pinarg = PinArg ( * self . board . get_pinarg_params ( ) ) <EOL> pinlevelarg = PinLevelArg ( ) <EOL> pinarg . set_value ( _key [ <NUM_LIT:4> : - <NUM_LIT:1> ] ) <EOL> pinlevelarg . set_value ( _value ) <EOL> args += [ pinarg , pinlevelarg ] <EOL> return [ a . get_value ( ) for a in args ] </s>
