mehrere oft verwendete Routinen in eigene utils.py eingebaut
This commit is contained in:
+2
-16
@@ -8,24 +8,10 @@ import os
|
||||
import configparser
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from utils import load_json, to_json, write_results
|
||||
|
||||
|
||||
# Funktionen
|
||||
def load_json(jsonfilename):
|
||||
with open(jsonfilename, encoding='utf-8') as fh:
|
||||
return json.load(fh)
|
||||
|
||||
def write_results(jsnResults, outdir, filename):
|
||||
""" write results to a json file
|
||||
"""
|
||||
print("writing results to a json file ...")
|
||||
outfile = Path(outdir) / filename
|
||||
with open(outfile, 'w', encoding='utf-8') as fh:
|
||||
fh.write(jsnResults)
|
||||
print("done")
|
||||
|
||||
def to_json(d, pretty: bool = True) -> str:
|
||||
return json.dumps(d, indent=2 if pretty else None, ensure_ascii=False, default=str) #ensure_ascii false für darstellung von "ue"
|
||||
|
||||
def create_plant(racks:dict, sensors:dict, distributors:dict, mapping:dict, tunnels: dict, tunlength:dict ) -> dict:
|
||||
|
||||
# racks = {'Rack_1-0': [Point(0, 0), Point(0, 10)],
|
||||
|
||||
Reference in New Issue
Block a user