import argparse import json import os import configparser if __name__ == '__main__': parser = argparse.ArgumentParser(description='calculation of a system according to Bös', prog='cremig') parser.add_argument('-i', '--infile', action='store', help='name of the input file', default="jayjay.cfg") parser.add_argument('-x', '--xlsx', action='store', help='name of the output .xlsx file. If none given, name of the input file is used.') parser.add_argument('-c', '--config', action='store', help='name of the config file inside of cfg folder to use. Default is Sivas_Daten.cfg', default="Sivas_Daten.cfg") parser.add_argument('-j', '--json', action='store', help='name of the json file as output. If none given, name of the input file is used. ') args = parser.parse_args() sivasCfgFilePath = os.path.join(os.environ.get('ECALC_CFG'), args.config) RieterConfig = cfg(sivasCfgFilePath) inFilePath = os.path.join(os.environ.get('ECALC_WORK'), args.infile) if os.path.isfile(inFilePath): (fname, ext) = os.path.splitext(args.infile) (mg, eas, hw, emo, dl, erg) = run_calc(inFilePath, RieterConfig) if args.xlsx: xlsPath = os.path.join(os.environ.get('ECALC_WORK'), args.xlsx) else: xlsPath = os.path.join(os.environ.get('ECALC_WORK'), fname + '.xlsx') to_excel(mg, eas, hw, emo, dl, erg, xlsPath) if args.json: jsonPath = os.path.join(os.environ.get('ECALC_WORK'), args.json) else: jsonPath = os.path.join(os.environ.get('ECALC_WORK'), fname + '.json') to_json(mg, eas, hw, emo, dl, erg, jsonPath) else: print("no such file in ECALC_WORK") # os.environ.get('ECALC_BIN') # os.environ.get('ECALC_WORK') # os.environ.get('ECALC_CFG') # os.environ.get('ECALC_LIB')