]> Creatis software - gdcm.git/commitdiff
* Add the PrintDicomDir test
authorregrain <regrain>
Thu, 13 Jan 2005 10:49:25 +0000 (10:49 +0000)
committerregrain <regrain>
Thu, 13 Jan 2005 10:49:25 +0000 (10:49 +0000)
   -- BeNours

ChangeLog
gdcmPython/demo/CMakeLists.txt
gdcmPython/demo/PrintDicomDir.py
gdcmPython/demo/PrintDicomDir.py.in [new file with mode: 0644]
gdcmPython/demo/PrintHeader.py
gdcmPython/demo/PrintHeader.py.in

index bd232debb766665b3632bd65231571cb60274080..96b10e1250645a7e941879890ee3effdbf19c716 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2005-01-13 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
    * Now, python test might work on systems
+   * Add the PrintDicomDir test
 
 2005-01-13 Jean-Pierre Roux <jpr@creatis.univ-lyon1.fr>
    * FIX : First entry following group 0002 was lost for
index f34df9c5ba989c46985929664541dd0c7bc1cb2e..25428d4e40ae96858589fc80cd87fb63e24288d0 100644 (file)
@@ -19,6 +19,9 @@ IF(PYTHON_EXECUTABLE)
   ADD_TEST(Python-PrintHeader ${PYTHON_EXECUTABLE}
     ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintHeader.py
     )
+  ADD_TEST(Python-PrintDicomDir ${PYTHON_EXECUTABLE}
+    ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintDicomDir.py
+    )
 ELSE(PYTHON_EXECUTABLE)
   MESSAGE(FATAL_ERROR "You requested testing for python, but python was not
     found")
@@ -32,3 +35,8 @@ CONFIGURE_FILE(
     ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintHeader.py
 )
 
+CONFIGURE_FILE(
+    ${GDCM_SOURCE_DIR}/gdcmPython/demo/PrintDicomDir.py.in
+    ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintDicomDir.py
+)
+
index b9538392cb903293602da2c321d5842b9776bd14..a4c534f3422b4da68c0f99f41695fc9b2ca34610 100644 (file)
@@ -3,9 +3,9 @@ import sys
 
 ### Get filename from command line or default it
 try:
-   FileName = sys.argv[1]
+   fileName = sys.argv[1]
 except IndexError:
-   FileName = os.path.join(GDCM_DATA_PATH, "DICOMDIR")
+   fileName = os.path.join(GDCM_DATA_PATH, "DICOMDIR")
 
 try:
    printLevel = int(sys.argv[2])
@@ -13,19 +13,15 @@ except IndexError:
    printLevel = 1
 
 ### Build the header element list
-toRead = gdcmDicomDir(FileName)
-if not toRead.IsReadable():
-   print "The ", FileName, " DicomDir is not readable with gdcm. Sorry."
+dicomdir = gdcmDicomDir(fileName)
+if not dicomdir.IsReadable():
+   print "The '", fileName, "' DicomDir is not readable with gdcm. Sorry."
    sys.exit()
 
 print "##############################################################"
-print "### Display all the elements and their respective values"
-print "## found in the ", FileName, " file."
+print "## Display all the elements and their respective values"
+print "## found in the ", fileName, " file."
 print "##############################################################"
-toRead.SetPrintLevel(-1)
-toRead.Print()
-
-# ValDict = toRead.GetEntry()
-# for key in ValDict.keys():
-#      print "[%s] = [%s]" %(key, ValDict[key])
+dicomdir.SetPrintLevel(-1)
+dicomdir.Print()
 
diff --git a/gdcmPython/demo/PrintDicomDir.py.in b/gdcmPython/demo/PrintDicomDir.py.in
new file mode 100644 (file)
index 0000000..1f74e54
--- /dev/null
@@ -0,0 +1,37 @@
+import sys
+import os
+
+sys.path.append('${GDCM_BINARY_DIR}')
+if os.name == 'posix':
+   sys.path.append('${GDCM_BINARY_DIR}/bin')
+else:
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Release')
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Debug')
+
+from gdcmPython.core import *
+
+### Get filename from command line or default it
+try:
+   fileName = sys.argv[1]
+except IndexError:
+   fileName = os.path.join(GDCM_DATA_PATH, "DICOMDIR")
+
+try:
+   printLevel = int(sys.argv[2])
+except IndexError:
+   printLevel = 1
+
+### Build the header element list
+dicomdir = gdcm.DicomDir(fileName)
+if not dicomdir.IsReadable():
+   print
+   raise RuntimeError,"The '%s' DicomDir is not readable with gdcm." % fileName
+   #sys.exit()
+
+print "##############################################################"
+print "## Display all the elements and their respective values"
+print "## found in the ", fileName, " file."
+print "##############################################################"
+dicomdir.SetPrintLevel(-1)
+dicomdir.Print()
+
index 0125576c117b55f355647ab361c529488b70aad6..ae409700545f0519f2a348bc86405ce4e6b5ea2f 100644 (file)
@@ -24,7 +24,7 @@ except IndexError:
 print fileName, type(fileName)
 header = gdcm.Header(fileName)
 if not header.IsReadable():
-   print "The ", fileName, " file is not readable with gdcm. Sorry."
+   print "The '", fileName, "' file is not readable with gdcm. Sorry."
    sys.exit()
 
 print "##############################################################"
index affa5f48425eb95bf2d65706ec7b75a9a672f08a..cd9acfb849c735b4f0f033f170955355e130e0c9 100644 (file)
@@ -21,19 +21,11 @@ try:
 except IndexError:
    printLevel = 1
 
-#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")
-
 ### Build the header element list
 print fileName, type(fileName)
 header = gdcm.Header(fileName)
 if not header.IsReadable():
-   print "The ", fileName, " file is not readable with gdcm. Sorry."
-   sys.exit()
+   raise RuntimeError,"The '%s' file is not readable with gdcm." % fileName
 
 print "##############################################################"
 print "### Display all the elements and their respective values"