diff options
author | Brian Waldon <bcwaldon@gmail.com> | 2012-06-01 15:00:38 -0700 |
---|---|---|
committer | Brian Waldon <bcwaldon@gmail.com> | 2012-06-01 15:00:38 -0700 |
commit | 96ef8b7a5faa6b8c744e658f33923cb571f50564 (patch) | |
tree | c4793b928e95febe24e5f279feef5a1ef47b8aa7 /warlock | |
parent | 4160dc4e65dc4c5c8ba2f2245512586490072f60 (diff) | |
download | warlock-96ef8b7a5faa6b8c744e658f33923cb571f50564.tar.gz |
Add basic test and implement minimal logic
Diffstat (limited to 'warlock')
-rw-r--r-- | warlock/__init__.py | 1 | ||||
-rw-r--r-- | warlock/core.py | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/warlock/__init__.py b/warlock/__init__.py index e69de29..2bdde37 100644 --- a/warlock/__init__.py +++ b/warlock/__init__.py @@ -0,0 +1 @@ +from core import Class diff --git a/warlock/core.py b/warlock/core.py new file mode 100644 index 0000000..741d137 --- /dev/null +++ b/warlock/core.py @@ -0,0 +1,21 @@ +#import jsonschema + + +def Class(schema): + class schema_class(object): + def __init__(self, **kwargs): + self.__dict__['raw'] = kwargs + + def __getattr__(self, key): + try: + return self.__dict__['raw'][key] + except KeyError: + raise AttributeError(key) + + def __setattr__(self, key, value): + if key in self.__dict__['raw']: + self.__dict__['raw'][key] = value + else: + raise AttributeError(key) + + return schema_class |