]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintDicomDir.py.in
* Amelioration of the Python part concerning demos
[gdcm.git] / gdcmPython / demo / PrintDicomDir.py.in
1 from gdcmConfigDemo import *
2 from gdcmPython.core import *
3
4 def PrintUse():
5    print ""
6    print "Use :"
7    print "-----"
8    print "%s <dicomDir>" % sys.argv[0]
9    print "   dicomDir : path to the DICOMDIR to parse"
10    print ""
11    print ""
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_ROOT, "DICOMDIR")
18
19 try:
20    printLevel = int(sys.argv[2])
21 except IndexError:
22    printLevel = 1
23
24 ### Build the DicomDir element list
25 dicomdir = gdcm.DicomDir(fileName)
26 if not dicomdir.IsReadable():
27    PrintUse()
28    raise RuntimeError,"The '%s' DicomDir is not readable with gdcm." % fileName
29
30 print "DICOMDIR -->",fileName
31 print "##############################################################"
32 print "## Display all the elements and their respective values"
33 print "## found in the ", fileName, " file."
34 print "##############################################################"
35 dicomdir.SetPrintLevel(-1)
36 dicomdir.Print()
37