Code refactor
This commit is contained in:
@@ -128,6 +128,20 @@ class Output:
|
|||||||
return usages
|
return usages
|
||||||
|
|
||||||
|
|
||||||
|
def dump(self, cache: bool = False) -> str:
|
||||||
|
data = {}
|
||||||
|
data |= { 'version' : self.version() }
|
||||||
|
data |= { 'net_size' : self.net_size() }
|
||||||
|
data |= { 'units' : self.units() }
|
||||||
|
data |= { 'times' : self.times() }
|
||||||
|
data |= { 'element_name' : self.element_name() }
|
||||||
|
data |= { 'energy_usage' : self.energy_usage() }
|
||||||
|
if cache:
|
||||||
|
with open(self.opt + '.json', 'w') as f:
|
||||||
|
json.dump(data, f)
|
||||||
|
return json.dumps(data)
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
# throw exception in destructor ? :)
|
# throw exception in destructor ? :)
|
||||||
self._check(self._lib.ENR_close(ctypes.byref(self._handle)))
|
self._check(self._lib.ENR_close(ctypes.byref(self._handle)))
|
||||||
@@ -135,16 +149,7 @@ class Output:
|
|||||||
|
|
||||||
def _read_output(name: str) -> str:
|
def _read_output(name: str) -> str:
|
||||||
opt = Output(name)
|
opt = Output(name)
|
||||||
data = {}
|
return opt.dump()
|
||||||
data |= { 'version' : opt.version() }
|
|
||||||
data |= { 'net_size' : opt.net_size() }
|
|
||||||
data |= { 'units' : opt.units() }
|
|
||||||
data |= { 'times' : opt.times() }
|
|
||||||
data |= { 'element_name' : opt.element_name() }
|
|
||||||
data |= { 'energy_usage' : opt.energy_usage() }
|
|
||||||
with open(opt.opt + '.json', 'w') as f:
|
|
||||||
json.dump(data, f)
|
|
||||||
return json.dumps(data)
|
|
||||||
|
|
||||||
|
|
||||||
def run_project(name: str) -> str:
|
def run_project(name: str) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user