aboutsummaryrefslogtreecommitdiff
path: root/src/resource.py
blob: f5210229bfd963d0657f80e40600992f5211d02a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)