]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintDicomDir.py
* Remove useless methods added by JPR for Python users. All was already
[gdcm.git] / gdcmPython / demo / PrintDicomDir.py
1 from gdcmPython import *
2 import sys
3
4 ### Get filename from command line or default it
5 try:
6    fileName = sys.argv[1]
7 except IndexError:
8    fileName = os.path.join(GDCM_DATA_PATH, "DICOMDIR")
9
10 try:
11    printLevel = int(sys.argv[2])
12 except IndexError:
13    printLevel = 1
14
15 ### Build the header element list
16 dicomdir = gdcmDicomDir(fileName)
17 if not dicomdir.IsReadable():
18    print "The '", fileName, "' DicomDir is not readable with gdcm. Sorry."
19    sys.exit()
20
21 print "##############################################################"
22 print "## Display all the elements and their respective values"
23 print "## found in the ", fileName, " file."
24 print "##############################################################"
25 dicomdir.SetPrintLevel(-1)
26 dicomdir.Print()
27