diff --git a/bin/cremig.bat b/bin/cremig.bat new file mode 100644 index 0000000..c8cf7bc --- /dev/null +++ b/bin/cremig.bat @@ -0,0 +1,2 @@ +call cremig_setenv.bat +python %CREMIG_LIB%\cremig.py %* diff --git a/bin/cremig_setenv.bat b/bin/cremig_setenv.bat new file mode 100644 index 0000000..d08f446 --- /dev/null +++ b/bin/cremig_setenv.bat @@ -0,0 +1,11 @@ +@echo off +set CREMIG=C:\Users\%USERNAME%\Documents\10-Develop\CreoMigrate +set CREMIG_BIN=%CREMIG%\bin +set CREMIG_WORK=%CREMIG%\work +set CREMIG_CFG=%CREMIG%\cfg +set CREMIG_LIB=%CREMIG%\lib +set CREMIG_LOG=%CREMIG%\log + +set PATH=%CREMIG%\bin;%PATH% +REM PYTHON_INCLUDE_DIR +REM PYTHON_LIBRARY diff --git a/lib/cremig.py b/lib/cremig.py new file mode 100644 index 0000000..49b74ec --- /dev/null +++ b/lib/cremig.py @@ -0,0 +1,47 @@ +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') + + + + +