From 689998d71f7b25ea12362c596fb54ca232a1e973 Mon Sep 17 00:00:00 2001 From: bel Date: Tue, 21 Feb 2023 12:51:28 -0700 Subject: [PATCH] configurable output temp dir --- cluster.py | 3 ++- config.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cluster.py b/cluster.py index c60ebb9..4138bcb 100644 --- a/cluster.py +++ b/cluster.py @@ -96,7 +96,8 @@ class Chars: modified_page.mediabox.lower_right = (bounds.x0, bounds.y1) modified_page.mediabox.lower_left = (bounds.x1, bounds.y1) modified_writer.add_page(modified_page) - modified_path = "/tmp/{}-{:03d}-{}.modified.pdf".format( + modified_path = "{}/{}-{:03d}-{}.modified.pdf".format( + config.TEMP_DIR, self.path.split("/")[-1], self.page.page_number, j, diff --git a/config.py b/config.py index 604ee63..2b908a4 100644 --- a/config.py +++ b/config.py @@ -4,3 +4,5 @@ DEBUG = os.environ.get("DEBUG", "") DEBUG_NO_SHOW = os.environ.get("DEBUG_NO_SHOW", "") DEBUG_HEIGHT = int(os.environ.get("DEBUG_HEIGHT", "800")) INPUT = os.environ.get("INPUT", "./testdata/input.pdf") +TEMP_DIR = os.environ.get("TEMP_DIR", "/tmp/dnd-pdf-to-txt.d") +os.makedirs(TEMP_DIR, exist_ok=True)