Skip to content

Commit

Permalink
Merge pull request #13 from fedorov/truncate-time-fraction
Browse files Browse the repository at this point in the history
Add truncate time option
  • Loading branch information
pieper committed Jun 28, 2019
2 parents 8312a30 + 5466a1c commit 615cede
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dicomsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def __init__(self):
'-t': 'test',
'--test': 'test',
'-u': 'unsafe',
'--unsafe': 'unsafe'
'--unsafe': 'unsafe',
'-r': 'truncateTime',
'--truncateTime': 'truncateTime'
}

self.defaultOptions = {
Expand All @@ -77,7 +79,8 @@ def __init__(self):
'keepGoing': False,
'verbose': False,
'test': False,
'unsafe': False
'unsafe': False,
'truncateTime': False
}

self.requiredOptions = [ 'sourceDir', 'targetPattern', ]
Expand Down Expand Up @@ -128,6 +131,9 @@ def pathFromDatasetPattern(self,ds,safe=True):
value = ""
if value == "":
value = "Unknown%s" % key
if self.options['truncateTime']:
if key.endswith("Time") and str(value)[str(value).find('.')+1:] == '000000':
value = str(value)[:str(value).find('.')]
if safe:
replacements[key] = self.safeFileName(str(value))
else:
Expand Down

0 comments on commit 615cede

Please sign in to comment.