Skip to content

Instantly share code, notes, and snippets.

@fredyr
Created March 27, 2017 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredyr/432b082681fa4302e7e6c95e98048964 to your computer and use it in GitHub Desktop.
Save fredyr/432b082681fa4302e7e6c95e98048964 to your computer and use it in GitHub Desktop.
import inspect
from urllib.parse import urlparse
class ParameterSet:
pass
class Field:
def __init__(self, description, **kwargs):
self.params = kwargs
self.params['description'] = description
def __str__(self):
return str(self.params)
class URL:
def __init__(self, url):
self.original_url = url
self.url = urlparse(url)
class IntegerField(Field):
pass
class FloatField(Field):
pass
class VHF(ParameterSet):
url = URL('file:///tmp/vhf/')
threshold_level = FloatField('Threshold level in V when VHF triggers',
min_value=0.0, max_value=600.0, default_value=55.3)
rms_integator_time = IntegerField('Integrator time in ms',
min_value=0, max_value=20000)
vhf_members = inspect.getmembers(VHF, lambda x: isinstance(x, Field))
print([(name, str(obj)) for name, obj in vhf_members])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment