X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=gdcmPython%2F__init__.py;h=dcad484cb23efa8365c080bd12deb841451ba881;hb=fc4e699091cd861dc45f93ef3fb5530cc05ec2e2;hp=a4c36f33062ebd1fdd2d24a85fa9cc286001f6b5;hpb=056201f7ae914314059ccb136d35c674a0ad9e0b;p=gdcm.git diff --git a/gdcmPython/__init__.py b/gdcmPython/__init__.py index a4c36f33..dcad484c 100644 --- a/gdcmPython/__init__.py +++ b/gdcmPython/__init__.py @@ -1,6 +1,6 @@ import os, sys -def BuildInstallOrPreinstallPath(DirName, FileName): +def BuildInstallOrPreinstallPath(DirName, FileName = None): # Builds a path to the DirName directory. This should work both when: # - the package is properly installed in which case DirName is a subdir # of the package, @@ -10,18 +10,27 @@ def BuildInstallOrPreinstallPath(DirName, FileName): # In both cases we need to express the full path to DirName relatively # to the path to this __init__.py. For this we rely on __path__ variable. # In order to make sure we got the correct Path, we check for the - # existence of FileName. + # existence of FileName if it is setted otherwise for the existence of the + # DirName. InstallModePath = os.path.join(__path__[0], DirName + "/") - if os.path.isfile(os.path.join(InstallModePath, FileName)): - return InstallModePath + if(FileName): + if os.path.isfile(os.path.join(InstallModePath, FileName)): + return InstallModePath + else: + if os.path.isdir(InstallModePath): + return InstallModePath + PreInstallModePath = os.path.join(__path__[0], "..", DirName + "/") - if os.path.isfile(os.path.join(PreInstallModePath, FileName)): - return PreInstallModePath - print "Unfound directory ", DirName + if(FileName): + if os.path.isfile(os.path.join(PreInstallModePath, FileName)): + return PreInstallModePath + else: + if os.path.isdir(PreInstallModePath): + return PreInstallModePath return None ### Setup the path to the dictionaries. WARNING: this needs to be done -# BEFORE importation of the shadow classse generated by swig as found +# BEFORE importation of the shadow classes generated by swig as found # in gdcm, since the dynamic library loads the standard dictionary # when dynamically loaded. # We consider we succefully found the dictionaries path when we encounter @@ -42,9 +51,11 @@ except KeyError: ### Set up the path to the data images for the demos. GDCM_DATA_PATH = BuildInstallOrPreinstallPath("Test", "test.acr") +if not GDCM_DATA_PATH: + print "GDCM_DATA_PATH is not setup properly: unfound Test directory" ### Set up the path to the data images of the test suite. -GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData", "test.acr") +GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData") ### Import the swig generated shadow classes. try: