diff --git a/lib/update_database.py b/lib/update_database.py index 02619d9..33b1e93 100644 --- a/lib/update_database.py +++ b/lib/update_database.py @@ -82,7 +82,7 @@ def get_sivas_dbase(sivas_id, out_dir): print(f"Can't execute SIVAS-database query. Check VPN connection and check the path of %SIVAS_DATABASE_QUERY% in cremig_setenv.bat") return False -def get_sivas_teilestamm(sivas_ids, out_dir): +def get_sivas_teilestamm(sivas_ids, out_dir, overwrite=True): """call the sivas exe for getting all csv files with the item data for the given sivas ids""" sivas_teilestamm_exe = os.environ.get('SIVAS_TEILESTAMM') @@ -92,9 +92,13 @@ def get_sivas_teilestamm(sivas_ids, out_dir): ids_to_generate = [] for id in sivas_ids: - id = id.replace(" ", "") - out_file = os.path.join(out_dir, id + ".csv") - if not os.path.isfile(out_file): + id = id.replace(" ", "") + if not overwrite: + out_file = os.path.join(out_dir, id + ".csv") + if not os.path.isfile(out_file): + ids_to_generate.append(id) + continue + else: ids_to_generate.append(id) if not id.isnumeric(): @@ -127,6 +131,7 @@ if __name__ == '__main__': parser.add_argument('-r', '--rd', action='store_true', help='fetch list of existing parts from network drive') parser.add_argument('-b', '--blacklist', action='store_true', help='fetch list of not allowed parts from network drive') parser.add_argument('-t', '--teilestamm', action='store_true', help='fetch teilestamm-data for given partnumbers as csv') + parser.add_argument('-w', '--overwrite', action='store_true', help='vorhandene CSV-Dateien werden nicht erneut aus SIVAS abgefragt') args = parser.parse_args() @@ -138,8 +143,13 @@ if __name__ == '__main__': elif args.sivasid: if args.teilestamm: - get_sivas_teilestamm(args.sivasid, out_dir) + overwrite = args.overwrite + if overwrite: + get_sivas_teilestamm(args.sivasid, out_dir, overwrite = True) + else: + get_sivas_teilestamm(args.sivasid, out_dir, overwrite = False) + else: get_sivas_dbase(args.sivasid, out_dir)