X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=gdcmPython%2Fdemo%2FPrintFile.py.in;h=a6d6bfbb2bdc4d5fc9d202046ab43e826551c8d7;hb=17daf7e7caceddf44e73864ee8d366613a1f0c82;hp=007a3fa1bfc8422f39044e58c2c163d6649c9f78;hpb=f51f3cf0f4013935c1d93a828779e5ca285a31fc;p=gdcm.git diff --git a/gdcmPython/demo/PrintFile.py.in b/gdcmPython/demo/PrintFile.py.in index 007a3fa1..a6d6bfbb 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.New() +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