]> Creatis software - gdcm.git/blob - gdcmPython/demo/test.py
* src/gdcmHeader[h, cxx] gdcmHeader now has an IsReadable predicate.
[gdcm.git] / gdcmPython / demo / test.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, "test.acr")
9
10 if not os.path.isfile(FileName):
11    print "Cannot open file ", FileName
12    sys.exit()
13
14 # On debugging purposes uncomment the next line
15 #s = raw_input("Hit any key in this window to exit")
16
17 ### Build the header element list
18 toRead = gdcmHeader(FileName)
19 if not toRead.IsReadable():
20    print "The ", FileName, " file is not "
21    print "   readable with gdcm. Sorry."
22    sys.exit()
23
24 print "##############################################################"
25 print "### Display all the elements and their respective values"
26 print "## found in the ", FileName, " file."
27 print "##############################################################"
28 ValDict = toRead.GetPubElVal()
29 for key in ValDict.keys():
30         print "[%s] = [%s]" %(key, ValDict[key])