-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put series into subfolders when downloading a study
- Loading branch information
Showing
3 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import re | ||
|
||
|
||
def sanitize_dirname(dirname): | ||
def sanitize_filename(name): | ||
"""Windows can't handle some file and folder names so we have to sanitize them.""" | ||
dirname = dirname.strip() | ||
dirname = re.sub(r"(\<|\>|\:|\"|\/|\\|\||\?|\*)", "", dirname) | ||
dirname = re.sub(r"(\.+)$", "", dirname) | ||
return dirname | ||
|
||
|
||
def sanitize_filename(filename): | ||
return sanitize_dirname(filename) | ||
sanitized_name = re.sub(r'[<>:"/\\|?*\x00-\x1F]', "_", name) | ||
sanitized_name = sanitized_name.strip() | ||
if not sanitized_name: | ||
sanitized_name = "default" | ||
return sanitized_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters