3 ### Setup the path to the dictionaries. WARNING: this needs to be done
4 # BEFORE importation of the shadow classse generated by swig as found
5 # in gdcm, since the dynamic library loads the standard dictionary
6 # when dynamically loaded.
7 # We consider we succefully found the dictionaries path when we encounter
8 # the standard dictionary i.e. the file dicomV3.dic.
11 ### First consider the environnement variable.
12 os.environ["GDCM_DICT_PATH"]
13 if not os.path.isfile(os.path.join(os.environ["GDCM_DICT_PATH"],
17 # When environnement variable is unavailable assume the package was
18 # properly installed i.e. the layout is such that the directory containing
19 # the dictionaries is BELOW (the root is at the top) the current file.
20 # Note: when importing this __init__ file the pathes are relative to the
21 # invocation directory. In order to get them relative to the package
22 # (or more simply to this file) we rely on the __path__ variable.
23 InstallModePath = os.path.join(__path__[0], "Dicts/")
24 if os.path.isfile(os.path.join(InstallModePath, "dicomV3.dic")):
25 os.environ["GDCM_DICT_PATH"] = InstallModePath
26 PreInstallModePath = None
28 # When both environnement variable and proper package installation
29 # strategy fail we eventually consider the pre-installation mode
30 # i.e. when developpers are toying in a CVS tree. In this case
31 # the layout is such that the directory containing the dictionaries is
32 # ABOVE (the root is at the top) the current directory.
33 PreInstallModePath = os.path.join(__path__[0], "..", "Dicts/")
34 if os.path.isfile(os.path.join(PreInstallModePath, "dicomV3.dic")):
35 os.environ["GDCM_DICT_PATH"] = PreInstallModePath
36 InstallModePath = None
38 print "Unfound gdcm dictionaries path"
41 ### Set up the path to the data images (for the test suite and the demo
42 # examples). As for GDCM_DICT_PATH we offer both proper python package
43 # installation scheme and the pre-install mode (see above).
44 InstallModePath = os.path.join(__path__[0], "Data")
45 if os.path.isfile(os.path.join(InstallModePath, "test.acr")):
46 GDCM_DATA_PATH = InstallModePath
48 PreInstallModePath = os.path.join(__path__[0], "..", "Data")
49 if os.path.isfile(os.path.join(PreInstallModePath, "test.acr")):
50 GDCM_DATA_PATH = PreInstallModePath
52 print "Unfound data path"
55 ### Import the swig generated shadow classes.
60 raise ImportError, "gdcm extension not imported."
62 ### Expose only the necessary stuff
63 gdcmHeader = gdcm.gdcmHeader
64 gdcmDictSet = gdcm.gdcmDictSet
65 gdcmFile = gdcm.gdcmFile