start building device forms
This commit is contained in:
@ -1,30 +0,0 @@
|
||||
from owrx.form import Input
|
||||
from owrx.controllers.settings import Section
|
||||
from typing import List
|
||||
|
||||
|
||||
class SdrDeviceDescriptionMissing(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class SdrDeviceDescription(object):
|
||||
@staticmethod
|
||||
def getByType(sdr_type: str) -> "SdrDeviceDescription":
|
||||
try:
|
||||
className = "".join(x for x in sdr_type.title() if x.isalnum()) + "DeviceDescription"
|
||||
module = __import__("owrx.source.{0}".format(sdr_type), fromlist=[className])
|
||||
cls = getattr(module, className)
|
||||
return cls()
|
||||
except (ModuleNotFoundError, AttributeError):
|
||||
raise SdrDeviceDescriptionMissing("Device description for type {} not available".format(sdr_type))
|
||||
|
||||
def getInputs(self) -> List[Input]:
|
||||
return []
|
||||
|
||||
def mergeInputs(self, *args):
|
||||
# build a dictionary indexed by the input id to make sure every id only exists once
|
||||
inputs = {input.id: input for input_list in args for input in input_list}
|
||||
return inputs.values()
|
||||
|
||||
def getSection(self):
|
||||
return Section("Device settings", *self.getInputs())
|
@ -1,7 +1,7 @@
|
||||
from owrx.controllers.admin import AuthorizationMixin
|
||||
from owrx.controllers.template import WebpageController
|
||||
from owrx.controllers.settings import SettingsFormController
|
||||
from owrx.controllers.settings.device import SdrDeviceDescription, SdrDeviceDescriptionMissing
|
||||
from owrx.source import SdrDeviceDescription, SdrDeviceDescriptionMissing
|
||||
from owrx.config import Config
|
||||
from urllib.parse import quote, unquote
|
||||
|
||||
|
Reference in New Issue
Block a user