From ff638e269d439c853b5182b68ff10777f12597f1 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sun, 5 Feb 2023 13:55:00 +1100 Subject: Use relative imports between data generation scripts Avoids the need for code that modifies sys.path, but requires running of the scripts using 'python -m' with backend/ as cwd. Also expects constants like DB_FILE to be non-relative, due to running from backend/. --- backend/hist_data/gen_imgs.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'backend/hist_data/gen_imgs.py') diff --git a/backend/hist_data/gen_imgs.py b/backend/hist_data/gen_imgs.py index 44c0020..8860fe0 100755 --- a/backend/hist_data/gen_imgs.py +++ b/backend/hist_data/gen_imgs.py @@ -19,10 +19,11 @@ import signal import sqlite3 import urllib.parse -IMG_DIR = os.path.join('enwiki', 'imgs') -IMG_DB = os.path.join('enwiki', 'img_data.db') -OUT_DIR = 'img' -DB_FILE = 'data.db' +DATA_DIR = os.path.dirname(os.path.realpath(__file__)) +IMG_DIR = os.path.join(DATA_DIR, 'enwiki', 'imgs') +IMG_DB = os.path.join(DATA_DIR, 'enwiki', 'img_data.db') +OUT_DIR = os.path.join(DATA_DIR, 'img') +DB_FILE = os.path.join(DATA_DIR, 'data.db') IMG_OUT_SZ = 200 -- cgit v1.2.3