X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=gdcmPython%2F__init__.py;h=3cbeb9cf18b236957a6c9245fc11e37b287fa503;hb=f82be8836ed5bc55c89d59fee471bb2c92737311;hp=26de4736dda7eb8520978e990b586ebd7422470e;hpb=5fbee0c35cc0f02ceea5d5a8be0c1900c63143bb;p=gdcm.git diff --git a/gdcmPython/__init__.py b/gdcmPython/__init__.py index 26de4736..3cbeb9cf 100644 --- a/gdcmPython/__init__.py +++ b/gdcmPython/__init__.py @@ -1,6 +1,11 @@ import os, sys -def BuildInstallOrPreinstallPath(DirName, FileName): +try: + from gdcmVersion import * +except: + print "gdcmVersion not imported" + +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,13 +15,23 @@ 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 + 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 @@ -45,7 +60,7 @@ 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: @@ -55,12 +70,14 @@ except ImportError,e: raise ImportError, "gdcm extension not imported." ### Expose only the necessary stuff -gdcmHeader = gdcm.gdcmHeader -gdcmDictSet = gdcm.gdcmDictSet -gdcmFile = gdcm.gdcmFile +gdcmGlobal = gdcm.gdcmGlobal +gdcmDictSet = gdcm.gdcmDictSet +gdcmHeader = gdcm.gdcmHeader +gdcmHeaderHelper = gdcm.gdcmHeaderHelper +gdcmFile = gdcm.gdcmFile -def GetPubDictTagNames(): - return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictTagNames() +def GetPubDictEntryNames(): + return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictEntryNames() -def GetPubDictTagNamesByCategory(): - return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictTagNamesByCategory() +def GetPubDictEntryNamesByCategory(): + return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictEntryNamesByCategory()