Skip to content

Clean the path the same way on all platforms #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions itchiodl/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import sys
import hashlib
import requests

Expand Down Expand Up @@ -38,14 +37,12 @@ def download(url, path, name, file):


def clean_path(path):
"""Cleans a path on windows"""
if sys.platform in ["win32", "cygwin", "msys"]:
path_clean = re.sub(r"[<>:|?*\"\/\\]", "-", path)
# This checks for strings that end in ... or similar,
# weird corner case that affects fewer than 0.1% of titles
path_clean = re.sub(r"(.)[.]\1+$", "-", path_clean)
return path_clean
return path
"""Cleans up invalid filename characters"""
path_clean = re.sub(r"[<>:|?*\"\/\\]", "-", path)
# This checks for strings that end in ... or similar,
# weird corner case that affects fewer than 0.1% of titles
path_clean = re.sub(r"(.)[.]\1+$", "-", path_clean)
return path_clean


def md5sum(path):
Expand Down