]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintDicomDir.py
b9538392cb903293602da2c321d5842b9776bd14
[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 toRead = gdcmDicomDir(FileName)
17 if not toRead.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 toRead.SetPrintLevel(-1)
26 toRead.Print()
27
28 # ValDict = toRead.GetEntry()
29 # for key in ValDict.keys():
30 #       print "[%s] = [%s]" %(key, ValDict[key])
31