commit e9723efb174de56a9d0d32a219bd2bf8ba705c1e
parent 15e582f17bf71b44bd5fa0ce78d2ed860985a9b7
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Sun, 3 Jan 2021 15:11:04 -0600
added naive functions for filer
Diffstat:
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/filer.py b/src/filer.py
@@ -17,5 +17,23 @@ class Filer(object):
writing to the various files that OPET uses
and/or edits.
"""
- def __init__(self, manager):
+ def __init__(self, manager, environment_file):
self.manager = manager
+ self.environment_file = environment_file
+ self.environment = self.read_json(self.environment_file)
+
+ def read_raw_file(self, filename):
+ with open(filename, "r") as f:
+ return f.read()
+
+ def read_json(self, jsonfile):
+ with open(jsonfile, "r") as j:
+ return json.load(j)
+
+ def write_raw_file(self, filename, string):
+ with open(filename, "w") as f:
+ f.write(string)
+
+ def write_json(self, jsonfile, jsondata):
+ with open(filename, "w") as j:
+ json.dump(jsondata, j)
diff --git a/src/opet.py b/src/opet.py
@@ -22,7 +22,7 @@ class OPET(object):
def __init__(self):
# Various tools
- self.filer = filer.Filer(self)
+ self.filer = filer.Filer(self, "environment.json")
self.esp_tool = tools.DataPackTool(self)
# Load up app