Mit curser weiter bearbeitet. Schaltschrankelemente werden jettz auch von getpositions raus geschrieben
This commit is contained in:
+12
-7
@@ -10,6 +10,7 @@ from shapely.geometry import LineString, Point
|
||||
from shapely.ops import nearest_points
|
||||
from plant import Anlage
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# Funktionen
|
||||
@@ -21,7 +22,7 @@ def write_results(jsnResults, outdir, filename):
|
||||
""" write results to a json file
|
||||
"""
|
||||
print("writing results to a json file ...")
|
||||
outfile = os.path.join(outdir, filename)
|
||||
outfile = Path(outdir) / filename
|
||||
with open(outfile, 'w', encoding='utf-8') as fh:
|
||||
fh.write(jsnResults)
|
||||
print("done")
|
||||
@@ -171,20 +172,24 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
|
||||
# Umgebungsvariablen
|
||||
work_dir = os.environ.get("PROJECT_WORK")
|
||||
config_dir = os.environ.get("PROJECT_CFG")
|
||||
work_dir_env = os.environ.get("PROJECT_WORK")
|
||||
config_dir_env = os.environ.get("PROJECT_CFG")
|
||||
if work_dir_env is None or config_dir_env is None:
|
||||
raise RuntimeError("PROJECT_WORK or PROJECT_CFG environment variable not set.")
|
||||
work_dir = Path(work_dir_env)
|
||||
config_dir = Path(config_dir_env)
|
||||
|
||||
# Pfade zu JSON-Dateien
|
||||
jsonfilename = args.filename
|
||||
sensors_path = os.path.join(work_dir, jsonfilename)
|
||||
sensors_path = work_dir / jsonfilename
|
||||
|
||||
# Einlesen und Vorbereiten der Daten
|
||||
rawdata = load_json(sensors_path)
|
||||
(racks, sensors, subdists, mapping, tunnels, tunlength, errors_dists, errors_sensors, errors_attributes) = prepare_data(rawdata)
|
||||
|
||||
config = configparser.ConfigParser(allow_no_value=True, delimiters=("="))
|
||||
config.optionxform = lambda option: option # preserve case for letters
|
||||
config.read(os.path.join(config_dir, "allgemein.cfg"))
|
||||
config.optionxform = lambda optionstr: optionstr # preserve case for letters
|
||||
config.read(str(config_dir / "allgemein.cfg"))
|
||||
|
||||
|
||||
# virtuelle Anlage erstellen
|
||||
@@ -200,7 +205,7 @@ if __name__ == "__main__":
|
||||
|
||||
# Ausgabe schreiben
|
||||
if args.write:
|
||||
basename = os.path.splitext(args.write)[0]
|
||||
basename = Path(args.write).stem
|
||||
cable_paths["errors_dists_not_in_layout"] = errors_dists
|
||||
cable_paths["errors_sensors_not_in_layout"] = errors_sensors
|
||||
cable_paths["errors_missing_attributes"] = errors_attributes
|
||||
|
||||
Reference in New Issue
Block a user