]> Creatis software - gdcm.git/commitdiff
* The subdirectory Data (containing all the images used for the
authorfrog <frog>
Wed, 7 May 2003 13:21:49 +0000 (13:21 +0000)
committerfrog <frog>
Wed, 7 May 2003 13:21:49 +0000 (13:21 +0000)
        test suite) is not part of this repository anymore. A new module
        containing those images is now available at
          :pserver:xxx@cvs.creatis.insa-lyon.fr:2402/cvs/public
        with the name gdcmData.
        All the python scripts (including the package initialisation file
        gdcmPython/__init__.py) were adapated to take this change into
        account (basically GDCM_DATA_PATH is now GDCM_TEST_DATA_PATH).

ChangeLog
gdcmPython/__init__.py
gdcmPython/demo/PrintHeader.py
gdcmPython/demo/testAll.py
gdcmPython/testSuite.py
setup.py

index 9deeb3673850f88345ce6bcd1fdccda59ece5eb1..daa8a82ab3dfa4d9001c9a2076658fcdc5b62e63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2003-05-7  Eric Boix <Eric.Boix@creatis.insa-lyon.fr> with JPR
+      * src/gdcmHeader.cxx: the constructor no longer exits when an
+        unexisting file is given as argument.
+      * The subdirectory Data (containing all the images used for the
+        test suite) is not part of this repository anymore. A new module
+        containing those images is now available at 
+          :pserver:frog@cvs.creatis.insa-lyon.fr:2402/cvs/public
+        with the name gdcmData.
+        All the python scripts (including the package initialisation file
+        gdcmPython/__init__.py) were adapated to take this change into
+        account (basically GDCM_DATA_PATH is now GDCM_TEST_DATA_PATH).
+
 2003-05-5  Eric Boix <Eric.Boix@creatis.insa-lyon.fr> with JPR
       * vtk subdir added. Contains vtkGdcmReader.[cxx|h] a vtk class
         inherinting from vtkImageReader and testvtkGdcmReader.cxx a small
index bf7fe97d768210ebd73c8c4b00a4d7de1d40c428..e1b32c2a36194f0879246753b734a79c86414a0e 100644 (file)
@@ -1,5 +1,25 @@
 import os, sys
 
+def BuildInstallOrPreinstallPath(DirName, FileName):
+   # 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,
+   # - when in pre-installation mode (basically inside a CVS hierarchy)
+   #   in which case DirName and the package itself lie at the same
+   #   filesystem level.
+   # 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.
+   InstallModePath = os.path.join(__path__[0], DirName + "/")
+   if os.path.isfile(os.path.join(InstallModePath, FileName)):
+      return InstallModePath
+   PreInstallModePath = os.path.join(__path__[0], "..", DirName + "/")
+   if os.path.isfile(os.path.join(PreInstallModePath, FileName)):
+      return PreInstallModePath
+   print "Unfound directory ", DirName
+   return None
+
 ### Setup the path to the dictionaries. WARNING: this needs to be done
 #   BEFORE importation of the shadow classse generated by swig as found
 #   in gdcm, since the dynamic library loads the standard dictionary
@@ -14,43 +34,17 @@ try:
                                       "dicomV3.dic")):
       raise KeyError
 except KeyError:
-   # When environnement variable is unavailable assume the package was
-   # properly installed i.e. the layout is such that the directory containing
-   # the dictionaries is BELOW (the root is at the top) the current file.
-   # Note: when importing this __init__ file the pathes are relative to the
-   #       invocation directory. In order to get them relative to the package
-   #       (or more simply to this file) we rely on the __path__ variable.
-   InstallModePath = os.path.join(__path__[0], "Dicts/")
-   if os.path.isfile(os.path.join(InstallModePath, "dicomV3.dic")):
-      os.environ["GDCM_DICT_PATH"] = InstallModePath
-      PreInstallModePath = None
-   else:
-      # When both environnement variable and proper package installation 
-      # strategy fail we eventually consider the pre-installation mode
-      # i.e. when developpers are toying in a CVS tree. In this case
-      # the layout is such that the directory containing the dictionaries is
-      # ABOVE (the root is at the top) the current directory.
-      PreInstallModePath = os.path.join(__path__[0], "..", "Dicts/")
-      if os.path.isfile(os.path.join(PreInstallModePath, "dicomV3.dic")):
-         os.environ["GDCM_DICT_PATH"] = PreInstallModePath
-         InstallModePath = None
-      else:
-         print "Unfound gdcm dictionaries path"
-         sys.exit(1)
-
-### Set up the path to the data images (for the test suite and the demo
-#   examples). As for GDCM_DICT_PATH we offer both proper python package
-#   installation scheme and the pre-install mode (see above).
-InstallModePath = os.path.join(__path__[0], "gdcmData")
-if os.path.isfile(os.path.join(InstallModePath, "test.acr")):
-   GDCM_DATA_PATH = InstallModePath
-else:
-   PreInstallModePath = os.path.join(__path__[0], "..", "gdcmData")
-   if os.path.isfile(os.path.join(PreInstallModePath, "test.acr")):
-      GDCM_DATA_PATH = PreInstallModePath
-   else:
-      print "Unfound data path"
+   Path = BuildInstallOrPreinstallPath("Dicts", "dicomV3.dic")
+   if not Path:
+      print "Path to dictionaries is mandatory. Exiting"
       sys.exit(1)
