From 5c0cc8e2f4fd632445079abc7af1b65ca0d3a8e0 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 21 Apr 2020 17:50:05 +0200 Subject: Create package --- libs/resource.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 libs/resource.py (limited to 'libs/resource.py') diff --git a/libs/resource.py b/libs/resource.py new file mode 100644 index 0000000..f521022 --- /dev/null +++ b/libs/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) + -- cgit v1.2.3