comparison Resources/Samples/Python/AutoClassify.py @ 2070:7e6afa0beaf6

samples: improved handling of special characters in paths
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 14 Jul 2016 09:05:22 +0200
parents 65b1ce7cb84f
children bec08e9236f5
comparison
equal deleted inserted replaced
2069:fabf7820d1f1 2070:7e6afa0beaf6
43 help = 'Remove DICOM files from Orthanc once classified (disabled by default)') 43 help = 'Remove DICOM files from Orthanc once classified (disabled by default)')
44 parser.set_defaults(remove = False) 44 parser.set_defaults(remove = False)
45 45
46 46
47 def FixPath(p): 47 def FixPath(p):
48 return p.encode('ascii', 'ignore').strip().decode() 48 return p.encode('ascii', errors = 'replace').translate(None, r"'\/:*?\"<>|!=").strip()
49 49
50 def GetTag(resource, tag): 50 def GetTag(resource, tag):
51 if ('MainDicomTags' in resource and 51 if ('MainDicomTags' in resource and
52 tag in resource['MainDicomTags']): 52 tag in resource['MainDicomTags']):
53 return resource['MainDicomTags'][tag] 53 return resource['MainDicomTags'][tag]