3 def BuildInstallOrPreinstallPath(DirName, FileName):
4 # Builds a path to the DirName directory. This should work both when:
5 # - the package is properly installed in which case DirName is a subdir
7 # - when in pre-installation mode (basically inside a CVS hierarchy)
8 # in which case DirName and the package itself lie at the same
10 # In both cases we need to express the full path to DirName relatively
11 # to the path to this __init__.py. For this we rely on __path__ variable.
12 # In order to make sure we got the correct Path, we check for the
13 # existence of FileName.
14 InstallModePath = os.path.join(__path__[0], DirName + "/")
15 if os.path.isfile(os.path.join(InstallModePath, FileName)):
16 return InstallModePath
17 PreInstallModePath = os.path.join(__path__[0], "..", DirName + "/")
18 if os.path.isfile(os.path.join(PreInstallModePath, FileName)):
19 return PreInstallModePath
20 print "Unfound directory ", DirName
23 ### Setup the path to the dictionaries. WARNING: this needs to be done
24 # BEFORE importation of the shadow classse generated by swig as found
25 # in gdcm, since the dynamic library loads the standard dictionary
26 # when dynamically loaded.
27 # We consider we succefully found the dictionaries path when we encounter
28 # the standard dictionary i.e. the file dicomV3.dic.
31 ### First consider the environnement variable.
32 os.environ["GDCM_DICT_PATH"]
33 if not os.path.isfile(os.path.join(os.environ["GDCM_DICT_PATH"],
37 Path = BuildInstallOrPreinstallPath("Dicts", "dicomV3.dic")
39 print "Path to dictionaries is mandatory. Exiting"
41 os.environ["GDCM_DICT_PATH"] = Path
43 ### Set up the path to the data images for the demos.
44 GDCM_DATA_PATH = BuildInstallOrPreinstallPath("Test", "test.acr")
46 ### Set up the path to the data images of the test suite.
47 GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData", "test.acr")
49 ### Import the swig generated shadow classes.
54 raise ImportError, "gdcm extension not imported."
56 ### Expose only the necessary stuff
57 gdcmHeader = gdcm.gdcmHeader
58 gdcmDictSet = gdcm.gdcmDictSet
59 gdcmFile = gdcm.gdcmFile
61 def GetPubDictTagNames():
62 return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictTagNames()
64 def GetPubDictTagNamesByCategory():
65 return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictTagNamesByCategory()