]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintDict.py.in
* src/gdcmDictSet.h : set the default output to the os variable
[gdcm.git] / gdcmPython / demo / PrintDict.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 print "#####################################################################"
14 # Print the DictSet
15 dicts=gdcm.Global.GetDicts()
16 if(not isinstance(dicts,gdcm.DictSet)):
17         raise RuntimeError,"The DictSet hasn't the good type (%s)" % type(dicts)
18 print "DictSet content :"
19 dicts.Print()
20
21 print "#####################################################################"
22 # Print the Dict (public)
23 pubDict=dicts.GetDefaultPubDict()
24 if(not isinstance(pubDict,gdcm.Dict)):
25         raise RuntimeError,"The public Dict hasn't the good type (%s)" % type(dict)
26 print "Public Dict content :"
27 pubDict.Print()
28
29 print "#####################################################################"
30 # Print the DictEntry (0010|0020)
31 ENTRY_GR = 0x10
32 ENTRY_EL = 0x20
33 entry=pubDict.GetDictEntry(ENTRY_GR,ENTRY_EL)
34 if(not isinstance(entry,gdcm.DictEntry)):
35         raise RuntimeError,"The entry (%04x|%04x) hasn't the good type (%s)" % \
36               (ENTRY_GR,ENTRY_EL,type(entry))
37 print "Entry (%04x|%04x) content :" % (ENTRY_GR,ENTRY_EL)
38 entry.Print()
39
40 # Print the DictEntry (0010|0010)
41 ENTRY_GR = 0x10
42 ENTRY_EL = 0x10
43 entry=pubDict.GetDictEntry(ENTRY_GR,ENTRY_EL)
44 if(not isinstance(entry,gdcm.DictEntry)):
45         raise RuntimeError,"The entry (%04x|%04x) hasn't the good type (%s)" % \
46               (ENTRY_GR,ENTRY_EL,type(entry))
47 print "Entry (%04x|%04x) content :" % (ENTRY_GR,ENTRY_EL)
48 entry.Print()
49