From 5c1004928e0ebd1347a93ab23f2ab1b3cb62440a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Fri, 24 Jun 2016 08:46:52 +0200 Subject: Imported Upstream version 1.0.8 --- python/fisx/DataDir.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'python/fisx') diff --git a/python/fisx/DataDir.py b/python/fisx/DataDir.py index a67f15d..16ee9a5 100644 --- a/python/fisx/DataDir.py +++ b/python/fisx/DataDir.py @@ -28,7 +28,7 @@ import os # this will be filled by the setup FISX_DATA_DIR = 'DATA_DIR_FROM_SETUP' -# This is to be filled by the setup +# this is to be filled by the setup FISX_DOC_DIR = 'DOC_DIR_FROM_SETUP' # what follows is only used in frozen versions if not os.path.exists(FISX_DATA_DIR): @@ -45,9 +45,9 @@ if not os.path.exists(FISX_DATA_DIR): # this is used in build directory if not os.path.exists(FISX_DATA_DIR): - tmp_dir = os.path.dirname(__file__) + tmp_dir = os.path.dirname(os.path.abspath(__file__)) old_tmp_dir = tmp_dir + "dummy" - basename = os.path.basename(FISX_DATA_DIR) + basename = "fisx_data" FISX_DATA_DIR = os.path.join(tmp_dir, "fisx", basename) while (len(FISX_DATA_DIR) > 14) and (tmp_dir != old_tmp_dir): if os.path.exists(FISX_DATA_DIR): @@ -57,7 +57,16 @@ if not os.path.exists(FISX_DATA_DIR): FISX_DATA_DIR = os.path.join(tmp_dir, "fisx", basename) if not os.path.exists(FISX_DATA_DIR): - raise IOError('%s directory not found' % basename) + FISX_DATA_DIR = os.getenv("FISX_DATA_DIR") + if FISX_DATA_DIR is not None: + if not os.path.exists(FISX_DATA_DIR): + raise IOError('%s directory set from environent not found' % FISX_DATA_DIR) + else: + txt = "WARNING: Taking FISX_DATA_DIR from environement.\n" + txt += "Use it at your own risk." + print(txt) + else: + raise IOError('%s directory not found' % basename) # do the same for the directory containing HTML files if not os.path.exists(FISX_DOC_DIR): @@ -71,13 +80,11 @@ if not os.path.exists(FISX_DOC_DIR): old_tmp_dir = tmp_dir tmp_dir = os.path.dirname(tmp_dir) FISX_DOC_DIR = os.path.join(tmp_dir, basename) -if not os.path.exists(FISX_DOC_DIR): - raise IOError('%s directory not found' % basename) if not os.path.exists(FISX_DOC_DIR): - tmp_dir = os.path.dirname(__file__) + tmp_dir = os.path.dirname(os.path.abspath(__file__)) old_tmp_dir = tmp_dir + "dummy" - basename = os.path.basename(FISX_DOC_DIR) + basename = "fisx_data" FISX_DOC_DIR = os.path.join(tmp_dir,basename) while (len(FISX_DOC_DIR) > 14) and (tmp_dir != old_tmp_dir): if os.path.exists(FISX_DOC_DIR): @@ -85,5 +92,12 @@ if not os.path.exists(FISX_DOC_DIR): old_tmp_dir = tmp_dir tmp_dir = os.path.dirname(tmp_dir) FISX_DOC_DIR = os.path.join(tmp_dir, "fisx", basename) + if not os.path.exists(FISX_DOC_DIR): - raise IOError('%s directory not found' % basename) + FISX_DOC_DIR = os.getenv("FISX_DOC_DIR") + if FISX_DOC_DIR is not None: + if not os.path.exists(FISX_DOC_DIR): + raise IOError('%s directory not found' % basename) + else: + # use the data dir as doc dir + FISX_DOC_DIR = FISX_DATA_DIR -- cgit v1.2.3