GDCM: TestReader.py

GDCM 3.2.7

TestReader.py

This is a C++ example on how to use gdcm::Reader

1
14
15import os,sys
16import gdcm
17
18def TestRead(filename, verbose = False):
19 r = gdcm.Reader()
20 r.SetFileName( filename )
21 success = r.Read()
22 #if verbose: print r.GetFile()
23 if verbose: print(r.GetFile().GetDataSet())
24 return success
25
26if __name__ == "__main__":
27 success = 0
28 try:
29 filename = os.sys.argv[1]
30 success += TestRead( filename, True )
31 except:
32 # loop over all files:
33 gdcm.Trace.DebugOff()
34 gdcm.Trace.WarningOff()
35 t = gdcm.Testing()
36 nfiles = t.GetNumberOfFileNames()
37 for i in range(0,nfiles):
38 filename = t.GetFileName(i)
39 success += TestRead( filename )
40
41
42 # Test succeed ?
43 sys.exit(success == 0)
gdcm::Reader
Reader ala DOM (Document Object Model).
Definition gdcmReader.h:54
gdcm::Testing
class for testing
Definition gdcmTesting.h:32
gdcm::Trace::WarningOff
static void WarningOff()
gdcm::Trace::DebugOff
static void DebugOff()