+   os.environ["GDCM_DICT_PATH"] = Path
+
+### Set up the path to the data images for the demos.
+GDCM_DATA_PATH = BuildInstallOrPreinstallPath("Test", "test.acr")
+
+### Set up the path to the data images of the test suite.
+GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData", "test.acr")
 
 ### Import the swig generated shadow classes.
 try:
index fa98de2d86a4a8108a69f2b027ad399ca0b9e66e..6edd80fe7f4d7a43ea55874be12ae09f3c6afcfb 100644 (file)
@@ -7,9 +7,9 @@ try:
 except IndexError:
    FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
 
-if not os.path.isfile(FileName):
-   print "Cannot open file ", FileName
-   sys.exit()
+#if not os.path.isfile(FileName):
+#   print "Cannot open file ", FileName
+#   sys.exit()
 
 # On debugging purposes uncomment the next line
 #s = raw_input("Hit any key in this window to exit")
@@ -17,8 +17,7 @@ if not os.path.isfile(FileName):
 ### Build the header element list
 toRead = gdcmHeader(FileName)
 if not toRead.IsReadable():
-   print "The ", FileName, " file is not "
-   print "   readable with gdcm. Sorry."
+   print "The ", FileName, " file is not readable with gdcm. Sorry."
    sys.exit()
 
 print "##############################################################"
index 89c045972012ce460ea15ad240628e3219cea69d..9bf4a502502a3520f3253641e890743c3c87d6aa 100644 (file)
@@ -1,3 +1,5 @@
+import glob, os
+import sys
 from gdcmPython import *
 
 # Test each file of the Data directory
@@ -26,10 +28,11 @@ AllFiles = [
        ]
 
 if __name__ == '__main__':
-       for file in AllFiles:
-               fileName = os.path.join(GDCM_DATA_PATH, file)
-               print "############## file :", fileName
-               toRead = gdcmHeader(fileName)
-               ValDict = toRead.GetPubElVal()
-               for key in ValDict.keys():
-                       print "   [%s] = [%s]" %(key, ValDict[key])
+   # AllFiles = glob.glob(os.path.join(GDCM_TEST_DATA_PATH,"*.dcm"))
+   for file in AllFiles:
+      fileName = os.path.join(GDCM_TEST_DATA_PATH, file)
+      print "############## file :", fileName
+      toRead = gdcmHeader(fileName)
+      ValDict = toRead.GetPubElVal()
+      for key in ValDict.keys():
+          print "   [%s] = [%s]" %(key, ValDict[key])
index 149345986ab1303e10e1c3a0398b4d162ed4b604..238ac033846aababc4e2670623540d7a81e4f2af 100644 (file)
@@ -495,7 +495,7 @@ class gdcmTestCase(unittest.TestCase):
 
    def _BaseTest(self, FileSet):
       for entry in FileSet:
-         fileName = os.path.join(GDCM_DATA_PATH, entry[0])
+         fileName = os.path.join(GDCM_TEST_DATA_PATH, entry[0])
          toRead = gdcmHeader(fileName)
          valDict = toRead.GetPubElVal()
          for subEntry in entry[1]:
@@ -519,7 +519,7 @@ class gdcmTestCase(unittest.TestCase):
 
    def testWrite(self):
       import md5
-      SourceFileName = os.path.join(GDCM_DATA_PATH,
+      SourceFileName = os.path.join(GDCM_TEST_DATA_PATH,
                                     'gdcm-MR-PHILIPS-16-Multi-Seq.dcm')
       Source = gdcmFile(SourceFileName);
       Source.GetImageData()
index 4a75e2d0af31082b7fb9e2fe66dc0021c3e14499..d36e0517cfcc024ca99b88aea0cdfc3514a90992 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ ThisModule='gdcmPython'
 gdcmPythonSrcDir=ThisModule
 gdcmSrcDir      ="src"
 gdcmDictsDir    ="Dicts"
-gdcmDataDir     ="Data"
+gdcmTestDir     ="Test"
 
 # Due to a disutil oddity on Unices : see
 # http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325
@@ -43,8 +43,8 @@ setup(name=ThisModule,
                    define_macros=macros,
                    swig_cpp=1,
                    swig_include=[ gdcmSrcDir] ) ],
-      data_files=[(os.path.join(targetDir,"Data"),
-                   glob.glob(os.path.join(gdcmDataDir,"*.*"))),
+      data_files=[(os.path.join(targetDir,gdcmTestDir),
+                   glob.glob(os.path.join(gdcmTestDir,"*.acr"))),
                   (os.path.join(targetDir,"Dicts"),
                    glob.glob(os.path.join(gdcmDictsDir,"*.*"))),
                 ]