Created
March 27, 2017 18:52
-
-
Save fredyr/432b082681fa4302e7e6c95e98048964 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Migrations blog post
https://realpython.com/blog/python/django-migrations-a-primer/
Migrations docs
https://docs.djangoproject.com/en/1.10/topics/migrations/
Migrations implementation
https://github.com/django/django/tree/master/django/db/migrations