]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintDicomDir.py.in
703ee20ec7846354e50c9421832b5c910c1b2930
[gdcm.git] / gdcmPython / demo / PrintDicomDir.py.in
1 import sys
2 import os
3
4 sys.path.append('${GDCM_BINARY_DIR}')
5 if os.name == 'posix':
6    sys.path.append('${GDCM_BINARY_DIR}/bin')
7 else:
8    sys.path.append('${GDCM_BINARY_DIR}/bin/Release')
9    sys.path.append('${GDCM_BINARY_DIR}/bin/Debug')
10
11 from gdcmPython.core import *
12
13 ### Get filename from command line or default it
14 try:
15    fileName = sys.argv[1]
16 except IndexError:
17    fileName = os.path.join(GDCM_DATA_ROOT, "DICOMDIR")
18
19 try:
20    printLevel = int(sys.argv[2])
21 except IndexError:
22    printLevel = 1
23
24 ### Build the DicomDir element list
25 dicomdir = gdcm.DicomDir(fileName)
26 if not dicomdir.IsReadable():
27    print
28    raise RuntimeError,"The '%s' DicomDir is not readable with gdcm." % fileName
29    #sys.exit()
30
31 print "##############################################################"
32 print "## Display all the elements and their respective values"
33 print "## found in the ", fileName, " file."
34 print "##############################################################"
35 dicomdir.SetPrintLevel(-1)
36 dicomdir.Print()
37