From 22b62d7a2fbbef453562c9c3738bb1a0c5f6db7c Mon Sep 17 00:00:00 2001 From: Mike Gerber Date: Wed, 27 Nov 2024 18:48:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Remove=20output=20files=20before?= =?UTF-8?q?=20writing=20them=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mods4pandas/mods4pandas.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mods4pandas/mods4pandas.py b/src/mods4pandas/mods4pandas.py index aae282d..215acd0 100755 --- a/src/mods4pandas/mods4pandas.py +++ b/src/mods4pandas/mods4pandas.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import contextlib import csv import logging import os @@ -401,10 +402,14 @@ def process(mets_files: List[str], output_file: str, output_page_info: str): # Process METS files output_file_sqlite3 = output_file + ".sqlite3" + with contextlib.suppress(FileNotFoundError): + os.remove(output_file_sqlite3) con = sqlite3.connect(output_file_sqlite3) if output_page_info: output_page_info_sqlite3 = output_page_info + ".sqlite3" + with contextlib.suppress(FileNotFoundError): + os.remove(output_page_info_sqlite3) con_page_info = sqlite3.connect(output_page_info_sqlite3) with open(output_file + '.warnings.csv', 'w') as csvfile: