]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintDict.py.in
* bug fix in the Python demos, due to the recent changes
[gdcm.git] / gdcmPython / demo / PrintDict.py.in
1 from gdcmConfigDemo import *
2 from gdcmPython.core import *
3
4 print "#####################################################################"
5 # Print the DictSet
6 dicts=gdcm.Global.GetDicts()
7 if(not isinstance(dicts,gdcm.DictSet)):
8    raise RuntimeError,"The DictSet hasn't the good type (%s)" % type(dicts)
9 print "DictSet content :"
10 dicts.Print()
11
12 print "#####################################################################"
13 # Print the Dict (public)
14 pubDict=dicts.GetDefaultPubDict()
15 if(not isinstance(pubDict,gdcm.Dict)):
16    raise RuntimeError,"The public Dict hasn't the good type (%s)" % type(dict)
17 print "Public Dict content :"
18 pubDict.Print()
19
20 print "#####################################################################"
21 # Print the DictEntry (0010|0020)
22 ENTRY_GR = 0x10
23 ENTRY_EL = 0x20
24 entry=pubDict.GetEntry(ENTRY_GR,ENTRY_EL)
25 if(not isinstance(entry,gdcm.DictEntry)):
26    raise RuntimeError,"The entry (%04x|%04x) hasn't the good type (%s)" % \
27          (ENTRY_GR,ENTRY_EL,type(entry))
28 print "Entry (%04x|%04x) content :" % (ENTRY_GR,ENTRY_EL)
29 entry.Print()
30
31 print "#####################################################################"
32 # Print the public Dict content
33 print "dict content :"
34 entry=pubDict.GetFirstEntry()
35 while(entry):
36    print "%4x|%4x [%s] - M%s : %s (%s)" %\
37          (entry.GetGroup(),entry.GetElement(),entry.GetVR().str(),entry.GetVM(),          entry.GetName(),entry.GetKey().str())
38    entry=pubDict.GetNextEntry()
39