aboutsummaryrefslogtreecommitdiff
path: root/bcst/resource.py
blob: 342e08a27203aa6895200962e689219cdb1d2571 (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


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)