diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2020-04-21 15:48:24 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2020-04-21 15:48:24 +0200 |
| commit | 5c07eda3fa0e48c7b8337f8b57b8390da86ee6d7 (patch) | |
| tree | 91c2dfa66e00a35c0fe72a04dea4f5f39c0f442f /src/resource.py | |
Init project
Diffstat (limited to 'src/resource.py')
| -rw-r--r-- | src/resource.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/resource.py b/src/resource.py new file mode 100644 index 0000000..f521022 --- /dev/null +++ b/src/resource.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +from os import path +import json, jsonschema + + +class Resource: + def __init__(self, resource): + self.resource=resource + # Read data + try: + with open(resource,'r') as f: + self.data=f.read() + except IOError: + print("Unable to found "+resource) + exit(1) + # Decode data + try: + self.json=json.loads(self.data) + except: + print("Unable to read json from "+resource) + exit(1) + |
