X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=gdcmPython%2Fdemo%2FPrintFile.py.in;h=2b3582faf95c4194914de878aa63dc6bbb56dad6;hb=1f395cbc93181939a4f440b8e8fd3e0ac4962f75;hp=007a3fa1bfc8422f39044e58c2c163d6649c9f78;hpb=f51f3cf0f4013935c1d93a828779e5ca285a31fc;p=gdcm.git diff --git a/gdcmPython/demo/PrintFile.py.in b/gdcmPython/demo/PrintFile.py.in index 007a3fa1..2b3582fa 100644 --- a/gdcmPython/demo/PrintFile.py.in +++ b/gdcmPython/demo/PrintFile.py.in @@ -1,4 +1,5 @@ import sys +import os.path from gdcmConfigDemo import * from gdcmPython.core import * @@ -16,6 +17,8 @@ try: fileName = sys.argv[1] except IndexError: fileName = os.path.join(GDCM_DATA_ROOT, "test.acr") + if( not os.path.isfile(fileName) ): + fileName=os.path.join(os.path.split(sys.argv[0])[0],"test.acr") try: printLevel = int(sys.argv[2]) @@ -23,7 +26,9 @@ except IndexError: printLevel = 1 ### Build the file element list -file = gdcm.File(fileName) +file = gdcm.File() +file.SetFileName(fileName) +file.Load() if not file.IsReadable(): PrintUse() raise RuntimeError,"The '%s' file is not readable with gdcm." % fileName @@ -44,12 +49,9 @@ val=None print "##############################################################" val=file.GetFirstEntry() while(val): - if(isinstance(val,gdcm.ValEntryPtr)): - print "Val %04d|%04d [%s] : %s" % (val.GetGroup(),val.GetElement(), - val.GetName(),val.GetValue()) - else: - print "Bin %04d|%04d [%s] : %s" % (val.GetGroup(),val.GetElement(), - val.GetName(),val.GetValue()) + if(isinstance(val,gdcm.DataEntryPtr)): + print "Data %s [%s] [%s] : %s" % (val.GetKey().str(),val.GetVR().str(), + val.GetName(),val.GetString()) val=file.GetNextEntry() val=None