]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintHeader.py
* src/gdcmDicomDir.cxx, gdcmDocEntrySet.cxx: removed inclusion of errno.h
[gdcm.git] / gdcmPython / demo / PrintHeader.py
1 from gdcmPython import *
2 import sys
3 import os
4
5 ### Get filename from command line or default it
6 try:
7    FileName = sys.argv[1]
8 except IndexError:
9    FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
10
11 try:
12    printLevel = int(sys.argv[2])
13 except IndexError:
14    printLevel = 1
15
16 #if not os.path.isfile(FileName):
17 #   print "Cannot open file ", FileName
18 #   sys.exit()
19
20 # On debugging purposes uncomment the next line
21 #s = raw_input("Hit any key in this window to exit")
22
23 ### Build the header element list
24 toRead = gdcmHeader(FileName)
25 if not toRead.IsReadable():
26    print "The ", FileName, " file is not readable with gdcm. Sorry."
27    sys.exit()
28
29 print "##############################################################"
30 print "### Display all the elements and their respective values"
31 print "## found in the ", FileName, " file."
32 print "##############################################################"
33 ###toRead.SetPrintLevel(printLevel)
34 ###toRead.Print()
35
36 ValDict = toRead.GetEntry()
37 for key in ValDict.keys():
38         print "[%s] = [%s]" %(key, ValDict[key])
39