From a7f5d93bec04b9142c8a14fb17a5059f069c6326 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 5 Jan 2022 09:43:41 +0300 Subject: Check for path existence Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi --- gn3/db/correlations.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gn3/db') diff --git a/gn3/db/correlations.py b/gn3/db/correlations.py index 5361a1e..d372607 100644 --- a/gn3/db/correlations.py +++ b/gn3/db/correlations.py @@ -29,8 +29,11 @@ def get_filename(conn: Any, target_db_name: str, text_files_dir: str) -> Union[ filename = "ProbeSetFreezeId_{tid}_FullName_{fname}.txt".format( tid=result[0], fname=result[1].replace(' ', '_').replace('/', '_')) - return ((filename in os.listdir(text_files_dir)) - and f"{text_files_dir}/{filename}") + full_filename = f"{text_files_dir}/{filename}" + return ( + os.path.exists(full_filename) and + (filename in os.listdir(text_files_dir)) and + full_filename) return False -- cgit v1.2.3