4 from gdcmVersion import *
6 print "gdcmVersion not imported"
8 def BuildInstallOrPreinstallPath(DirName, FileName = None):
9 # Builds a path to the DirName directory. This should work both when:
10 # - the package is properly installed in which case DirName is a subdir
12 # - when in pre-installation mode (basically inside a CVS hierarchy)
13 # in which case DirName and the package itself lie at the same
15 # In both cases we need to express the full path to DirName relatively
16 # to the path to this __init__.py. For this we rely on __path__ variable.
17 # In order to make sure we got the correct Path, we check for the
18 # existence of FileName if it is setted otherwise for the existence of the
20 InstallModePath = os.path.join(__path__[0], DirName + "/")
22 if os.path.isfile(os.path.join(InstallModePath, FileName)):
23 return InstallModePath
25 if os.path.isdir(InstallModePath):
26 return InstallModePath
28 PreInstallModePath = os.path.join(__path__[0], "..", DirName + "/")
30 if os.path.isfile(os.path.join(PreInstallModePath, FileName)):
31 return PreInstallModePath
33 if os.path.isdir(PreInstallModePath):
34 return PreInstallModePath
37 ### Setup the path to the dictionaries. WARNING: this needs to be done
38 # BEFORE importation of the shadow classes generated by swig as found
39 # in gdcm, since the dynamic library loads the standard dictionary
40 # when dynamically loaded.
41 # We consider we succefully found the dictionaries path when we encounter
42 # the standard dictionary i.e. the file dicomV3.dic.
45 ### First consider the environnement variable.
46 os.environ["GDCM_DICT_PATH"]
47 if not os.path.isfile(os.path.join(os.environ["GDCM_DICT_PATH"],
51 Path = BuildInstallOrPreinstallPath("Dicts", "dicomV3.dic")
53 print "Path to dictionaries is mandatory. Exiting"
55 os.environ["GDCM_DICT_PATH"] = Path
56 GDCM_DICT_PATH = os.environ["GDCM_DICT_PATH"]
58 ### Set up the path to the data images for the demos.
59 GDCM_DATA_PATH = BuildInstallOrPreinstallPath("Test", "test.acr")
60 if not GDCM_DATA_PATH:
61 print "GDCM_DATA_PATH is not setup properly: unfound Test directory"
63 ### Set up the path to the data images of the test suite.
64 GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData")
66 ### Import the swig generated shadow classes.
71 raise ImportError, "gdcm extension not imported."
73 ### Expose only the necessary stuff
74 gdcmGlobal = gdcm.gdcmGlobal
75 gdcmDictSet = gdcm.gdcmDictSet
76 gdcmDicomDir = gdcm.gdcmDicomDir
77 gdcmHeader = gdcm.gdcmHeader
78 gdcmHeaderHelper = gdcm.gdcmHeaderHelper
79 gdcmFile = gdcm.gdcmFile
81 def GetPubDictEntryNames():
82 return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictEntryNames()
84 def GetPubDictEntryNamesByCategory():
85 return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictEntryNamesByCategory()