]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintHeader.py.in
* Now, python test might work on systems
[gdcm.git] / gdcmPython / demo / PrintHeader.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_PATH, "test.acr")
18
19 try:
20    printLevel = int(sys.argv[2])
21 except IndexError:
22    printLevel = 1
23
24 #if not os.path.isfile(FileName):
25 #   print "Cannot open file ", FileName
26 #   sys.exit()
27
28 # On debugging purposes uncomment the next line
29 #s = raw_input("Hit any key in this window to exit")
30
31 ### Build the header element list
32 print fileName, type(fileName)
33 header = gdcm.Header(fileName)
34 if not header.IsReadable():
35    print "The ", fileName, " file is not readable with gdcm. Sorry."
36    sys.exit()
37
38 print "##############################################################"
39 print "### Display all the elements and their respective values"
40 print "## found in the ", fileName, " file."
41 print "##############################################################"
42
43 header.Initialize()
44 val=header.GetNextEntry()
45 while(val):
46         val.Print()
47         print ""
48         val=header.GetNextEntry()
49 val=None
50