aboutsummaryrefslogtreecommitdiff
path: root/libs/resource.py
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2020-04-21 17:50:05 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2020-04-21 17:50:05 +0200
commit5c0cc8e2f4fd632445079abc7af1b65ca0d3a8e0 (patch)
tree09c9629b24d848f648cbd6d00090c659035ef778 /libs/resource.py
parent5c07eda3fa0e48c7b8337f8b57b8390da86ee6d7 (diff)
Create package
Diffstat (limited to 'libs/resource.py')
-rw-r--r--libs/resource.py23
1 files changed, 23 insertions, 0 deletions
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)
+