3 ### Setup the path to the dictionaries. WARNING: this needs to be done
4 # BEFORE importation of gdcm. We consider we found the dictionaries
5 # path when we encounter the standard dictionary i.e. the file dicomV3.dic.
6 # 1/ first consider the environnement variable.
7 # 2/ when this fails consider the package installation mode i.e. when the
8 # layout is such that the directory containing the dictionaries is
9 # BELOW (the root is at the top) the current directory.
10 # 3/ eventually consider the pre-installation mode i.e. when the
11 # layout is such that the directory containing the dictionaries is
12 # ABOVE (the root is at the top) the current directory.
15 os.environ["GDCM_DICT_PATH"]
16 if not os.path.isfile(os.path.join(os.environ["GDCM_DICT_PATH"],
20 # Those pathes have to be relative to the package (hence we use __path__):
21 InstallModePath = os.path.join(__path__[0], "Dicts/")
22 if os.path.isfile(os.path.join(InstallModePath, "dicomV3.dic")):
23 os.environ["GDCM_DICT_PATH"] = InstallModePath
24 PreInstallModePath = None
26 PreInstallModePath = os.path.join(__path__[0], "..", "Dicts/")
27 if os.path.isfile(os.path.join(PreInstallModePath, "dicomV3.dic")):
28 os.environ["GDCM_DICT_PATH"] = PreInstallModePath
29 InstallModePath = None
31 print "Unfound gdcm dictionaries path"
34 ### Import the swig generated shadow classes.
39 raise ImportError, "gdcm extension not imported."
41 ### Set up the path to the data images (for examples and test suite)
43 GDCM_DATA_PATH = os.path.join(__path__[0], "Data")
45 if PreInstallModePath:
46 GDCM_DATA_PATH = os.path.join(__path__[0], "..", "Data")
48 print "Unfound data path"
51 ### Get filename from command line or default it
53 FileName = sys.argv[1]
55 FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
57 if not os.path.isfile(FileName):
58 print "Cannot open file ", FileName